feat: add admin dashboard and core API routes with Docker configuration
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import prisma from '@/lib/prisma';
|
||||
import { getAuthUser } from '@/lib/auth-utils';
|
||||
|
||||
// GET /api/favorites - Get user's favorites
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id');
|
||||
if (!userId) {
|
||||
const authUser = await getAuthUser(request);
|
||||
if (!authUser) {
|
||||
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 });
|
||||
}
|
||||
|
||||
const favorites = await prisma.favorite.findMany({
|
||||
where: { userId },
|
||||
where: { userId: authUser.id },
|
||||
include: {
|
||||
business: {
|
||||
include: {
|
||||
@@ -32,17 +33,19 @@ export async function GET(request: NextRequest) {
|
||||
// POST /api/favorites - Toggle favorite
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const userId = request.headers.get('x-user-id');
|
||||
const authUser = await getAuthUser(request);
|
||||
const body = await request.json();
|
||||
const { businessId } = body;
|
||||
|
||||
if (!userId) {
|
||||
if (!authUser) {
|
||||
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 });
|
||||
}
|
||||
if (!businessId) {
|
||||
return NextResponse.json({ error: 'businessId requis' }, { status: 400 });
|
||||
}
|
||||
|
||||
const userId = authUser.id;
|
||||
|
||||
// Resolve business ID (in case slug was passed)
|
||||
const business = await prisma.business.findFirst({
|
||||
where: {
|
||||
|
||||
Reference in New Issue
Block a user