"use client"; import { useState, Suspense } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { authClient } from "~/lib/auth-client"; import { Card, CardContent } from "~/components/ui/card"; import { Input } from "~/components/ui/input"; import { Button } from "~/components/ui/button"; import { Label } from "~/components/ui/label"; import { toast } from "sonner"; import { Logo } from "~/components/branding/logo"; import { LegalModal } from "~/components/ui/legal-modal"; import { env } from "~/env"; import { Mail, Lock, ArrowRight, Users, FileText, TrendingUp, Shield, } from "lucide-react"; interface SignInFormProps { allowRegistration: boolean; } export function SignInForm({ allowRegistration }: SignInFormProps) { const authentikEnabled = env.NEXT_PUBLIC_AUTHENTIK_ENABLED === true; const router = useRouter(); const searchParams = useSearchParams(); const callbackUrl = searchParams.get("callbackUrl") ?? "/dashboard"; const signupDisabled = searchParams.get("signup") === "disabled"; const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); async function handleSignIn(e: React.FormEvent) { e.preventDefault(); setLoading(true); const { error } = await authClient.signIn.email({ email, password, }); setLoading(false); if (error) { toast.error(error.message ?? "Invalid email or password"); } else { toast.success("Signed in successfully!"); router.push(callbackUrl); router.refresh(); } } async function handleSocialSignIn() { setLoading(true); try { await authClient.signIn.oauth2({ providerId: "authentik", callbackURL: callbackUrl, }); // The signIn.sso method will automatically redirect to the SSO provider } catch (error) { console.error("[SSO Error]", error); setLoading(false); } } return (
{/* Blob Background */}
{/* Hero Section - Hidden on mobile */}

Welcome back to your {" "} invoicing workspace

Continue managing your clients and creating professional invoices that get you paid faster.

Client Management

Organize and track all your clients in one place

Professional Invoices

Beautiful templates that get you paid faster

Payment Tracking

Monitor your income with real-time insights

{/* Sign In Form */}
{/* Mobile Logo */}

Sign In

Enter your credentials to access your account

{signupDisabled && (
New account registration is currently disabled.
)} {authentikEnabled && (
Or continue with
)}
setEmail(e.target.value)} required autoFocus className="bg-background/50 border-border/60 focus:bg-background h-11 pl-10 transition-all" placeholder="m@example.com" />
setPassword(e.target.value)} required className="bg-background/50 border-border/60 focus:bg-background h-11 pl-10 transition-all" placeholder="Enter your password" />
{allowRegistration && (
Don't have an account?{" "} Sign up
)}
By signing in, you agree to our{" "} Terms of Service } />{" "} and{" "} Privacy Policy } /> .
); } export default function SignInPageClient() { return ( Loading...}> ); }