(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[871],{30700:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>g});var a=n(37876);n(14232);var o=n(72757),l=n(35003),i=n(60795),r=n(1912),s=n(84812),c=n(37626),u=n(1105),d=n(50223),m=n(1992),p=n(97685),y=n(74860),h=n(39091),_=n(73564),v=n(99995),f=n(34780),b=n(71212),x=n(66703);let g=t=>{let e,n,g,{setLoyalityModal:j,loyalitydata:w,refetch:A,profileRefatch:E,loyalityModal:S}=t,C=(0,x.A)(),{global:T}=(0,u.d4)(t=>t.globalSettings);T&&(e=null==T?void 0:T.currency_symbol,n=null==T?void 0:T.currency_symbol_direction,g=null==T?void 0:T.digit_after_decimal_point);let{t:k}=(0,c.B)(),N=(0,d.Wx)({initialValues:{point:w||0},validationSchema:h.Ik({point:h.ai().required("Please give an amount")}),onSubmit:async(t,e)=>{if(t.point<=w&&t.point>=(null==T?void 0:T.loyalty_point_exchange_rate))if(t.point<(null==T?void 0:T.minimum_point_to_transfer))p.oR.error("".concat(k("Please exchange more than ")," ").concat(k(null==T?void 0:T.minimum_point_to_transfer)," ").concat(k(" points")));else try{P(t)}catch(t){}else p.oR.error(k("insufficient amount"))}}),P=t=>{R(t,{onSuccess:async t=>{var e,n,a;203===t.status?null==t||null==(n=t.data)||null==(e=n.errors)||e.forEach(t=>p.oR.error(t.message)):(p.oR.success(null==t||null==(a=t.data)?void 0:a.message),j(!1),await A(),await E())},onError:b.J})},{mutate:R}=(0,m.useMutation)("loyalityToWallet",y.G.loyalityToWallet),V=k("points");return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(o.A,{open:S,onClose:()=>{j(!1)},"aria-labelledby":"modal-modal-title","aria-describedby":"modal-modal-description",children:(0,a.jsxs)(_.V,{children:[(0,a.jsx)(l.A,{variant:"h5",align:"center",mb:".5rem",color:C.palette.neutral[1e3],children:k("Your loyalty point will convert to currency and transfer to wallet")}),(0,a.jsx)(v.YO,{align:"center",variant:"h5",color:"primary.main",children:"".concat(null==T?void 0:T.loyalty_point_exchange_rate," ").concat(V," = ").concat((0,f.fE)(1,n,e,g))}),(0,a.jsx)(i.A,{mt:"1rem",children:(0,a.jsxs)("form",{noValidate:!0,onSubmit:N.handleSubmit,children:[(0,a.jsx)(r.A,{required:!0,type:"number",sx:{width:"100%",color:t=>t.palette.neutral[1e3]},id:"outlined-basic",label:k("Amount"),variant:"outlined",name:"point",value:N.values.point,onChange:N.handleChange,defaultValue:N.values.point,error:N.touched.point&&!!N.errors.point,helperText:N.touched.point&&N.errors.point}),(0,a.jsx)(i.A,{justifyContent:"center",mt:"1rem",children:(0,a.jsx)(s.A,{variant:"contained",type:"submit",children:k("Submit")})})]})})]})})})}},30754:(t,e,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/info/loyality/LoyalityModal",function(){return n(30700)}])},74860:(t,e,n)=>{"use strict";n.d(e,{G:()=>o});var a=n(45774);let o={loayalityList:t=>a.A.get("/api/v1/customer/loyalty-point/transactions?offset=".concat(t,"&limit=10")),loyalityToWallet:t=>a.A.post("/api/v1/customer/loyalty-point/point-transfer",t)}}},t=>{t.O(0,[636,6593,8792],()=>t(t.s=30754)),_N_E=t.O()}]);