'use client' import { ReactNode } from 'react' import { useRouter } from '../contexts/RouterContext' import { useStyles } from '../contexts/StylesContext' interface FooterLink { label: string href?: string onClick?: () => void } interface AuthCardProps { title: string subtitle?: string children?: ReactNode footerLinks?: FooterLink[] error?: string success?: string loading?: boolean loadingText?: string } export function AuthCard({ title, subtitle, children, footerLinks, error, success, loading, loadingText = 'Loading...', }: AuthCardProps) { const router = useRouter() const styles = useStyles() const handleLinkClick = (e: React.MouseEvent, href: string) => { e.preventDefault() router.push(href) } return (
{loading ? (

{loadingText}

) : ( <>

{title}

{subtitle &&

{subtitle}

} {error &&
{error}
} {success &&
{success}
} {children} {footerLinks && footerLinks.length > 0 && (
{footerLinks.map((link, i) => ( link.onClick ? ( ) : link.href ? ( handleLinkClick(e, link.href!)} className={styles.link} > {link.label} ) : null ))}
)} )}
) }