import{o as x,l as C,k as j,j as e,E as b,G as L,aA as c,az as S,ax as f,a9 as r}from"./app-BgLa5dit.js";import{C as l}from"./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";const P=c.object().shape({limit:c.number().required(()=>"This is required")});function G(t){var a,d;const i=x(l.getCustomerUserCredit(t.customerId,t.userId)),s=C(),u=j();function n({limit:o}){var m;if(o===((m=i.data)==null?void 0:m.creditLimit)){t.closePopup();return}const h=l.editUserCreditLimit({...i.data,customerId:t.customerId,userId:t.userId,maxCredit:o});u(h).then(()=>s.success("Successfully updated credit limit")).catch(()=>s.error("Failed to update credit limit. Please try again.")).finally(t.closePopup)}const p=!!i.data;return e.jsx(b,{title:"Update Daily Request Limit",closePopup:t.closePopup,showLoadingSpinner:!p,children:e.jsx(L,{initialValues:{limit:((a=i.data)==null?void 0:a.creditLimit)??""},validationSchema:P,onSubmit:n,children:e.jsxs(S,{children:[e.jsx(f,{name:"limit",id:"limit",type:"number",min:0,placeholder:((d=i.data)==null?void 0:d.creditLimit)!==void 0?`Current limit is ${i.data.creditLimit}`:"Enter credit limit",label:"Credit limit",showRequiredStar:!0}),e.jsx("div",{className:"mb-2",children:e.jsxs("em",{children:[e.jsx("b",{children:"Note:"})," User request credit is reset each day."]})}),e.jsxs(r,{children:[e.jsx(r.Cancel,{onClick:t.closePopup,text:"Cancel"}),e.jsx(r.Submit,{variant:"dark",text:"Save"})]})]})})})}export{G as EditUserCreditView};
//# sourceMappingURL=W1a0iNzs.chunk.js.map
