PageSourceSearch

https://propertymeasure.ai/assets/NewClientPage-B_R7GGzR.js

js propertymeasure.ai collected 2026-10-05 13:46:11 UTC 12,460 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-motion-0RUSUsFi.js";import{c as ce,j as de,a as l,L as me}from"./vendor-router-BySvYurK.js";import{e as P,i as G,a as ue,h as H,c as Y,b as he,d as xe,C as pe,f as be}from"./clientFormLogic-Cat2qcE-.js";import{c9 as q,ca as ge,aj as je,P as fe,aO as W,c5 as o,bC as Ne,aN as I,$ as ve,az as ye,ac as ke,ad as Ce,cb as Se,cc as Te}from"./index-CyDkdwrf.js";import{c as we}from"./portfolioLogic-CF9Bt41z.js";import{E as Pe,A as Ae,a as Re,b as Ee}from"./AddressAutocomplete-B7KI441E.js";import{u as Fe}from"./usePageTitle-rWW94EJR.js";import{T as $e}from"./tag-RkxRzNCW.js";import{T as _e}from"./trash-2-bjFTbf9c.js";import"./vendor-firebase-JEFnLeA1.js";import"./googleMaps-Ducq9TIZ.js";const Oe=["referral","website","google","social","repeat","walk-by","other"],Le={referral:"Referral",website:"Website",google:"Google",social:"Social media",repeat:"Repeat customer","walk-by":"Saw us working nearby",other:"Other"};let Be=0;const A=()=>`c${Be+=1}`;function Je(){Fe("New client");const a=ce(),[c]=de(),[n,m]=l.useState(c.get("name")??""),[u,f]=l.useState(q(c.get("name")??"")),[N,r]=l.useState(!1),[s,K]=l.useState(ge),[R,V]=l.useState(""),[E,Z]=l.useState(""),[F,J]=l.useState(""),[v,Q]=l.useState([]),[y,$]=l.useState(Pe),[_,O]=l.useState(""),[L,X]=l.useState(""),[B,ee]=l.useState(!1),[U,te]=l.useState(!1),[z,ae]=l.useState(""),[M,se]=l.useState(""),[x,k]=l.useState(()=>[P(A())]),[C,S]=l.useState(!1),[D,b]=l.useState(null),T=l.useRef(null);l.useEffect(()=>{T.current?.focus()},[]);const le=l.useCallback(async()=>{if(v.length)return;const t=await je().catch(()=>[]);Q(t.filter(i=>we("__new__",i.id,t).ok).map(i=>({id:i.id,name:i.name})).sort((i,d)=>i.name.localeCompare(d.name)))},[v.length]),ne=(t,i)=>k(d=>d.map(p=>p.key===t?{...p,...i}:p)),ie=()=>k(t=>[...t,P(A())]),re=t=>k(i=>i.length===1?[P(A())]:i.filter(d=>d.key!==t)),g=x.filter(G),w=l.useMemo(()=>ue(x),[x]);async function oe(){const t=n.trim();if(!t){b("Give the client a name so you can find them later."),T.current?.focus();return}if(w.length){b(`${w.length===1?"One person has":`${w.length} people have`} details but no name. Add a name, or clear the row.`);return}S(!0),b(null);try{const i=await Se(he({name:t,type:u,status:s,source:R,companyName:E,parentClientId:F,addressRecord:Ee(y),addressText:_,terms:L,poRequired:B,taxExempt:U,tags:z,notes:M})),d=[];for(const p of xe(x))try{await Te(i.id,p)}catch{d.push(p.name)}if(d.length){S(!1),b(`Client saved, but ${d.join(" and ")} could not be added. Add them from the client page.`),setTimeout(()=>a(`/clients/${i.id}`),1800);return}a(`/clients/${i.id}`)}catch(i){b(i instanceof Error?i.message:"Could not save. Check your connection and try again."),S(!1)}}return e.jsxs("main",{className:"app-container py-6 lg:py-10",children:[e.jsx(fe,{breadcrumbs:[{label:"Clients",to:"/clients"},{label:"New client"}],title:"New client",subtitle:"Who they are, where they are, and who to call. You can add properties and more contacts afterwards."}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs(j,{title:"The client",icon:W,children:[e.jsx(h,{label:"Name",htmlFor:"cl-name",required:!0,children:e.jsx("input",{id:"cl-name",ref:T,value:n,onChange:t=>{m(t.target.value),N||f(q(t.target.value))},className:o,placeholder:"Willowbrook Office Park"})}),e.jsxs("fieldset",{className:"mt-4",children:[e.jsx("legend",{className:"mb-1.5 text-12 font-medium text-ink-muted",children:"Where does this stand?"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:Ne.filter(t=>t.value!=="archived").map(t=>e.jsx(Ue,{selected:s===t.value,onClick:()=>K(t.value),title:t.label,body:t.hint},t.value))})]}),e.jsxs("fieldset",{className:"mt-4",children:[e.jsx("legend",{className:"mb-1.5 text-12 font-medium text-ink-muted",children:"Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:["residential","commercial"].map(t=>e.jsxs("button",{type:"button","aria-pressed":u===t,onClick:()=>{f(t),r(!0)},className:`flex items-center justify-center gap-2 rounded-lg border px-3 py-2.5 text-13 font-medium transition-colors ${u===t?"border-brand bg-brand-soft text-brand-ink":"border-line bg-raised text-ink hover:bg-sunk"}`,children:[t==="residential"?e.jsx(I,{size:15,"aria-hidden":"true"}):e.jsx(W,{size:15,"aria-hidden":"true"}),t==="residential"?"Residential":"Commercial"]},t))})]}),e.jsx(h,{label:"How did they find you?",htmlFor:"cl-source",hint:"Recording this is what lets you see which marketing actually pays.",children:e.jsxs("select",{id:"cl-source",value:R,onChange:t=>V(t.target.value),className:o,children:[e.jsx("option",{value:"",children:"Not recorded"}),Oe.map(t=>e.jsx("option",{value:t,children:Le[t]??t},t))]})}),e.jsx(h,{label:"Company name",htmlFor:"cl-company",hint:"Trading name, if it differs from the account name.",children:e.jsx("input",{id:"cl-company",value:E,onChange:t=>Z(t.target.value),className:o})}),e.jsx(h,{label:"Part of a group",htmlFor:"cl-parent",hint:"For portfolios — a management company with several sites.",children:e.jsxs("select",{id:"cl-parent",value:F,onFocus:le,onChange:t=>J(t.target.value),className:o,children:[e.jsx("option",{value:"",children:"Standalone"}),v.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})})]}),e.jsxs(j,{title:"Address",icon:ve,children:[e.jsx(Ae,{value:_,id:"cl-addr",label:"Billing address",onChange:t=>{O(t),$({...y,formatted:t})},onSelect:t=>{$(t),O(t.formatted)},placeholder:"Where invoices go",hint:"Pick a suggestion and the city, state, ZIP and map location fill themselves in."}),e.jsx(Re,{address:y})]}),e.jsxs(j,{title:"Billing & tags",icon:$e,children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(h,{label:"Payment terms",htmlFor:"cl-terms",children:e.jsxs("select",{id:"cl-terms",value:L,onChange:t=>X(t.target.value),className:o,children:[e.jsx("option",{value:"",children:"Not set"}),[0,7,14,30,45,60].map(t=>e.jsx("option",{value:String(t),children:t===0?"Due on receipt":`Net ${t}`},t))]})}),e.jsx(h,{label:"Tags",htmlFor:"cl-tags",hint:"Comma separated.",children:e.jsx("input",{id:"cl-tags",value:z,onChange:t=>ae(t.target.value),className:o,placeholder:"snow, VIP, net-30"})})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-13 text-ink",children:[e.jsx("input",{type:"checkbox",checked:B,onChange:t=>ee(t.target.checked),className:"h-4 w-4 accent-brand"}),"Requires a PO number"]}),e.jsxs("label",{className:"flex items-center gap-2 text-13 text-ink",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:t=>te(t.target.checked),className:"h-4 w-4 accent-brand"}),"Tax exempt"]})]}),e.jsx(h,{label:"Notes",htmlFor:"cl-notes",children:e.jsx("textarea",{id:"cl-notes",value:M,onChange:t=>se(t.target.value),rows:3,className:o})})]})]}),e.jsx("div",{className:"space-y-5",children:e.jsxs(j,{title:"People",icon:I,hint:"A commercial account usually has a property manager, someone in accounts payable and a site contact. Add as many as you know.",children:[e.jsx("div",{className:"space-y-4",children:x.map((t,i)=>e.jsx(ze,{contact:t,index:i,onChange:d=>ne(t.key,d),onRemove:()=>re(t.key),removable:x.length>1||H(t)},t.key))}),e.jsxs("button",{type:"button",onClick:ie,className:"mt-3 inline-flex items-center gap-1.5 rounded-lg border border-line bg-raised px-3 py-2 text-13 font-semibold text-ink hover:bg-sunk",children:[e.jsx(ye,{size:15,"aria-hidden":"true"})," Add another person"]}),g.length>0&&e.jsxs("p",{className:"mt-3 text-12 text-ink-muted",children:[e.jsx("span",{className:"font-medium text-ink",children:Y(g[0])})," will be the primary contact",g.length>1?`, with ${g.length-1} more`:"","."]})]})})]}),e.jsx("div",{className:"sticky bottom-0 z-10 mt-6 -mx-4 border-t border-line bg-raised px-4 py-3 sm:-mx-6 sm:px-6",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[D?e.jsx("p",{role:"alert",className:"mr-auto text-13 text-bad",children:D}):e.jsx("p",{className:"mr-auto text-12 text-ink-muted",children:n.trim()?"Ready to save.":"A client name is needed before this can be saved."}),e.jsx(me,{to:"/clients",children:e.jsx(ke,{disabled:C,children:"Cancel"})}),e.jsx(Ce,{onClick:oe,disabled:C||!n.trim(),children:C?"Saving…":"Create client"})]})})]})}function j({title:a,icon:c,hint:n,children:m}){return e.jsxs("section",{className:"rounded-xl border border-line bg-raised p-4 sm:p-5",children:[e.jsxs("header",{className:"mb-3",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-14 font-semibold text-ink",children:[e.jsx(c,{size:15,className:"text-ink-faint","aria-hidden":"true"}),a]}),n&&e.jsx("p",{className:"mt-1 text-12 text-ink-muted",children:n})]}),m]})}function h({label:a,htmlFor:c,hint:n,required:m,children:u}){return e.jsxs("div",{className:"mt-4 first:mt-0",children:[e.jsxs("label",{htmlFor:c,className:"mb-1 block text-12 font-medium text-ink-muted",children:[a,m&&e.jsx("span",{className:"ml-0.5 text-bad","aria-hidden":"true",children:"*"})]}),u,n&&e.jsx("p",{className:"mt-1 text-11 text-ink-faint",children:n})]})}function Ue({selected:a,onClick:c,title:n,body:m}){return e.jsxs("button",{type:"button","aria-pressed":a,onClick:c,className:`rounded-lg border p-3 text-left transition-colors ${a?"border-brand bg-brand-soft":"border-line bg-raised hover:bg-sunk"}`,children:[e.jsx("span",{className:`block text-13 font-semibold ${a?"text-brand-ink":"text-ink"}`,children:n}),m&&e.jsx("span",{className:"mt-0.5 block text-12 leading-snug text-ink-muted",children:m})]})}function ze({contact:a,index:c,onChange:n,onRemove:m,removable:u}){const N=H(a)&&!G(a),r=s=>`ct-${a.key}-${s}`;return e.jsxs("fieldset",{className:"rounded-lg border border-line p-3",children:[e.jsxs("legend",{className:"flex items-center gap-2 px-1 text-12 font-semibold text-ink-muted",children:[c===0?"Primary contact":`Contact ${c+1}`,u&&e.jsx("button",{type:"button",onClick:m,"aria-label":`Remove ${Y(a)||`contact ${c+1}`}`,className:"text-ink-faint hover:text-bad",children:e.jsx(_e,{size:13,"aria-hidden":"true"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("first"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"First name"}),e.jsx("input",{id:r("first"),value:a.firstName,onChange:s=>n({firstName:s.target.value}),className:o,placeholder:"Ann"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("last"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Last name"}),e.jsx("input",{id:r("last"),value:a.lastName,onChange:s=>n({lastName:s.target.value}),className:o,placeholder:"Delgado"})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{htmlFor:r("role"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Role"}),e.jsxs("select",{id:r("role"),value:a.role,onChange:s=>n({role:s.target.value}),className:o,children:[e.jsx("option",{value:"",children:"Not recorded"}),pe.map(s=>e.jsx("option",{value:s,children:be[s]},s))]})]}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("email"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Email"}),e.jsx("input",{id:r("email"),type:"email",value:a.email,onChange:s=>n({email:s.target.value}),className:o,placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("phone"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Phone"}
1),e.jsx("input",{id:r("phone"),type:"tel",value:a.phone,onChange:s=>n({phone:s.target.value}),className:o,placeholder:"(555) 123-4567"})]})]}),e.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("mobile"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Mobile"}),e.jsx("input",{id:r("mobile"),type:"tel",value:a.mobile,onChange:s=>n({mobile:s.target.value}),className:o,placeholder:"(555) 987-6543"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:r("notes"),className:"mb-1 block text-12 font-medium text-ink-muted",children:"Notes"}),e.jsx("input",{id:r("notes"),value:a.notes,onChange:s=>n({notes:s.target.value}),className:o,placeholder:"Best reached mornings"})]})]}),N&&e.jsx("p",{className:"mt-2 text-12 text-amber-700",children:"Add a name, or this person cannot be saved."})]})}export{Je 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.