import{o as d,R as l,l as x,k as O,j as e,G as R,aR as b,aS as F}from"./app-BgLa5dit.js";import{S}from"./CReApwJh.chunk.js";import{O as V}from"./BZQd390p.chunk.js";import{C as v}from"./C2cKa2R1.chunk.js";import{C as L,a as q}from"./8iu0vnCW.chunk.js";import"./C4BcftDO.chunk.js";import"./lZO4aq5x.chunk.js";import"./C8_78Eqq.chunk.js";import"./BPPr_ng0.chunk.js";import"./BixyE8L-.chunk.js";import"./c3I67AiW.chunk.js";import"./3nM7jLnE.chunk.js";import"./CPXlV0fg.chunk.js";import"./ChrB5FYK.chunk.js";import"./DR2FaZH9.chunk.js";import"./q-IBKcuF.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";import"./KUnagq9Z.chunk.js";import"./DULWIWQR.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";function nt(o){var m;const t=d(S.customerSettings(o.id)),s=d(b.currentUser()),[f,r]=l.useState(!1),[h,i]=l.useState(!1),a=x(),C=O();async function g(j){try{r(!0);const p=Object.values(j).filter(n=>{var u,c;const y=(c=(u=t.data)==null?void 0:u[n.name])==null?void 0:c.value;return!F.isEqual(y,n.value)});await C(S.updateSettings(o.id,p)),r(!1),a.success("Customer options updated.")}catch{a.error("Failed to update customer options.")}finally{i(!1)}}const w=t.hasCompleted&&s.hasCompleted&&t.hasCompleted;return e.jsx(L,{view:q.Customers,children:e.jsx(v,{title:"Options",currentTabId:"options",id:o.id,loading:!w,children:e.jsx(R,{onSubmit:()=>{},initialValues:t.data||{},children:e.jsx(V,{settings:t.data,showSpinner:f,showPopup:h,userGroups:(m=s.data)==null?void 0:m.groups,setShowPopup:i,setShowSpinner:r,onSubmit:g,title:"Options"})},o.id)})})}export{nt as CustomerOptionsView};
//# sourceMappingURL=D1bwuqLU.chunk.js.map
