import { useState } from 'react' import { Building2, Plus, UserCheck, UserPlus } from 'lucide-react' import { Link } from 'react-router-dom' import { ToolHeader } from '../../components/ToolHeader' import { Modal, Panel } from '../../components/ui' import { useAuth } from '../../lib/useAuth' import { recruitBrand } from './brand' import { useClaimClient, useClients, useCreateClient } from './clientQueries' const chip = (on: boolean) => `rounded-full px-3 py-1 text-xs font-semibold transition ${ on ? 'bg-recruit/25 text-recruit shadow-[inset_0_0_0_1px_var(--color-recruit)]' : 'bg-navy-900 text-faint hover:text-muted border border-line/60' }` const inputCls = 'w-full rounded-lg border border-line/70 bg-navy-900 px-3 py-2 text-sm text-ink outline-none focus:border-recruit' export function Clients() { const { principal } = useAuth() const [owner, setOwner] = useState('') const [q, setQ] = useState('') const [open, setOpen] = useState(false) const list = useClients({ owner, q }) const create = useCreateClient() const claim = useClaimClient() const [name, setName] = useState('') const [industry, setIndustry] = useState('') const submit = () => { create.mutate( { name, industry }, { onSuccess: () => { setName('') setIndustry('') setOpen(false) }, }, ) } const rows = list.data?.clients ?? [] return (
Could not load clients. {(list.error as Error)?.message}
) : list.isLoading ? (Loading clients…
) : rows.length === 0 ? ({owner === 'me' ? 'You do not hold any client accounts yet. Claim one from Unassigned or create a new client.' : owner === 'unassigned' ? 'Every client is assigned. Nothing is sitting unclaimed.' : 'No clients yet. Create the first one to start placing job orders against it.'}
) : ({c.industry || 'No industry set'} · {c.contact_count} contact {c.contact_count === 1 ? '' : 's'} · {c.status}
{(create.error as Error).message}
)}