chris 781f990541 Add store kill switch to admin panel and estore
Admin panel shows a prominent open/closed toggle above the tabs. When
closed, the shop displays a branded closure message and the checkout API
returns 503. The closure state persists in data/store-status.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 00:52:31 -04:00

24 lines
772 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { getStoreStatus, setStoreStatus } from '@/lib/store-status'
import { cookies } from 'next/headers'
function isAuthed() {
return cookies().get('bpb_admin')?.value === 'true'
}
export async function GET() {
if (!isAuthed()) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
return NextResponse.json(await getStoreStatus())
}
export async function PUT(req: NextRequest) {
if (!isAuthed()) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
const body = await req.json()
const status = {
closed: Boolean(body.closed),
message: String(body.message ?? '').trim(),
}
await setStoreStatus(status)
return NextResponse.json({ ok: true, ...status })
}