feat: implement dynamic categories, admin category CRUD, fix routing and cleanup
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { mockDb } from '@/lib/mockDb'
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
const body = await req.json()
|
||||
const { listingId, actionType } = body
|
||||
|
||||
if (!listingId || !actionType) {
|
||||
return NextResponse.json({ error: 'listingId and actionType are required' }, { status: 400 })
|
||||
}
|
||||
|
||||
const validActions = ['views', 'whatsapp', 'phone', 'menu']
|
||||
if (!validActions.includes(actionType)) {
|
||||
return NextResponse.json({ error: 'Invalid actionType' }, { status: 400 })
|
||||
}
|
||||
|
||||
// Call stateful DB increment
|
||||
const record = await mockDb.incrementAnalytics(listingId, actionType)
|
||||
|
||||
return NextResponse.json({ success: true, record })
|
||||
} catch (err: any) {
|
||||
console.error('Error logging event analytics:', err)
|
||||
return NextResponse.json({ error: err.message || 'Internal Server Error' }, { status: 500 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user