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:
81
lib/supabase.ts
Normal file
81
lib/supabase.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { createClient } from "@supabase/supabase-js"
|
||||
|
||||
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!
|
||||
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
||||
|
||||
// Client-side (browser)
|
||||
export const supabase = createClient(supabaseUrl, supabaseAnonKey)
|
||||
|
||||
// Server-side com service role (para Server Actions e API routes)
|
||||
export function createServiceClient() {
|
||||
return createClient(supabaseUrl, process.env.SUPABASE_SERVICE_ROLE_KEY!, {
|
||||
auth: { autoRefreshToken: false, persistSession: false },
|
||||
})
|
||||
}
|
||||
|
||||
// Tipos do banco
|
||||
export type Produto = {
|
||||
id: string
|
||||
nome: string
|
||||
descricao: string | null
|
||||
tipo: "PF" | "PJ" | "SSL" | "NFe"
|
||||
validade: string
|
||||
midia: "Token" | "Cartão" | "Nuvem" | "Sem mídia" | null
|
||||
preco_centavos: number
|
||||
ativo: boolean
|
||||
imagem_url: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type Cliente = {
|
||||
id: string
|
||||
nome: string
|
||||
email: string
|
||||
telefone: string | null
|
||||
cpf_cnpj: string | null
|
||||
asaas_id: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type Pedido = {
|
||||
id: string
|
||||
cliente_id: string | null
|
||||
produto_id: string | null
|
||||
valor_centavos: number
|
||||
metodo_pagamento: "PIX" | "BOLETO" | "CREDIT_CARD" | null
|
||||
status: "PENDING" | "RECEIVED" | "CONFIRMED" | "OVERDUE" | "REFUNDED" | "CANCELLED"
|
||||
asaas_payment_id: string | null
|
||||
asaas_invoice_url: string | null
|
||||
pix_copia_cola: string | null
|
||||
pix_qrcode_url: string | null
|
||||
due_date: string | null
|
||||
paid_at: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type Cupom = {
|
||||
id: string
|
||||
codigo: string
|
||||
descricao: string
|
||||
percentual: number
|
||||
validade: string
|
||||
ativo: boolean
|
||||
destaque: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export type Agendamento = {
|
||||
id: string
|
||||
cliente_id: string | null
|
||||
produto_id: string | null
|
||||
pedido_id: string | null
|
||||
data_hora: string
|
||||
status: "AGUARDANDO" | "CONFIRMADO" | "CANCELADO" | "CONCLUIDO"
|
||||
observacoes: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
Reference in New Issue
Block a user