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>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { createServiceClient } from "@/lib/supabase"
|
|
import PedidoStatus from "@/components/pedido-status"
|
|
import { notFound } from "next/navigation"
|
|
import type { Metadata } from "next"
|
|
|
|
type Props = { params: Promise<{ id: string }> }
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Seu Pedido",
|
|
}
|
|
|
|
export default async function PedidoPage({ params }: Props) {
|
|
const { id } = await params
|
|
const supabase = createServiceClient()
|
|
|
|
const { data: pedido, error } = await supabase
|
|
.from("pedidos")
|
|
.select(
|
|
"id, status, valor_centavos, metodo_pagamento, pix_copia_cola, pix_qrcode_url, asaas_invoice_url, paid_at, clientes(nome, email), produtos(nome, validade, midia)"
|
|
)
|
|
.eq("id", id)
|
|
.single()
|
|
|
|
if (error || !pedido) notFound()
|
|
|
|
return (
|
|
<div className="container py-16 px-4">
|
|
<div className="max-w-2xl mx-auto mb-8 text-center">
|
|
<h1 className="text-3xl font-bold mb-2">Seu Pedido</h1>
|
|
<p className="text-muted-foreground">
|
|
Acompanhe o status do seu pedido
|
|
</p>
|
|
</div>
|
|
<PedidoStatus pedidoInicial={pedido} />
|
|
</div>
|
|
)
|
|
}
|