Property Management Network — Next.js 16 (App Router), Better Auth, Drizzle ORM over PostgreSQL, Stripe, OpenAI, Resend. Includes: - Security hardening: access-control/IDOR fixes, TLS-by-default DB layer, constant-time cron auth, strict security headers, atomic AI quota gating, HTML/email output encoding, demo-backdoor disabled in production. - Superadmin dashboard at /admin (overview/MRR, server-paginated users with ban/impersonate/plan/delete, billing, platform activity + admin audit log, AI usage, system health) via the Better Auth admin plugin. - Seed/migration utility scripts under scripts/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
36 lines
1016 B
TypeScript
36 lines
1016 B
TypeScript
"use client"
|
|
|
|
import { useState } from "react"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
export function CheckoutButton({ plan, label, highlight }: { plan: string; label: string; highlight?: boolean }) {
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
async function handleClick() {
|
|
setLoading(true)
|
|
const res = await fetch("/api/stripe/checkout", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ plan }),
|
|
})
|
|
const data = await res.json()
|
|
if (data.url) window.location.href = data.url
|
|
else setLoading(false)
|
|
}
|
|
|
|
return (
|
|
<button
|
|
onClick={handleClick}
|
|
disabled={loading}
|
|
className={cn(
|
|
"w-full rounded-lg py-2 text-xs font-semibold transition disabled:opacity-50",
|
|
highlight
|
|
? "bg-indigo-600 text-white hover:bg-indigo-500"
|
|
: "border border-white/10 text-white/70 hover:border-white/20 hover:text-white"
|
|
)}
|
|
>
|
|
{loading ? "Loading..." : label}
|
|
</button>
|
|
)
|
|
}
|