1import{c as ds,z as cs,b as os,w as ms,r as l,d as h,u as x,j as e,e as _e,B as i,I as d,a as o,q as m}from"./index-BxMItG-b.js";import{C as p}from"./card-CIsiNZB2.js";import{B as T}from"./badge-BPn2RsR7.js";import{L as r}from"./label-w-YTA7Tz.js";import{D as j,a as _,b as g,c as f,d as y,e as Ee}from"./dialog-Bzcskrf6.js";import{T as Pe}from"./textarea-Dglm9MU5.js";import{S as J,a as Y,b as H,c as X,d as N,e as xs}from"./types-CJj4gdGq.js";import{b as us,a as hs}from"./avatar-BODpFGG3.js";import{u as ps,F as js,O as gs}from"./outlook-reconnect-dialog-6CRhX0am.js";import{N as fs}from"./notes-panel-6Q43I2c8.js";import{c as Re,b as ys}from"./schema-CxQh40BN.js";import{A as bs}from"./arrow-left-BYPfSP6g.js";import{M as Z}from"./mail-Dhwr6f9G.js";import{P as ee}from"./phone-BMD69uN-.js";import{G as Fe}from"./globe-DlSJ9oxj.js";import{M as $e}from"./map-pin-sZA-DYBz.js";import{P as Ns}from"./pencil-W2vVMGfx.js";import{P as se}from"./pen-line-IeO_PS2o.js";import{T as v}from"./trash-2-3Yno5TQb.js";import{B as vs}from"./building-2-Du9EaF7Q.js";import{U as ws}
1from"./users-UKM44JJg.js";import{U as ks}from"./user-plus-CLPYpRF0.js";import{F as te}from"./file-text-ByofHTwl.js";import{U as Cs}from"./upload-BdDfCeQ0.js";import{S as E}from"./send-DfaOoPGc.js";import{P as De}from"./plus-BcqXFvcm.js";import{S as Ss}from"./shield-CcYJTeLv.js";import{C as Oe}from"./circle-check-D9xMYh3n.js";import{C as Ts}from"./circle-x-BuCV9ibu.js";import{C as _s}from"./clock-EgAxfusY.js";import{L as ae}from"./loader-circle-CRirUgms.js";import{C as Es}from"./copy-CNp1gwtr.js";import"./index-D0DoevW8.js";import"./chevron-down-Dzx9VsRB.js";import"./format-BBErTw00.js";const Ps=ds("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]),Rs={active:"default",prospect:"secondary",contact_to_be_made:"outline",not_worth_time:"destructive"};function ut(){const{id:n}=cs(),[,ne]=os(),{toast:c}=ms(),[Ae,P]=l.useState(!1),[qe,R]=l.useState(!1),[Be,F]=l.useState(!1),[Me,$]=l.useState(!1),[ie,re]=l.useState(""),[Ie,w]=l.useState(!1),[b,Le]=l.useState(null),[k,le]=l.useState(""),[de,ce]=l.useState(""),[D,oe]=l.useState(""),[me,xe]=l.useState(""),[ue,he]=l.useState(!1),[O,pe]=l.useState(!1),[Ke,C]=l.useState(!1),[je,We]=l.useState("terms_of_business"),[A,ge]=l.useState(""),[q,fe]=l.useState(""),[B,ye]=l.useState(""),[u,ze]=l.useState("none"),[be,Ue]=l.useState(""),[Ne,Ve]=l.useState(""),[ve,we]=l.useState(!1),[ke,Ce]=l.useState(null),[Qe,M]=l.useState(!1),{data:t,isLoading:Ge}=h({queryKey:["/api/clients",n]}),{data:I}=h({queryKey:["/api/clients",n,"contacts"],queryFn:async()=>{const s=await fetch(`/api/clients/${n}/contacts`);if(!s.ok)throw new Error("Failed");return s.json()}}),{data:L,refetch:Je}=h({queryKey:["/api/esign","client",n],queryFn:async()=>{const s=await fetch(`/api/esign?clientId=${n}`);if(!s.ok)throw new Error("Failed");return s.json()},enabled:!!n,staleTime:0,refetchOnWindowFocus:!0}),{data:Se=[]}=h({queryKey:["/api/esign/templates"]}),{data:K}=h({queryKey:["/api/clients",n,"tob-documents"],queryFn:async()=>{const s=await fetch(`/api/clients/${n}/tob-documents`);if(!s.ok)throw new Error("Failed");return s.json()}}),{data:W}=h({queryKey:["/api/clients",n,"rates"],queryFn:async()=>{const s=await fetch(`/api/clients/${n}/rates`);if(!s.ok)throw new Error("Failed");return s.json()}}),{data:z}=h({queryKey:["/api/clients",n,"rebate-tiers"],queryFn:async()=>{const s=await fetch(`/api/clients/${n}/rebate-tiers`);if(!s.ok)throw new Error("Failed");return s.json()}}),U=x({mutationFn:async s=>{await o("PATCH",`/api/clients/${n}`,s)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n]}),m.invalidateQueries({queryKey:["/api/clients"]}),P(!1),c({title:"Client updated"})}}),Ye=x({mutationFn:async()=>{await o("DELETE",`/api/clients/${n}`)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients"]}),m.invalidateQueries({queryKey:["/api/dashboard/stats"]}),ne("/clients"),c({title:"Client deleted"})}}),V=x({mutationFn:async s=>{await o("POST",`/api/clients/${n}/contacts`,s)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"contacts"]}),R(!1),c({title:"Contact added"})}}),He=x({mutationFn:async s=>{await o("DELETE",`/api/contacts/${s}`)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"contacts"]}),c({title:"Contact removed"})}}),{uploadFile:Xe,isUploading:Te}=ps({onSuccess:s=>{Ze.mutate({filePath:s.objectPath,fileName:s.metadata.name}),c({title:"Document uploaded successfully"})},onError:()=>{c({title:"Failed to upload document",variant:"destructive"})}}),Ze=x({mutationFn:async s=>{await o("POST",`/api/clients/${n}/tob-documents`,s)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"tob-documents"]})}}),es=x({mutationFn:async s=>{await o("DELETE",`/api/tob-documents/${s}`)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"tob-documents"]}),c({title:"Document removed"})}}),Q=x({mutationFn:async s=>{await o("POST",`/api/clients/${n}/rates`,s)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"rates"]}),F(!1),c({title:"Rate added"})}}),ss=x({mutationFn:async s=>{await o("DELETE",`/api/rates/${s}`)},onSuccess:()=>
1{m.invalidateQueries({queryKey:["/api/clients",n,"rates"]}),c({title:"Rate removed"})}}),G=x({mutationFn:async s=>{await o("POST",`/api/clients/${n}/rebate-tiers`,s)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"rebate-tiers"]}),$(!1),c({title:"Rebate tier added"})}}),ts=x({mutationFn:async s=>{await o("DELETE",`/api/rebate-tiers/${s}`)},onSuccess:()=>{m.invalidateQueries({queryKey:["/api/clients",n,"rebate-tiers"]}),c({title:"Rebate tier removed"})}}),as=s=>{s.preventDefault();const a=new FormData(s.currentTarget);U.mutate({companyName:a.get("companyName"),phone:a.get("phone")||null,email:a.get("email")||null,address:a.get("address")||null,website:a.get("website")||null,industry:a.get("industry")||null,category:ie||t?.category||"prospect"})},ns=s=>{s.preventDefault();const a=new FormData(s.currentTarget);V.mutate({name:a.get("name"),role:a.get("role")||null,email:a.get("email")||null,phone:a.get("phone")||null})},is=s=>{const a=s.target.files?.[0];a&&Xe(a)},rs=s=>{s.preventDefault();const a=new FormData(s.currentTarget);Q.mutate({salaryMin:Number(a.get("salaryMin")),salaryMax:a.get("salaryMax")?Number(a.get("salaryMax")):null,ratePercent:Number(a.get("ratePercent")),description:a.get("description")||null})},ls=s=>{s.preventDefault();const a=new FormData(s.currentTarget);G.mutate({fromWeek:Number(a.get("fromWeek")),toWeek:Number(a.get("toWeek")),rebatePercent:Number(a.get("rebatePercent"))})};return Ge?e.jsxs("div",{className:"p-6 space-y-4 max-w-5xl mx-auto",children:[e.jsx(_e,{className:"h-8 w-48"}),e.jsx(_e,{className:"h-64 w-full"})]}):t?e.jsxs("div",{className:"p-6 space-y-4 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-start gap-3 pb-4 border-b",children:[e.jsx(i,{size:"icon",variant:"ghost",onClick:()=>ne("/clients"),"data-testid":"button-back",className:"mt-1 shrink-0",children:e.jsx(bs,{className:"h-4 w-4"})}),e.jsx("div",{className:`h-16 w-16 rounded-lg flex items-center justify-center text-white text-xl font-bold shrink-0 ${hs(t.companyName)}`,children:us(t.companyName)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-2xl font-semibold","data-testid":"text-client-name",children:t.companyName}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 flex-wrap",children:[t.industry&&e.jsx(T,{variant:"secondary",children:t.industry}),e.jsx(T,{variant:Rs[t.category]??"secondary","data-testid":"badge-client-category",children:Re[t.category]})]}),(t.email||t.phone||t.website||t.address)&&e.jsxs("div",{className:"flex items-center gap-4 flex-wrap mt-2",children:[t.email&&e.jsxs("a",{href:`mailto:${t.email}`,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(Z,{className:"h-3 w-3 shrink-0"}),t.email]}),t.phone&&e.jsxs("a",{href:`tel:${t.phone}`,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(ee,{className:"h-3 w-3 shrink-0"}),t.phone]}),t.website&&e.jsxs("a",{href:t.website,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary hover:underline",children:[e.jsx(Fe,{className:"h-3 w-3 shrink-0"}),t.website.replace(/^https?:\/\//,"")]}),t.address&&e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx($e,{className:"h-3 w-3 shrink-0"}),t.address]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(j,{open:Ae,onOpenChange:s=>{P(s),s&&re(t.category)},children:[e.jsx(_,{asChild:!0,children:e.jsxs(i,{variant:"secondary",size:"sm","data-testid":"button-edit-client",children:[e.jsx(Ns,{className:"h-3 w-3 mr-1"})," Edit"]})}),e.jsxs(g,{className:"max-w-lg",children:[e.jsx(f,{children:e.jsx(y,{children:"Edit Client"})}),e.jsxs("form",{onSubmit:as,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Company Name *"}),e.jsx(d,{name:"companyName",defaultValue:t.companyName,required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Phone"}),e.jsx(d,{name:"phone",defaultValue:t.phone??""})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Email"}),e.jsx(d,{name:"email",type:"email",defaultValue:t.email??""})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Address"}),e.jsx(d,{name:"address",defaultValue:t.address??""})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Website"}),e.jsx(d,{name:"website",defaultValue:t.website??""})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Industry"}),e.jsx(d,{name:"industry",defaultValue:t.industry??""})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Category"}),e.jsxs(J,{value:ie,onValueChange:re,children:[e.jsx(Y,{"data-testid":"select-edit-category",children:e.jsx(H,{})}),e.jsx(X,{children:ys.map(s=>e.jsx(N,{value:s,children:Re[s]},s))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{type:"button",variant:"secondary",onClick:()=>P(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:U.isPending,children:U.isPending?"Saving...":"Save Changes"})]})]})]})]}),e.jsxs(i,{variant:"outline",size:"sm","data-testid":"button-request-signature",onClick:()=>{ge(""),fe(""),ye(`This Terms of Business Agreement ("Agreement") is entered into between the recruitment agency and ${t?.companyName||"the client company"} ("Client"). 2 31. SERVICES: The agency agrees to provide recruitment services to identify and introduce suitable candidates for the Client's vacancies. 4 52. FEES: The Client agrees to pay the agency's placement fees as outlined in the fee schedule agreed upon. 6 73. REBATE PERIOD: A rebate period of 12 weeks applies, subject to the terms specified separately. 8 94. EXCLUSIVITY: Unless otherwise agreed, introductions are non-exclusive. 10 11By signing below, both parties agree to be bound by this Agreement. 12 13Signed on behalf of Client: 14 15Name: _______________________ 16Title: _______________________ 17Date: _______________________`),C(!0)},children:[e.jsx(se,{className:"h-3 w-3 mr-1"})," Request Signature"]}),e.jsxs(i,{variant:"destructive",size:"sm",onClick:()=>Ye.mutate(),"data-testid":"button-delete-client",children:[e.jsx(v,{className:"h-3 w-3 mr-1"})," Delete"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-blue-50 dark:bg-blue-950/40 flex items-center justify-center shrink-0",children:e.jsx(vs,{className:"h-3.5 w-3.5 text-blue-600 dar
17k:text-blue-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Company Details"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.email&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("a",{href:`mailto:${t.email}`,className:"hover:text-primary transition-colors",children:t.email})]}),t.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("a",{href:`tel:${t.phone}`,className:"hover:text-primary transition-colors",children:t.phone})]}),t.website&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("a",{href:t.website,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline truncate",children:t.website})]}),t.address&&e.jsxs("div",{className:"flex items-center gap-2 col-span-2",children:[e.jsx($e,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{children:t.address})]})]})]}),e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-violet-50 dark:bg-violet-950/40 flex items-center justify-center shrink-0",children:e.jsx(ws,{className:"h-3.5 w-3.5 text-violet-600 dark:text-violet-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Contacts"})]}),e.jsxs(j,{open:qe,onOpenChange:R,children:[e.jsx(_,{asChild:!0,children:e.jsxs(i,{size:"sm",variant:"secondary","data-testid":"button-add-contact",children:[e.jsx(ks,{className:"h-3 w-3 mr-1"})," Add Contact"]})}),e.jsxs(g,{children:[e.jsx(f,{children:e.jsx(y,{children:"Add Contact"})}),e.jsxs("form",{onSubmit:ns,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Name *"}),e.jsx(d,{name:"name",required:!0,"data-testid":"input-contact-name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Role"}),e.jsx(d,{name:"role","data-testid":"input-contact-role"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Email"}),e.jsx(d,{name:"email",type:"email","data-testid":"input-contact-email"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Phone"}),e.jsx(d,{name:"phone","data-testid":"input-contact-phone"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{type:"button",variant:"secondary",onClick:()=>R(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:V.isPending,"data-testid":"button-submit-contact",children:V.isPending?"Adding...":"Add Contact"})]})]})]})]})]}),I&&I.length>0?e.jsx("div",{className:"space-y-2",children:I.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-md bg-muted/50","data-testid":`contact-${s.id}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:s.name}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5 flex-wrap",children:[s.role&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.role}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"text-xs text-muted-foreground flex items-center gap-1 hover:text-foreground transition-colors",children:[e.jsx(Z,{className:"h-3 w-3"})," ",s.email]}),s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"text-xs text-muted-foreground flex items-center gap-1 hover:text-foreground transition-colors",children:[e.jsx(ee,{className:"h-3 w-3"})," ",s.phone]})]})]}),e.jsx(i,{size:"icon",variant:"ghost",onClick:()=>He.mutate(s.id),"data-testid":`button-delete-contact-${s.id}`,children:e.jsx(v,{className:"h-3 w-3"})})]},s.id))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No contacts added yet"})]}),e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-amber-50 dark:bg-amber-950/40 flex items-center justify-center shrink-0",children:e.jsx(te,{className:"h-3.5 w-3.5 text-amber-600 dar
17k:text-amber-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Terms of Business"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"file",id:"tob-upload",className:"hidden",accept:".pdf,.doc,.docx,.txt",onChange:is,"data-testid":"input-tob-upload"}),e.jsxs(i,{size:"sm",variant:"secondary",onClick:()=>document.getElementById("tob-upload")?.click(),disabled:Te,"data-testid":"button-upload-tob",children:[e.jsx(Cs,{className:"h-3 w-3 mr-1"})," ",Te?"Uploading...":"Upload TOB"]})]})]}),K&&K.length>0?e.jsx("div",{className:"space-y-2",children:K.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 rounded-md bg-muted/50","data-testid":`tob-doc-${s.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(te,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("a",{href:`/objects/${s.filePath}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-primary hover:underline truncate block","data-testid":`link-tob-${s.id}`,children:s.fileName}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Uploaded ",new Date(s.uploadedAt).toLocaleDateString()]})]})]}),e.jsxs(i,{size:"sm",variant:"outline","data-testid":`button-send-tob-${s.id}`,onClick:()=>{Le(s),le(""),ce(""),oe(`Terms of Business â ${t?.companyName||""}`),xe(`Please find attached our Terms of Business for your review. 18 19Please don't hesitate to contact us with any questions. 20 21Kind regards, 22FillRate`),pe(!1),w(!0)},children:[e.jsx(E,{className:"h-3 w-3 mr-1"})," Send"]}),e.jsx(i,{size:"icon",variant:"ghost",onClick:()=>es.mutate(s.id),"data-testid":`button-delete-tob-${s.id}`,children:e.jsx(v,{className:"h-3 w-3"})})]},s.id))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No terms of business uploaded yet"})]}),e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-emerald-50 dark:bg-emerald-950/40 flex items-center justify-center shrink-0",children:e.jsx(Ps,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Rates Confirmed"})]}),e.jsxs(j,{open:Be,onOpenChange:F,children:[e.jsx(_,{asChild:!0,children:e.jsxs(i,{size:"sm",variant:"secondary","data-testid":"button-add-rate",children:[e.jsx(De,{className:"h-3 w-3 mr-1"})," Add Rate"]})}),e.jsxs(g,{children:[e.jsx(f,{children:e.jsx(y,{children:"Add Rate Band"})}),e.jsxs("form",{onSubmit:rs,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Salary From (£) *"}),e.jsx(d,{name:"salaryMin",type:"number",required:!0,placeholder:"e.g. 0","data-testid":"input-rate-salaryMin"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Salary To (£)"}),e.jsx(d,{name:"salaryMax",type:"number",placeholder:"Leave blank for no cap","data-testid":"input-rate-salaryMax"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Rate (%) *"}),e.jsx(d,{name:"ratePercent",type:"number",step:"0.5",required:!0,placeholder:"e.g. 20","data-testid":"input-rate-percent"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Description"}),e.jsx(d,{name:"description",placeholder:"e.g. Standard permanent rate","data-testid":"input-rate-description"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{type:"button",variant:"secondary",onClick:()=>F(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:Q.isPending,"data-testid":"button-submit-rate",children:Q.isPending?"Adding...":"Add Rate"})]})]})]})]})]}),W&&W.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left",children:[e.jsx("th",{className:"pb-2 font-medium text-muted-foreground",children:"Salary Band"}),e.jsx("th",{className:"pb-2 font-medium text-muted-foreground",children:"Rate"}),e.jsx("th",{className:"pb-2 font-medium text-muted-foreground",children:"Description"}),e.jsx("th",{className:"pb-2 w-10"})]})}),e.jsx("tbody",{children:W.map(s=>e.jsxs("tr",{className:"border-b last:border-0","data-testid":`rate-row-${s.id}`,children:[e.jsxs("td",{className:"py-2.5",children:["£",s.salary
22Min.toLocaleString(),s.salaryMax?` â £${s.salaryMax.toLocaleString()}`:"+"]}),e.jsx("td",{className:"py-2.5",children:e.jsxs(T,{variant:"secondary",children:[s.ratePercent,"%"]})}),e.jsx("td",{className:"py-2.5 text-muted-foreground",children:s.description||"â"}),e.jsx("td",{className:"py-2.5",children:e.jsx(i,{size:"icon",variant:"ghost",onClick:()=>ss.mutate(s.id),"data-testid":`button-delete-rate-${s.id}`,children:e.jsx(v,{className:"h-3 w-3"})})})]},s.id))})]})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No rates configured yet"})]}),e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-indigo-50 dark:bg-indigo-950/40 flex items-center justify-center shrink-0",children:e.jsx(Ss,{className:"h-3.5 w-3.5 text-indigo-600 dark:text-indigo-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Rebate Agreement"})]}),e.jsxs(j,{open:Me,onOpenChange:$,children:[e.jsx(_,{asChild:!0,children:e.jsxs(i,{size:"sm",variant:"secondary","data-testid":"button-add-rebate",children:[e.jsx(De,{className:"h-3 w-3 mr-1"})," Add Tier"]})}),e.jsxs(g,{children:[e.jsx(f,{children:e.jsx(y,{children:"Add Rebate Tier"})}),e.jsxs("form",{onSubmit:ls,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"From Week *"}),e.jsx(d,{name:"fromWeek",type:"number",min:"0",required:!0,placeholder:"e.g. 0","data-testid":"input-rebate-fromWeek"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"To Week *"}),e.jsx(d,{name:"toWeek",type:"number",min:"1",required:!0,placeholder:"e.g. 2","data-testid":"input-rebate-toWeek"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Rebate (%) *"}),e.jsx(d,{name:"rebatePercent",type:"number",min:"0",max:"100",required:!0,placeholder:"e.g. 100","data-testid":"input-rebate-percent"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If an accepted candidate leaves within this period, this percentage of the fee will be rebated to the client."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(i,{type:"button",variant:"secondary",onClick:()=>$(!1),children:"Cancel"}),e.jsx(i,{type:"submit",disabled:G.isPending,"data-testid":"button-submit-rebate",children:G.isPending?"Adding...":"Add Tier"})]})]})]})]})]}),z&&z.length>0?e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left",children:[e.jsx("th",{className:"pb-2 font-medium text-muted-foreground",children:"Period"}),e.jsx("th",{className:"pb-2 font-medium text-muted-foreground",children:"Rebate"}),e.jsx("th",{className:"pb-2 w-10"})]})}),e.jsx("tbody",{children:z.map(s=>e.jsxs("tr",{className:"border-b last:border-0","data-testid":`rebate-row-${s.id}`,children:[e.jsxs("td",{className:"py-2.5",children:["Week ",s.fromWeek," â ",s.toWeek,e.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",s.toWeek-s.fromWeek," ",s.toWeek-s.fromWeek===1?"week":"weeks",")"]})]}),e.jsx("td",{className:"py-2.5",children:e.jsxs(T,{variant:s.rebatePercent>=75?"destructive":s.rebatePercent>=50?"default":"secondary",children:[s.rebatePercent,"% rebate"]})}),e.jsx("td",{className:"py-2.5",children:e.jsx(i,{size:"icon",variant:"ghost",onClick:()=>ts.mutate(s.id),"data-testid":`button-delete-rebate-${s.id}`,children:e.jsx(v,{className:"h-3 w-3"})})})]},s.id))})]})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No rebate agreement configured yet"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(p,{className:"p-5 shadow-sm",children:e.jsx(fs,{clientId:n})}),L&&L.length>0&&e.jsxs(p,{className:"p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"h-7 w-7 rounded-lg bg-rose-50 dark:bg-rose-950/40 flex items-center justify-center shrink-0",children:e.jsx(se,{className:"h-3.5 w-3.5 text-rose-600 dar
22k:text-rose-400"})}),e.jsx("h3",{className:"font-medium text-sm",children:"Signature Requests"})]}),e.jsx("div",{className:"space-y-2",children:L.map(s=>e.jsxs("div",{"data-testid":`esign-request-${s.id}`,className:"flex items-center justify-between gap-2 p-2.5 rounded-lg border bg-muted/30 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.status==="signed"?e.jsx(Oe,{className:"h-3.5 w-3.5 text-green-500 shrink-0"}):s.status==="expired"?e.jsx(Ts,{className:"h-3.5 w-3.5 text-red-400 shrink-0"}):e.jsx(_s,{className:"h-3.5 w-3.5 text-amber-500 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:s.documentTitle}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:s.status})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{"data-testid":`button-resend-esign-${s.id}`,disabled:ke===s.id,className:"text-xs text-primary hover:underline flex items-center gap-1 disabled:opacity-50",onClick:async()=>{Ce(s.id);try{const S=await(await o("POST",`/api/esign/${s.id}/resend`,{})).json();S.emailSent?c({title:"Reminder sent",description:`A reminder email has been sent to ${s.recipientEmail}.`}):S.outlookAuthError?M(!0):S.error?c({title:"Could not resend",description:S.error,variant:"destructive"}):c({title:"Could not send email",description:"Use 'Copy link' to share manually.",variant:"destructive"})}catch{c({title:"Request failed",description:"Please try again.",variant:"destructive"})}finally{Ce(null)}},children:ke===s.id?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"h-3 w-3 animate-spin"})," Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-3 w-3"})," Resend"]})}),e.jsxs("button",{"data-testid":`button-copy-esign-link-${s.id}`,className:"text-xs text-primary hover:underline flex items-center gap-1",onClick:()=>{const a=`${window.location.origin}/sign/${s.token}`;navigator.clipboard.writeText(a).then(()=>c({title:"Signing link copied",description:"Paste it into an email to send manually."}))},children:[e.jsx(Es,{className:"h-3 w-3"})," Copy link"]})]}),s.status==="signed"&&e.jsx("a",{href:`/api/esign/${s.token}/download`,"data-testid":`link-download-esign-${s.id}`,className:"text-xs text-primary hover:underline shrink-0",children:"Download"})]})]},s.id))})]})]})]}),e.jsx(j,{open:Ie,onOpenChange:w,children:e.jsxs(g,{className:"max-w-lg",children:[e.jsx(f,{children:e.jsx(y,{children:"Send Terms of Business via Outlook"})}),O?e.jsxs("div",{className:"flex flex-col items-center py-8 gap-3",children:[e.jsx(Oe,{className:"h-12 w-12 text-green-500"}),e.jsx("p",{className:"font-medium",children:"Terms of Business sent successfully!"})]}):e.jsxs("div",{className:"space-y-4 py-2",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted/50 rounded-md",children:[e.jsx(te,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:b.fileName})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm font-medium",children:"Recipient Email *"}),e.jsx(d,{type:"email",value:k,onChange:s=>le(s.target.value),placeholder:"[email protected]","data-testid":"input-send-tob-email"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm font-medium",children:"Recipient Name"}),e.jsx(d,{type:"text",value:de,onChange:s=>ce(s.target.value),placeholder:"Jane Smith","data-testid":"input-send-tob-name"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm font-medium",children:"Subject"}),e.jsx(d,{type:"text",value:D,onChange:s=>oe(s.target.value),"data-testid":"input-send-tob-subject"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-sm font-medium",children:"Message"}),e.jsx(Pe,{value:me,onChange:s=>xe(s.target.value),rows:4,className:"text-sm","data-testid":"input-send-tob-body"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The Terms of Business document will be attached to this email."})]}),e.jsxs(Ee,{className:"gap-2",children:[e.jsx(i,{variant:"outline",onClick:()=>w(!1),"data-testid":"button-send-tob-cancel",children:"Cancel"}),!O&&e.jsx(i,{disabled:ue||!k.trim()||!D.trim(),"data-testid":"button-send-tob-confirm",onClick:async()=>
22{if(b){he(!0);try{await o("POST","/api/outlook/mail/send",{toEmail:k,toName:de||void 0,subject:D,body:me,attachmentPath:b.filePath,attachmentName:b.fileName,linkedClientId:t?.id}),pe(!0),c({title:"Email sent!",description:`Terms of Business sent to ${k} via Outlook.`}),setTimeout(()=>w(!1),1500)}catch{c({title:"Failed to send email",description:"Could not send via Outlook. Check your Outlook connection in Settings.",variant:"destructive"})}finally{he(!1)}}},children:ue?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"h-4 w-4 mr-2 animate-spin"})," Sending..."]}):O?e.jsxs(e.Fragment,{children:[e.jsx(xs,{className:"h-4 w-4 mr-2"})," Sent!"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 mr-2"})," Send via Outlook"]})})]})]})}),e.jsx(j,{open:Ke,onOpenChange:C,children:e.jsxs(g,{className:"max-w-lg",children:[e.jsx(f,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-4 w-4"})," Request Signature"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Document Type"}),e.jsxs(J,{value:je,onValueChange:We,children:[e.jsx(Y,{"data-testid":"select-esign-doc-type",children:e.jsx(H,{})}),e.jsxs(X,{children:[e.jsx(N,{value:"cv_consent",children:"CV Consent Form"}),e.jsx(N,{value:"terms_of_business",children:"Terms of Business"})]})]})]}),Se.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(r,{children:["Document Template ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(J,{value:u,onValueChange:ze,children:[e.jsx(Y,{"data-testid":"select-esign-template",children:e.jsx(H,{placeholder:"No template â use text body below"})}),e.jsxs(X,{children:[e.jsx(N,{value:"none",children:"No template â use text body below"}),Se.map(s=>e.jsx(N,{value:s.id,children:s.name},s.id))]})]}),u!=="none"&&e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(js,{className:"h-3.5 w-3.5 text-green-600"}),"The PDF template will be shown to the signer â no text body needed."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Recipient Name"}),e.jsx(d,{"data-testid":"input-esign-recipient-name",value:A,onChange:s=>ge(s.target.value),placeholder:"Full name"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Recipient Email"}),e.jsx(d,{"data-testid":"input-esign-recipient-email",type:"email",value:q,onChange:s=>fe(s.target.value),placeholder:"[email protected]"})]})]}),u!=="none"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(r,{children:["Job Title ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(d,{"data-testid":"input-esign-job-title",value:be,onChange:s=>Ue(s.target.value),placeholder:"e.g. Customer Service Advisor"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(r,{children:["Company Name ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(d,{"data-testid":"input-esign-company-name",value:Ne,onChange:s=>Ve(s.target.value),placeholder:"e.g. Acme Ltd"})]})]}),u==="none"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(r,{children:"Document Body"}),e.jsx(Pe,{"data-testid":"textarea-esign-doc-body",value:B,onChange:s=>ye(s.target.value),rows:8,className:"text-xs font-mono"})]})]}),e.jsxs(Ee,{children:[e.jsx(i,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(i,{disabled:ve||!A.trim()||!q.trim()||u==="none"&&!B.trim(),"data-testid":"button-esign-send",onClick:async()=>{we(!0);try{const a=await(await o("POST","/api/esign/create",{documentType:je,recipientName:A,recipientEmail:q,documentBody:u!=="none"?void 0:B,templateId:u!=="none"?u:void 0,recipientJobTitle:be.trim()||void 0,recipientCompanyName:Ne.trim()||void 0,recipientPhone:t?.phone||void 0,clientId:n})).json();Je(),C(!1),a.emailSent?c({title:"Signature request sent",description:"An email with the signing link has been sent to the recipient."}):a.outlookAuthError?(c({title:"Signing request created",description:"Use 'Copy link' to share the signing link manually."}),M(!0)):c({title:"Signing request created",description:"Email could not be sent â use 'Copy link' on the request to share it manually."})}catch{c({title:"Failed to send signing request",variant:"destructive"})}finally{we(!1)}},children:ve?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"h-4 w-4 mr-2 animate-spin"})," Sendingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 mr-2"})," Send Signing Request"]})})]})]})}),e.jsx(gs,{open:Qe,onOpenChange:M})]}):e.jsx("div",{className:"p-6 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"Client not found"})})}
22export{ut as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.