Files
property-management-network/components/forms/delete-property-button.tsx
Leon SerfatyandClaude Opus 4.8 857b9a7811 Initial import: property management SaaS + security hardening + admin dashboard
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>
2026-06-23 20:36:07 -04:00

49 lines
1.5 KiB
TypeScript

"use client"
import { useState } from "react"
import { useRouter } from "next/navigation"
import { Trash2 } from "lucide-react"
export function DeletePropertyButton({ propertyId }: { propertyId: string }) {
const router = useRouter()
const [confirming, setConfirming] = useState(false)
const [loading, setLoading] = useState(false)
async function handleDelete() {
setLoading(true)
await fetch(`/api/properties/${propertyId}`, { method: "DELETE" })
router.push("/properties")
router.refresh()
}
if (confirming) {
return (
<div className="flex items-center gap-2">
<span className="text-xs text-white/50">Are you sure?</span>
<button
onClick={handleDelete}
disabled={loading}
className="rounded-lg bg-red-600 px-3 py-2 text-xs font-medium text-white hover:bg-red-500 disabled:opacity-50 transition"
>
{loading ? "Deleting..." : "Yes, delete"}
</button>
<button
onClick={() => setConfirming(false)}
className="rounded-lg border border-white/10 px-3 py-2 text-xs text-white/60 hover:text-white transition"
>
Cancel
</button>
</div>
)
}
return (
<button
onClick={() => setConfirming(true)}
className="flex items-center gap-1.5 rounded-lg border border-red-500/20 px-3 py-2 text-sm text-red-400 hover:border-red-500/40 hover:bg-red-500/5 transition"
>
<Trash2 className="h-3.5 w-3.5" /> Delete
</button>
)
}