This commit is contained in:
@@ -4,11 +4,11 @@ import prisma from '../../../../../lib/prisma'
|
||||
// PATCH /api/admin/reports/[id] — Update report status
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const { status } = await request.json()
|
||||
|
||||
if (!userId) {
|
||||
|
||||
@@ -4,9 +4,12 @@ import prisma from '../../../../lib/prisma'
|
||||
type Params = { params: Promise<{ id: string }> }
|
||||
|
||||
// GET /api/blog/[id]
|
||||
export async function GET(_request: NextRequest, { params }: Params) {
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const post = await prisma.blogPost.findUnique({ where: { id } })
|
||||
if (!post) return NextResponse.json({ error: 'Non trouvé' }, { status: 404 })
|
||||
return NextResponse.json(post)
|
||||
@@ -17,9 +20,12 @@ export async function GET(_request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// PATCH /api/blog/[id]
|
||||
export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const body = await request.json()
|
||||
const post = await prisma.blogPost.update({ where: { id }, data: body })
|
||||
return NextResponse.json(post)
|
||||
@@ -30,9 +36,12 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// DELETE /api/blog/[id]
|
||||
export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
await prisma.blogPost.delete({ where: { id } })
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,9 +4,12 @@ import prisma from '../../../../lib/prisma'
|
||||
type Params = { params: Promise<{ id: string }> }
|
||||
|
||||
// GET /api/businesses/[id]
|
||||
export async function GET(_request: NextRequest, { params }: Params) {
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const business = await prisma.business.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
@@ -25,9 +28,12 @@ export async function GET(_request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// PATCH /api/businesses/[id]
|
||||
export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const body = await request.json()
|
||||
const business = await prisma.business.update({
|
||||
where: { id },
|
||||
@@ -42,9 +48,12 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// DELETE /api/businesses/[id]
|
||||
export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
await prisma.business.delete({ where: { id } })
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,11 +4,11 @@ import prisma from '../../../../../lib/prisma'
|
||||
// PATCH /api/conversations/[id]/archive — Toggle archive status for the user
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const { archived } = await request.json()
|
||||
|
||||
if (!userId) {
|
||||
|
||||
@@ -4,11 +4,11 @@ import prisma from '../../../../lib/prisma'
|
||||
// GET /api/conversations/[id] — Get messages for a conversation
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
|
||||
if (!userId) {
|
||||
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 })
|
||||
@@ -36,6 +36,7 @@ export async function GET(
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
email: true,
|
||||
avatar: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ export async function GET(request: NextRequest) {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
email: true,
|
||||
avatar: true,
|
||||
role: true
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@ import prisma from '../../../../lib/prisma'
|
||||
type Params = { params: Promise<{ id: string }> }
|
||||
|
||||
// GET /api/interviews/[id]
|
||||
export async function GET(_request: NextRequest, { params }: Params) {
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const interview = await prisma.interview.findUnique({ where: { id } })
|
||||
if (!interview) return NextResponse.json({ error: 'Non trouvé' }, { status: 404 })
|
||||
return NextResponse.json(interview)
|
||||
@@ -17,9 +20,12 @@ export async function GET(_request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// PATCH /api/interviews/[id]
|
||||
export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const body = await request.json()
|
||||
const interview = await prisma.interview.update({ where: { id }, data: body })
|
||||
return NextResponse.json(interview)
|
||||
@@ -30,9 +36,12 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// DELETE /api/interviews/[id]
|
||||
export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
await prisma.interview.delete({ where: { id } })
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
|
||||
@@ -4,11 +4,11 @@ import prisma from '../../../../../lib/prisma'
|
||||
// POST /api/messages/[id]/report — Report a message for moderation
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const { reason } = await request.json()
|
||||
|
||||
if (!userId) {
|
||||
|
||||
@@ -4,9 +4,12 @@ import prisma from '../../../../lib/prisma'
|
||||
type Params = { params: Promise<{ id: string }> }
|
||||
|
||||
// GET /api/offers/[id]
|
||||
export async function GET(_request: NextRequest, { params }: Params) {
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const offer = await prisma.offer.findUnique({
|
||||
where: { id },
|
||||
include: { business: true },
|
||||
@@ -20,9 +23,12 @@ export async function GET(_request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// PATCH /api/offers/[id]
|
||||
export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
const body = await request.json()
|
||||
const offer = await prisma.offer.update({
|
||||
where: { id },
|
||||
@@ -37,9 +43,12 @@ export async function PATCH(request: NextRequest, { params }: Params) {
|
||||
}
|
||||
|
||||
// DELETE /api/offers/[id]
|
||||
export async function DELETE(_request: NextRequest, { params }: Params) {
|
||||
export async function DELETE(
|
||||
_request: NextRequest,
|
||||
context: { params: Promise<{ id: string }> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const { id } = await params
|
||||
const { id } = await context.params
|
||||
await prisma.offer.delete({ where: { id } })
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
|
||||
@@ -2,7 +2,10 @@ import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '../../../../lib/prisma'
|
||||
|
||||
// PATCH /api/users/me — Update personal user profile
|
||||
export async function PATCH(request: NextRequest) {
|
||||
export async function PATCH(
|
||||
request: NextRequest,
|
||||
context: { params: Promise<any> }
|
||||
): Promise<Response> {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id')
|
||||
const data = await request.json()
|
||||
|
||||
@@ -17,7 +17,10 @@ export async function GET(request: NextRequest) {
|
||||
name: true,
|
||||
email: true,
|
||||
role: true,
|
||||
avatar: true
|
||||
avatar: true,
|
||||
phone: true,
|
||||
bio: true,
|
||||
location: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, Suspense } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { LayoutDashboard, Edit3, ShoppingBag, CreditCard, LogOut, Eye, MessageSquare, User as UserIcon, Rocket, ShieldAlert } from 'lucide-react';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
@@ -15,7 +15,7 @@ import DashboardOffers from '../../components/dashboard/DashboardOffers';
|
||||
import PricingSection from '../../components/PricingSection';
|
||||
import { useUser } from '../../components/UserProvider';
|
||||
|
||||
const DashboardPage = () => {
|
||||
const DashboardContent = () => {
|
||||
const { user, logout } = useUser();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
@@ -319,4 +319,16 @@ const DashboardPage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const DashboardPage = () => {
|
||||
return (
|
||||
<Suspense fallback={
|
||||
<div className="min-h-screen flex items-center justify-center bg-gray-50">
|
||||
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-brand-600"></div>
|
||||
</div>
|
||||
}>
|
||||
<DashboardContent />
|
||||
</Suspense>
|
||||
);
|
||||
};
|
||||
|
||||
export default DashboardPage;
|
||||
|
||||
Reference in New Issue
Block a user