"use client" import { useEffect, useState } from "react" import { Building2, Mail, Phone, Globe, FileText, Hash, Users, DollarSign, CalendarDays } from "lucide-react" interface Profile { id: string customer_type: string source: string customer_notes: string status_name: string status_color: string company_name: string registration_number: string tax_id: string website: string industry: string company_size: string annual_revenue: string first_name: string last_name: string job_title: string } interface Contact { type: string value: string label: string is_primary: boolean } export default function ClientProfile() { const [profile, setProfile] = useState(null) const [contacts, setContacts] = useState([]) useEffect(() => { fetch("/client-portal/api/profile", { credentials: "include" }) .then((r) => r.json()) .then((d) => { setProfile(d.profile || null) setContacts(d.contacts || []) }) .catch(() => {}) }, []) if (!profile) { return (
) } const isCompany = profile.customer_type === "company" const name = isCompany ? profile.company_name : `${profile.first_name || ""} ${profile.last_name || ""}`.trim() return (

Profile

Your account and company information

{/* Main info card */}

{name || "Unnamed"}

{profile.status_name} {isCompany ? "Company" : "Individual"}
{isCompany && profile.industry && (

Industry

{profile.industry}

)} {isCompany && profile.registration_number && (

Registration

{profile.registration_number}

)} {profile.tax_id && (

Tax / VAT

{profile.tax_id}

)} {isCompany && profile.company_size && (

Company Size

{profile.company_size}

)} {isCompany && profile.annual_revenue && (

Annual Revenue

{Number(profile.annual_revenue).toLocaleString()}

)} {profile.website && (

Website

{profile.website}

)} {!isCompany && profile.job_title && (

Job Title

{profile.job_title}

)}
{profile.customer_notes && (

Notes

{profile.customer_notes}

)}
{/* Contacts sidebar */}
{(contacts || []).map((c, i) => (
{c.type === "email" ? : c.type === "phone" || c.type === "mobile" ? : c.type === "website" ? : }

{c.label || c.type}

{c.value}

{c.is_primary && ( Primary )}
))} {contacts.length === 0 && (
No contact info
)}
) }