1import{a as m,j as e,L as I}from"./vendor-BEUer1XH.js";import{u as z}from"./useQuery-BhaiNdUJ.js";import{u as H}from"./useMutation-KANBv_r7.js";import{g as D}from"./hub.api-3Y-DajJ0.js";import{L as K}from"./index-Dfin3-gg.js";import{P as C}from"./PlusCircleOutlined-C07CyfV-.js";import{u as Q}from"./useCustomerAuth-DwzWAjwz.js";import{M as R}from"./index-DoV0blCP.js";import{c as U}from"./customer.api-CQHdDpwz.js";import{i as V}from"./utils-w1iDNRBg.js";import{M as G}from"./index-BJNvwC5j.js";import{D as J,T as P,B as W}from"./index-DENArrSa.js";import{B as X}from"./Breadcrumb-DW4w8HQp.js";import{S as k}from"./index-CCT_oRJ6.js";import{F as o}from"./index-BYqFq3zo.js";import{S as A}from"./index-B1cxAMIp.js";import{S as Y}from"./index-Cn9ZDzL8.js";import"./index-xmoZg6gj.js";import"./index-C9C5-gxl.js";import"./index-_xoAewD-.js";import"./index-CrRiyByw.js";import"./EyeOutlined-D647LYEE.js";import"./addEventListener-DapjV_MG.js";import"./LeftOutlined-CpjQE-vN.js";import"./RightOutlined-9GOMZsx1.js";import"./TagsOutlined-CKJsvvIo.js";import"./index-DkfwU8zk.js";import"./DownOutlined-CeXDrnPO.js";import"./dropdown-qHy0AlcK.js";import"./Dropdown-CDCCRALY.js";import"./PurePanel-CbtVgttN.js";import"./index-BzPrgs7b.js";import"./EllipsisOutlined-Djar-icM.js";import"./Overflow-CAQIMHA2.js";import"./mediaQueryUtil-BSyvLspT.js";import"./collapse-BbEVqHco.js";import"./index-CUWDS_la.js";import"./useForm-DrUwT_4T.js";import"./useBreakpoint-BBrUbbpN.js";import"./SearchOutlined-DVVMytpw.js";const{Title:Z}=P,ze=()=>{var h,f,g,x,b,j,N,y,_,S;const{customer:t}=Q(),{notification:c}=J.useApp(),[u,O]=m.useState({search:""}),[T,p]=m.useState({lat:37.33548,lng:-121.893028});m.useEffect(()=>{var s,i,a;if((a=(i=(s=t==null?void 0:t.registered_customer)==null?void 0:s.setting)==null?void 0:i.default_hub)!=null&&a.address){const r=t.registered_customer.setting.default_hub.address,l=Number(r.latitude),n=Number(r.longitude);!isNaN(l)&&!isNaN(n)&&p({lat:l,lng:n})}},[t]);const{data:d,isLoading:M}=z({refetchOnMount:!0,queryKey:["hubs",u],queryFn:()=>D(u),select:s=>s.hubs,retry:0,placeholderData:s=>s}),L=s=>O({search:s}),q=(s,i)=>{if(i!=null&&i.address){const a=Number(i.address.latitude),r=Number(i.address.longitude);!isNaN(a)&&!isNaN(r)&&p({lat:a,lng:r})}},{mutate:w,isPending:B}=H({mutationFn:s=>U(s),onSettled:(s,i)=>{var a,r,l,n,v;if(i){if(V(i)){let F=i==null?void 0:i.message;(r=(a=i==null?void 0:i.response)==null?void 0:a.data)!=null&&r.error&&(F=(v=(n=(l=i==null?void 0:i.response)==null?void 0:l.data)==null?void 0:n.details)==null?void 0:v.message),c.error({message:F})}}else s&&s.registered_customer&&c.success({message:"Account setting has been updated"})}}),E=s=>w(s);return e.jsxs(e.Fragment,{children:[e.jsx(G,{title:"Account Settings"}),e.jsxs("section",{className:"space-y-4 md:space-y-0",children:[e.jsx(X,{className:"block md:hidden",items:[{title:e.jsx(I,{to:"/accounts",children:"..."})},{title:e.jsx(P.Text,{className:"capitalize",children:"Settings"})}]}),e.jsx(Z,{level:4,className:"pb-0 md:pb-4",children:"Settings"}),e.jsx(k,{spinning:!t,indicator:e.jsx(C,{spin:!0}),children:t&&e.jsxs(o,{layout:"vertical",initialValues:{default_hub_id:((f=(h=t==null?void 0:t.registered_customer)==null?void 0:h.setting)==null?void 0:f.default_hub.status)==="active"?(x=(g=t==null?void 0:t.registered_customer)==null?void 0:g.setting)==null?void 0:x.default_hub.id:void 0,email_subscription:(j=(b=t==null?void 0:t.registered_customer)==null?void 0:b.setting)==null?void 0:j.email_subscription,is_private:(y=(N=t==null?void 0:t.registered_customer)==null?void 0:N.setting)==null?void 0:y.is_private},requiredMark:!1,onFinish:E,children:[e.jsx(o.Item,{name:"email_subscription",hidden:!0,valuePropName:"checked",children:e.jsx(A,{checkedChildren:"ON",unCheckedChildren:"OFF"})}),e.jsx(o.Item,{label:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"mb-0",children:"Preferred Hub"}),e.jsxs("p",{className:"font-normal text-gray-400",children:["This will be your default hub for ",e.jsx("span",{className:"inline-flex",children:"pickup or drop-off"})]})]}),name:"default_hub_id",rules:[{required:!0,message:"Please select a hub"}],children:e.jsx(Y,{style:{height:"auto"},options:d&&d.length>0?d.map(s=>({...s,value:s.id,label:e.jsx(K,{option:s}),title:s.name,disabled:!1})):[{key:"",value:(S=(_=t==null?void 0:t.registered_customer)==null?void 0:_.setting)==null?void 0:S.default_hub.id,label:e.jsx("span",{className:"text-gray-400",children:"Loading..."}),title:"",disabled:!1}],onSearch:L,filterOption:!1,notFoundContent:M?e.jsx(k,{indicator:e.jsx(C,{spin:!0}),size:"small"}):null,placeholder:"Search hub by name, zipcode, city, or address",defaultActiveFirstOption:!0,onSelect:q,showSearch:!0})}),e.jsx(R,{center:T}),e.jsx("hr",{className:"my-6"}),e.jsx(o.Item,{name:"is_private",label:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"mb-0",children:"Public Profile"}),e.jsx("p",{className:"font-normal text-gray-400",children:"Turning your public profile off will make your profile page not visible to other users."})]}),valuePropName:"checked",children:e.jsx(A,{checkedChildren:"ON",unCheckedChildren:"OFF"})}),e.jsx(o.Item,{className:"text-right",children:e.jsx(W,{type:"primary",htmlType:"submit",loading:B,children:"Update settings"})})]})})]})]})};export{ze 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.