Files
Felipe Carvalho 038ce3f556 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>
2026-04-16 06:40:41 +02:00

29 lines
877 B
TypeScript

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 })
}