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 (
setQ(e.target.value)} placeholder="Search name or UEI" className={`${inputCls} ml-auto max-w-xs`} />
{list.isError ? (

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.'}

) : ( )}
setOpen(false)} title="New client">

You will hold this account. Anyone can see that you hold it, and an admin can reassign it.

{create.isError && (

{(create.error as Error).message}

)}
) }