feat: initial commit — asaas-checkout template white-label
Template genérico de checkout com ASAAS, parametrizado via env vars. Inclui fluxo completo: checkout → pedido → polling → webhook → admin. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
28
app/api/agendamento/[id]/status/route.ts
Normal file
28
app/api/agendamento/[id]/status/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { createServiceClient } from "@/lib/supabase"
|
||||
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const { id } = await params
|
||||
const body = await request.json().catch(() => ({}))
|
||||
const { status } = body as { status?: string }
|
||||
|
||||
const STATUSES_VALIDOS = ["pendente", "confirmado", "realizado", "cancelado"]
|
||||
if (!status || !STATUSES_VALIDOS.includes(status)) {
|
||||
return NextResponse.json({ error: "Status inválido" }, { status: 400 })
|
||||
}
|
||||
|
||||
const supabase = createServiceClient()
|
||||
const { error } = await supabase
|
||||
.from("agendamentos")
|
||||
.update({ status, updated_at: new Date().toISOString() })
|
||||
.eq("id", id)
|
||||
|
||||
if (error) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 })
|
||||
}
|
||||
|
||||
return NextResponse.json({ ok: true, status })
|
||||
}
|
||||
Reference in New Issue
Block a user