Files
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

65 lines
1.6 KiB
TypeScript

import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function formatCurrency(amount: number, currency = "USD"): string {
return new Intl.NumberFormat("en-US", {
style: "currency",
currency,
minimumFractionDigits: 0,
maximumFractionDigits: 2,
}).format(amount)
}
export function formatDate(date: string | Date): string {
return new Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "short",
day: "numeric",
}).format(new Date(date))
}
export function formatDateShort(date: string | Date): string {
return new Intl.DateTimeFormat("en-US", {
month: "short",
day: "numeric",
}).format(new Date(date))
}
export function daysUntil(date: string | Date): number {
const target = new Date(date)
const today = new Date()
today.setHours(0, 0, 0, 0)
const diff = target.getTime() - today.getTime()
return Math.ceil(diff / (1000 * 60 * 60 * 24))
}
export function daysAgo(date: string | Date): number {
return -daysUntil(date)
}
export function slugify(str: string): string {
return str.toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]/g, "")
}
export function initials(name: string): string {
return name
.split(" ")
.map((n) => n[0])
.join("")
.toUpperCase()
.slice(0, 2)
}
export function truncate(str: string, length = 50): string {
return str.length > length ? str.slice(0, length) + "…" : str
}
export function getOccupancyRate(occupied: number, total: number): number {
if (total === 0) return 0
return Math.round((occupied / total) * 100)
}