Initial food blog app

This commit is contained in:
Andy
2026-03-21 11:57:08 +00:00
commit b83762bfc3
33 changed files with 8621 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { NextResponse } from 'next/server'
import { readRestaurants, writeRestaurants } from '@/app/lib/restaurants'
export async function DELETE(
_request: Request,
{ params }: { params: Promise<{ id: string; visitId: string }> }
) {
const { id, visitId } = await params
const restaurants = readRestaurants()
const index = restaurants.findIndex((r) => r.id === id)
if (index === -1) {
return NextResponse.json({ error: 'Restaurant not found' }, { status: 404 })
}
const visitIndex = restaurants[index].visits.findIndex((v) => v.id === visitId)
if (visitIndex === -1) {
return NextResponse.json({ error: 'Visit not found' }, { status: 404 })
}
restaurants[index].visits.splice(visitIndex, 1)
writeRestaurants(restaurants)
return NextResponse.json({ success: true })
}