PageSourceSearch

https://www.bindstack.ai/assets/EditClientPage-Xqfl3xpt.js

js bindstack.ai collected 2026-10-05 15:01:15 UTC 7,595 bytes, 1 lines download raw bytes

1import{j as e,r as _}from"./ui-vendor-Da9uQuMW.js";import{u as y}from"./index.esm-CPxzRGRC.js";import{a as v}from"./zod-CYT7bu3-.js";import{a as P,d as w,q as d,m as F,as as N,a9 as E,y as S,aw as M}from"./App-B1QN_3sS.js";import{P as D}from"./PhoneInput-Bs-uNvr5.js";import{B as f}from"./separator-CcGBAGgT.js";import{a as T,b as h}from"./field-fegNnuR1.js";import{F as k,a as l,b as o,c as j,d as i,e as c}from"./form-DjaFZy1J.js";import{I as g}from"./input-Brt-l3Vp.js";import{I as V}from"./input-date-2eVIE3Jr.js";import{e as B,u as L}from"./client.service-D2_Glw4E.js";import{c as q}from"./useRelationshipTypes-PgjMhRUp.js";import{C as I,T as R}from"./tags-manager-B-HjNgvY.js";import{E as U,R as K,a as $}from"./relationships-manager-CesK20Hy.js";import{b as z,u as A,c as G}from"./utils-DxXc-Znk.js";import{u as Q}from"./use-client-title-BBR56iFk.js";import"./schemas-Co01wv4L.js";import"./index-CmeDnPm-.js";import"./icons-dynamic-vendor-Cqq8S-fy.js";import"./triangle-alert-DXdl2qp5.js";import"./charts-vendor-DWyOgyj2.js";import"./label-CRXglOZ-.js";import"./form-context-Bh2_V_Tz.js";import"./calendar-DHlzcMmw.js";import"./isSameMonth-CTRyE1l9.js";import"./differenceInCalendarMonths-BNQGOslE.js";import"./isBefore-D6ggWwtQ.js";import"./endOfMonth-BC0iisUo.js";import"./isSameDay-DjhqARqg.js";import"./chevron-left-hPFoVWSi.js";import"./chevron-down-BxT7zPmN.js";import"./master.service-CgJD5klq.js";import"./external-DlBibT6I.js";import"./coerce-D2T_-LMI.js";import"./drawer-CRDKWsU0.js";import"./scroll-area-BxLCDlQw.js";import"./client-category.service-Ej2SOnLb.js";import"./plus-B0rxKHQi.js";import"./pencil-Dl6ciUcf.js";import"./trash-2-YwIbSmcf.js";import"./hash-e9nTm3Ek.js";import"./checkbox-Dl8ThHeQ.js";import"./select-BU2kemPI.js";import"./chevron-up-Dwh8BAX2.js";import"./use-infinite-scroll-CFIjmTyF.js";import"./participant-item-CXyq1fOL.js";import"./search-BaKoX4JV.js";import"./use-location-state-DCb-o99A.js";const W={hot:"bg-red-500 text-white hover:bg-red-600",warm:"bg-yellow-500 text-white hover:bg-yellow-600",cold:"bg-blue-500 text-white hover:bg-blue-600"};function H({value:r,onChange:u,temperatures:p,disabled:x=!1}){return e.jsx("div",{className:"flex flex-wrap gap-2",children:p.map(m=>e.jsx(f,{type:"button",variant:r===m?"default":"outline",className:`flex-1 shadow-none ${r===m&&W[m]||""}`,onClick:()=>u(m),disabled:x,children:z(m)},m))})}function J({clientId:r}){const u=P(),{data:p,isLoading:x}=w({queryKey:d.clientFormData(r),queryFn:()=>B(r)}),m=p?.masterData,n=p?.client,t=y({resolver:v(q),defaultValues:{name:"",nickname:"",dob:null,emails:[],phone_number:"",client_category:void 0,temperature:null,tags:[],relationship:[],ref_type:null,ref_value:null,ref_source_id:null,ref_source_name:null}});_.useEffect(()=>{n&&t.reset({name:n.cl_name,nickname:n.cl_nickname||"",dob:n.cl_dob?new Date(n.cl_dob):null,emails:n.cl_emails&&n.cl_emails.length>0?n.cl_emails:n.cl_email?[{email:n.cl_email,is_primary:!0}]:[],phone_number:n.cl_phone_number||"",client_category:n.cl_client_category||"leads",temperature:n.cl_temperature||null,tags:n.cl_client_tagging||[],ref_type:n.cl_ref_type??null,ref_value:n.cl_ref_value??null,ref_source_id:n.cl_ref_source_id??null,ref_source_name:n.ref_source_name??null,relationship:n.cl_relationship.map(a=>({id_client:a.id_client,relation_type:a.relation_type,name:a.client.name}))})},[n,t]);const s=F({mutationFn:a=>L(r,a),successMessage:"Contact updated successfully",errorMessage:"Failed to update contact",invalidateKeys:[d.clients(),d.client(r),d.clientFormData(r),d.clientData(r),d.clientTagCatalog(),d.tags(),d.tagUsageClient()],onSuccess:()=>{u("/app/contacts")}}),b=a=>{s.mutate(a)},C=()=>{u(-1),t.reset()};return x?e.jsx(N,{title:"Loading contact data...",subtitle:"Please wait while we fetch the contact information."}):e.jsx(k,{...t,children:e.jsxs("form",{onSubmit:t.handleSubmit(b),className:"flex flex-col gap-6 pb-6",children:[e.jsxs(T,{className:"gap-4",children:[e.jsx(l,{control:t.control,name:"name",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsx(h,{children:"Full Name"})}),e.jsx(i,{children:e.jsx(g,{placeholder:"Enter contact full name",disabled:s.isPending,...a})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"nickname",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsx(h,{children:"Nickname"})}),e.jsx(i,{children:e.jsx(g,{placeholder:"Enter contact nickname",disabled:s.isPending,...a,value:a.value??""})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"dob",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsx(h,{children:"Date of Birth"})}),e.jsx(i,{children:e.jsx(V,{value:a.value,onChange:a.onChange,placeholder:"31/12/1999",disabled:s.isPending})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"emails",render:({field:a})=>e.jsxs(o,{children:[e.jsx(i,{children:e.jsx(U,{value:a.value,onChange:a.onChange,disabled:s.isPending})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"phone_number",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsxs(h,{children:["Phone Number"," ",e.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]})}),e.jsx(i,{children:e.jsx(D,{placeholder:"Enter phone number",disabled:s.isPending,...a,value:a.value??""})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"client_category",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsx(h,{children:"Category"})}),e.jsx(i,{children:e.jsx(I,{value:a.value,onChange:a.onChange,disabled:s.isPending||x})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"temperature",render:({field:a})=>e.jsxs(o,{children:[e.jsx(j,{children:e.jsx(h,{children:"Temperature"})}),e.jsx(i,{children:e.jsx(H,{value:a.value??null,onChange:a.onChange,temperatures:m?.temperature_type||[],disabled:s.isPending||x})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"tags",render:({field:a})=>e.jsxs(o,{children:[e.jsx(i,{children:e.jsx(R,{value:a.value,onChange:a.onChange,disabled:s.isPending})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"ref_type",render:()=>e.jsxs(o,{children:[e.jsx(i,{children:e.jsx(K,{refType:t.watch("ref_type"),refValue:t.watch("ref_value"),refSourceId:t.watch("ref_source_id"),refSourceName:t.wat
1ch("ref_source_name"),onChange:a=>{t.setValue("ref_type",a.ref_type),t.setValue("ref_value",a.ref_value),t.setValue("ref_source_id",a.ref_source_id),t.setValue("ref_source_name",a.ref_source_name)},disabled:s.isPending,currentClientId:r})}),e.jsx(c,{})]})}),e.jsx(l,{control:t.control,name:"relationship",render:({field:a})=>e.jsxs(o,{children:[e.jsx(i,{children:e.jsx($,{value:a.value,onChange:a.onChange,disabled:s.isPending,currentClientId:r})}),e.jsx(c,{})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(f,{type:"submit",className:"flex-1",disabled:s.isPending,children:s.isPending?"Updating...":"Update Contact"}),e.jsx(f,{type:"button",variant:"outline",className:"flex-1",onClick:C,disabled:s.isPending,children:"Cancel"})]})]})})}function Ae(){const{id:r}=E(),u=Q(r);A("Edit Contact");const{setBreadcrumbs:p}=S(),x=M();return _.useEffect(()=>{p([{label:"Contacts",to:"/app/contacts"},{label:u,to:`/app/contacts/${r}`},{label:"Edit Contact",to:`/app/contacts/${r}/edit`,isLast:!0}])},[p,r,u]),r?e.jsxs("div",{className:G("mx-auto flex w-full flex-col gap-8 px-4 py-3.5",x?"max-w-md":""),children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Edit Contact"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Update contact information and details."})]}),e.jsx(J,{clientId:r})]}):null}export{Ae 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.