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>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
|
||||
interface AnimatedNumberProps {
|
||||
value: number
|
||||
duration?: number
|
||||
format?: "number" | "currency" | "percent"
|
||||
className?: string
|
||||
}
|
||||
|
||||
function formatValue(n: number, format: string) {
|
||||
if (format === "currency") return "$" + n.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
||||
if (format === "percent") return n + "%"
|
||||
return n.toLocaleString()
|
||||
}
|
||||
|
||||
export function AnimatedNumber({
|
||||
value,
|
||||
duration = 900,
|
||||
format = "number",
|
||||
className,
|
||||
}: AnimatedNumberProps) {
|
||||
const [display, setDisplay] = useState(0)
|
||||
const startRef = useRef<number | null>(null)
|
||||
const frameRef = useRef<number>(0)
|
||||
const prevRef = useRef(0)
|
||||
|
||||
useEffect(() => {
|
||||
const from = prevRef.current
|
||||
const to = value
|
||||
prevRef.current = value
|
||||
|
||||
if (from === to) {
|
||||
setDisplay(to)
|
||||
return
|
||||
}
|
||||
|
||||
startRef.current = null
|
||||
|
||||
function tick(ts: number) {
|
||||
if (!startRef.current) startRef.current = ts
|
||||
const elapsed = ts - startRef.current
|
||||
const progress = Math.min(elapsed / duration, 1)
|
||||
const eased = 1 - Math.pow(1 - progress, 3)
|
||||
setDisplay(Math.round(from + (to - from) * eased))
|
||||
if (progress < 1) {
|
||||
frameRef.current = requestAnimationFrame(tick)
|
||||
}
|
||||
}
|
||||
|
||||
frameRef.current = requestAnimationFrame(tick)
|
||||
return () => cancelAnimationFrame(frameRef.current)
|
||||
}, [value, duration])
|
||||
|
||||
return <span className={className}>{formatValue(display, format)}</span>
|
||||
}
|
||||
Reference in New Issue
Block a user