1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1062,9810],{18014:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/coupon/[couponId]",function(){return n(1809)}])},4180:function(e,t){"use strict";t.Z={src:"/_next/static/media/samu-giken.1bf2ec60.webp",height:549,width:1920,blurDataURL:"data:image/webp;base64,UklGRmQAAABXRUJQVlA4WAoAAAAQAAAABwAAAQAAQUxQSBEAAAAAGjk6MjtENBAZNi4qQzcvCgBWUDggLAAAAJABAJ0BKggAAgACQDgloAJ0ugADmAD+6ez/dAAp+z/+0s/+pZ/9Sz/NAAAA",blurWidth:8,blurHeight:2}},46976:function(e,t,n){"use strict";var i=n(52676),s=n(75271),l=n(9059),r=n(96516),a=n(4948),o=n(89120),c=n.n(o);t.Z=e=>{let{fetchOptions:t,debounceTimeout:n=500,...o}=e,[d,u]=(0,s.useState)(!1),[m,h]=(0,s.useState)([]),[p,x]=(0,s.useState)(""),f=(0,s.useRef)(0),g=(0,s.useMemo)(()=>c()(e=>{f.current+=1;let n=f.current;t(e).then(e=>{n===f.current&&(h(e),u(!1))})},n),[t,n]),v=d?(0,i.jsx)("div",{className:"py-2 flex justify-center",children:(0,i.jsx)(l.Z,{size:"small"})}):(0,i.jsx)(r.Z,{});return(0,i.jsx)(a.default,{labelInValue:!0,filterOption:!1,onSearch:e=>{h([]),x(e),void 0!==e&&(u(!0),g(e))},onFocus:()=>{h([]),u(!0),g("")},notFoundContent:v,...o,options:m,showSearch:!0,loading:d,searchValue:p})}},49810:function(e,t,n){"use strict";n.d(t,{Z:function(){return U}});var i=n(52676),s=n(75271),l=n(46035),r=n(33022),a=n(40150),o=n(28994),c=n(85304),d=n(4180),u=n(16624),m=n(27026),h=n.n(m),p=n(78051),x=n(98807),f=n(15036),g=n(32623),v=n.n(g);let j=e=>{let{isMobile:t,isDrawerOpen:n,setIsDrawerOpen:s,collapsed:l,setCollapsed:r,fullName:a}=e,{logout:o}=(0,c.a)();return(0,i.jsxs)("div",{style:{borderBottom:"1px solid #e8e8e8",position:"fixed",width:"100%",zIndex:100},className:"flex items-center justify-between h-16 px-6 bg-white",children:[(0,i.jsxs)("div",{className:"flex items-center h-full gap-2",children:[(0,i.jsx)(p.ZP,{onClick:()=>{t?s(!n):r(!l)},"aria-controls":"sidebar",className:"flex items-center justify-center w-8 px-1 py-0",icon:(0,i.jsx)("svg",{className:"w-5 h-5 text-gray-500",fill:"currentColor",viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h6a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z",clipRule:"evenodd"})})}),!t&&(0,i.jsx)(h(),{href:"/",className:"h-full",children:(0,i.jsx)(v(),{src:d.Z,alt:"Samugiken",className:"w-[100%] h-[60px]"})})]}),(0,i.jsx)("div",{className:"flex items-center justify-center",children:(0,i.jsx)("div",{className:"flex items-center justify-center col-row",children:(0,i.jsx)(x.Z,{arrow:!0,placement:"bottomRight",overlayClassName:"shadow-[rgba(0,0,0,0.35)_0_5px_15px] rounded-xl top-10",trigger:["click"],dropdownRender:()=>(0,i.jsxs)("div",{className:"flex flex-col p-3 bg-white rounded-md shadow-md gap-y-1",children:[(0,i.jsx)(h(),{href:"/my-profile",className:"font-medium leading-[normal] text-primary hover:text-primary",children:(0,i.jsx)("div",{className:"cursor-pointer rounded-[4px] p-3 duration-100 hover:bg-primary/10",children:"My Profile"})}),(0,i.jsx)(f.Z,{className:"!my-2"}),(0,i.jsx)(p.ZP,{type:"primary",danger:!0,onClick:o,children:"Logout"})]}),children:(0,i.jsxs)("div",{className:"flex items-center cursor-pointer gap-x-3",children:[(0,i.jsx)("div",{className:"flex items-center gap-2 ml-2",children:(0,i.jsx)("span",{className:"font-semibold",children:a})}),(0,i.jsx)(u.ZP,{name:a,round:!0,maxInitials:1,size:"35",textSizeRatio:2,fgColor:"white",color:"black"})]})})})})]})};var Z=n(73640),N=n(62581),y=n(26134),A=n(1952),E=n(7144),b=n(42439),C=n(88483),w=n(42720),I=n(43146),R=n(57221),S=n(84176),D=n(54216),O=n(12285),P=n(20188),T=n(19254);let k=e=>{var t,n,l,r,a,o,d,u,m,p,x;let{activeMenu:f,activeDropdown:g}=e,[v,j]=(0,s.useState)(f),{user:k}=(0,c.a)(),_=null==k?void 0:k.role.accessRights,M=e=>{j([e])},F=[{key:"dashboard",label:(0,i.jsx)(h(),{href:N.Z.ADMIN_DASHBOARD,children:"Dashboard"}),icon:(0,i.jsx)(A.Z,{width:16,height:16}),onClick:()=>M("dashboard")},...(0,y.f)(null==_?void 0:null===(t=_.PRODUCT)||void 0===t?void 0:t.READ,[{key:"product",label:(0,i.jsx)(h(),{href:N.Z.PRODUCT,children:"Product"}),icon:(0,i.jsx)(E.Z,{width:16,height:16}),onClick:()=>M("product")}]),...(0,y.f)(null==_?void 0:null===(n=_.REVIEW)||void 0===n?void 0:n.READ,[{key:"review",label:(0,i.jsx)(h(),{href:N.Z.REVIEW,children:"Reviews"}),icon:(0,i.jsx)(b.Z,{width:16,height:16}),onClick:()=>M("review")}]),...(0,y.f)(null==_?void 0:null===(l=_.WARRANTY)||void 0===l?void 0:l.READ,[{key:"warranty",label:"Warranty",icon:(0,i.jsx)(T.Z,{width:16,height:16}),children:[{key:"warranty-register",label:(0,i.jsx)(h(),{href:N.Z.WARRANTY_REGISTER,children:"Warranty Register"}),onClick:()=>M("warranty-register")},{key:"warranty-claim",label:(0,i.jsx)(h(),{href:N.Z.WARRANTY_CLAIM,children:"Warranty Claim"}),onClick:()=>M("warranty-claim")}]}]),...(0,y.f)(null==_?void 0:null===(r=_.COUPON)||void 0===r?void 0:r.READ,[{key:"c
1oupon",label:(0,i.jsx)(h(),{href:N.Z.COUPON,children:"Coupon"}),icon:(0,i.jsx)(C.Z,{width:16,height:16}),onClick:()=>M("coupon")}]),...(0,y.f)(null==_?void 0:null===(a=_.ORDER)||void 0===a?void 0:a.READ,[{key:"order",label:(0,i.jsx)(h(),{href:N.Z.ORDER,children:"Orders"}),icon:(0,i.jsx)(T.Z,{width:16,height:16}),onClick:()=>M("order")},{key:"abandonment",label:(0,i.jsx)(h(),{href:N.Z.ABANDONMENT,children:"Abandonment"}),icon:(0,i.jsx)(w.Z,{width:16,height:16}),onClick:()=>M("abandonment")}]),...(0,y.f)(null==_?void 0:null===(o=_.BLOG)||void 0===o?void 0:o.READ,[{key:"blog",label:(0,i.jsx)(h(),{href:N.Z.BLOG,children:"Blog"}),icon:(0,i.jsx)(I.Z,{width:16,height:16}),onClick:()=>M("blog")}]),...(0,y.f)(null==_?void 0:null===(d=_.OUR_PARTNERS)||void 0===d?void 0:d.READ,[{key:"our-partners",label:(0,i.jsx)(h(),{href:N.Z.OUR_PARTNERS,children:"Our Partners"}),icon:(0,i.jsx)(R.Z,{width:16,height:16}),onClick:()=>M("our-partners")}]),...(0,y.f)(null==_?void 0:null===(u=_.CONTENT_MANAGEMENT)||void 0===u?void 0:u.READ,[{key:"content",label:"Content Management",icon:(0,i.jsx)(S.Z,{width:16,height:16}),children:[{key:"content-banners",label:(0,i.jsx)(h(),{href:N.Z.CONTENT_BANNER,children:"Banners"}),onClick:()=>M("content-banners")},{key:"content-reviews",label:(0,i.jsx)(h(),{href:N.Z.CONTENT_REVIEW,children:"Customer Reviews"}),onClick:()=>M("content-reviews")},{key:"content-videos",label:(0,i.jsx)(h(),{href:N.Z.CONTENT_VIDEO,children:"Product Videos"}),onClick:()=>M("content-videos")},{key:"content-popups",label:(0,i.jsx)(h(),{href:N.Z.CONTENT_POPUP,children:"Popups"}),onClick:()=>M("content-popups")}]}]),...(0,y.f)(null==_?void 0:null===(m=_.USER)||void 0===m?void 0:m.READ,[{key:"user",label:(0,i.jsx)(h(),{href:N.Z.USER,children:"User"}),icon:(0,i.jsx)(D.Z,{width:16,height:16}),onClick:()=>M("user")}]),...(0,y.f)(null==_?void 0:null===(p=_.ROLE)||void 0===p?void 0:p.READ,[{key:"role",label:(0,i.jsx)(h(),{href:N.Z.ROLE,children:"Role"}),icon:(0,i.jsx)(O.Z,{width:16,height:16}),onClick:()=>M("role")}]),...(0,y.f)(null==_?void 0:null===(x=_["SYSTEM_CONFIG/CATEGORY"])||void 0===x?void 0:x.READ,[{key:"system-config",label:(0,i.jsx)(h(),{href:N.Z.SYSTEM_CONFIG,children:"System Config"}),icon:(0,i.jsx)(P.Z,{width:16,height:16}),onClick:()=>M("category")}])];return(0,i.jsx)(Z.Z,{theme:"light",mode:"inline",defaultOpenKeys:g||[],defaultSelectedKeys:v,items:F,className:"h-full font-medium"})};var _=n(63309);let{Sider:M,Content:F}=r.default;var U=e=>{let{children:t,user:n,activeMenu:u=[],activeDropdown:m=[],seoConfig:h,withPadding:p=!0,card:x=!0,contentClassName:f}=e,g=(0,o.ac)("(max-width: 768px)"),[Z,N]=(0,s.useState)(!1),[y,A]=(0,s.useState)(!1);return(0,i.jsx)(c.H,{user:n,children:(0,i.jsxs)(r.default,{className:"!min-h-screen",children:[(0,i.jsx)(l.PB,{...h}),(0,i.jsx)(j,{isMobile:g,isDrawerOpen:y,setIsDrawerOpen:A,collapsed:Z,setCollapsed:N,fullName:(null==n?void 0:n.firstName)+" "+(null==n?void 0:n.lastName)||""}),(0,i.jsx)("div",{className:"mt-[64px]"}),(0,i.jsxs)(r.default,{hasSider:!0,style:{minHeight:"100%"},children:[g?(0,i.jsx)(a.Z,{placement:"left",open:y,onClose:()=>A(!1),width:"250px",styles:{body:{padding:0}},closable:!1,children:(0,i.jsxs)("div",{className:"flex flex-col",children:[(0,i.jsx)("div",{className:"py-2",children:(0,i.jsx)(v(),{src:d.Z,alt:"Samugiken",className:"w-[100%] h-[70px]"})}),(0,i.jsx)(k,{activeMenu:u,activeDropdown:m})]})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:Z?"duration-200 ml-[80px]":"duration-200 ml-[250px]"}),(0,i.jsx)(M,{trigger:null,collapsible:!0,collapsed:Z,theme:"light",width:250,className:"hide-scrollbar",style:{overflow:"scroll",position:"fixed",marginTop:"64px",left:0,top:0,bottom:0,zIndex:100},children:(0,i.jsx)(k,{activeMenu:u,activeDropdown:m})})]}),(0,i.jsx)(F,{className:(0,_.cn)("min-h-full",p&&"px-3 py-5 md:p-9"),children:(0,i.jsx)("div",{className:(0,_.cn)(x&&"rounded-lg bg-white p-8 shadow-sm",f),children:t})})]})]})})}},5409:function(e,t,n){"use strict";n.d(t,{J:function(){return a}});var i=n(15989),s=n(39771),l=n(91340);let r=i.Z.create({baseURL:s.T5+"/api",headers:{"Content-Type":"application/json"},withCredentials:!0});r.interceptors.request.use(e=>{if((0,l.rD)()){let t=(0,l.Zd)();t&&(e.headers=e.headers||{},e.headers["x-session-id"]=t)}else e.headers&&e.headers["x-session-id"]&&delete e.headers["x-session-id"];return e});let a=i.Z.create({baseURL:s.T5+"/api",headers:{"Content-Type":"multipart/form-data"},maxContentLength:1/0,maxBodyLength:1/0,withCredentials:!0});t.Z=r},85304:function(e,t,n){"use strict";n.d(t,{H:function(){return h},a:function(){return p}});
1var i=n(52676),s=n(75271),l=n(76517),r=n(73414),a=n(71030),o=n(83214),c=n(62581),d=n(69504),u=n(91340);let m=(0,s.createContext)(null),h=e=>{let{children:t,user:n}=e,h=(0,r.useRouter)(),{mutate:p}=(0,a.D)({mutationFn:d.kS,onError:e=>l.Am.error((0,o._g)(e)),onSuccess:()=>{h.push(c.Z.LOGIN)}});return(0,s.useEffect)(()=>{n?(0,u.hv)():(0,u.wN)()},[n]),(0,i.jsx)(m.Provider,{value:{user:n,logout:p},children:t})},p=()=>{let e=(0,s.useContext)(m);if(!e)throw Error("useAuth must be used within a AuthProvider");return e}},1809:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSP:function(){return es},default:function(){return el}});var i=n(52676),s=n(33561),l=n(69834),r=n(71030),a=n(9059),o=n(76517),c=n(49810),d=n(75271),u=n(56220),m=n(21844),h=n(4948),p=n(88463),x=n(18060),f=n(78051),g=n(99508),v=n(29350),j=n(77471),Z=n(3833),N=n(58929),y=n(91709),A=n(78672),E=n(68734),b=n(39649),C=n(79406),w=n(77894),I=n(52043),R=n.n(I),S=n(6898),D=n(2194),O=n(94799),P=n(19575),T=n(70569),k=n(72818),_=n(27026),M=n.n(_),F=n(46976),U=n(72626),L=n(39936),V=n(9482),G=n(62581),z=n(94170),B=n(57722);let H=e=>e.toLowerCase().replace(/[_-]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),W={PENDING:"gold",PROCESSING:"green",SHIPPED:"blue",DELIVERED:"cyan",COMPLETED:"green",CANCELLED:"red",PAYMENT_FAILED:"red",REFUND_REQUESTED:"orange",REFUNDED:"purple",EXPIRED:"red"},Y=e=>{var t;return null!==(t=W[e])&&void 0!==t?t:"default"};var q=e=>{let{status:t}=e;return(0,i.jsx)(B.Z,{color:Y(t),children:H(t)})};let{Title:K,Text:Q}=u.default,{TextArea:X}=m.default,{Option:J}=h.default,{RangePicker:$}=p.default,ee=e=>{let t=[];switch(e.discountType){case"PERCENTAGE":t.push("".concat(e.percentOff||0,"% off order")),e.maxDiscount&&t.push("(max RM".concat(e.maxDiscount.toFixed(2),")"));break;case"FIXED":t.push("RM".concat((e.amountOff||0).toFixed(2)," off order"));break;case"FREE_SHIPPING":t.push(e.shippingMaxDiscount?"Free shipping (up to RM".concat(e.shippingMaxDiscount.toFixed(2),")"):"Free shipping")}return e.minSubtotal&&e.minSubtotal>0&&t.push("min spend RM".concat(e.minSubtotal.toFixed(2))),e.individualUseOnly&&t.pu
1sh("individual use only"),e.startsAt&&t.push("from ".concat(e.startsAt.format("YYYY-MM-DD HH:mm"))),e.endsAt&&t.push("until ".concat(e.endsAt.format("YYYY-MM-DD HH:mm"))),t.push(e.active?"(active)":"(inactive)"),t.join(" ⢠")},et=()=>(0,i.jsx)("span",{className:"inline-flex items-center",children:(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)("path",{d:"M12 3l7 4v5c0 5-3.5 9-7 9s-7-4-7-9V7l7-4z",stroke:"#1677ff",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})});var en=e=>{var t,n;let{coupon:s,onSubmit:r,saving:a}=e,[o]=x.Z.useForm(),[c,u]=(0,d.useState)(""),[p,I]=(0,d.useState)(!1),[_,B]=(0,d.useState)(1),[H,W]=(0,d.useState)(10),Y=x.Z.useWatch("startsAt",o),en=x.Z.useWatch("endsAt",o),ei=(0,l.a)({queryKey:["category","options"],queryFn:U.PA,select:e=>e.data}),es=(0,l.a)({queryKey:["coupon","redemptions",null==s?void 0:s.refId,_,H],queryFn:async()=>(null==s?void 0:s.refId)?(await (0,V.S8)({couponId:s.refId,page:_,pageSize:H,sortField:"createdAt",sortOrder:"desc"})).data:{total:0,page:1,rows:[]},enabled:p&&!!(null==s?void 0:s.refId)}),el=(0,d.useMemo)(()=>/^[A-Z0-9-]{6,24}$/i,[]),er=(0,d.useMemo)(()=>({code:"",discountType:"PERCENTAGE",includeProducts:[],includeCategories:[],active:!0,isPublic:!1,individualUseOnly:!0}),[]),ea=(0,d.useCallback)(async e=>{try{let{rows:t=[]}=(await (0,L.jw)({page:1,pageSize:10,search:e,sortField:"createdAt",sortOrder:z.As.DESC})).data;return t.map(e=>({label:e.name,value:e.refId,key:e.refId}))}catch(e){return console.error("Failed to load products",e),[]}},[]),eo=(0,d.useCallback)(e=>ee(e),[]);return(0,d.useEffect)(()=>{u(eo(o.getFieldsValue()))},[Y,en,eo,o]),(0,d.useEffect)(()=>{s||(o.resetFields(),o.setFieldsValue(er),u(""))},[s,o,er]),(0,d.useEffect)(()=>{var e,t,n,i,l,r,a,c;if(!s)return;let d={code:s.code,title:s.title||"",description:s.description||"",discountType:s.discountType,percentOff:null!==(e=s.percentOff)&&void 0!==e?e:void 0,amountOff:null!==(t=s.amountOff)&&void 0!==t?t:void 0,maxDiscount:null!==(n=s.percentMaxDiscount)&&void 0!==n?n:void 0,shippingMaxDiscount:null!==(i=s.shippingMaxDiscount)&&void 0!==i?i:void 0,minSubtotal:null!==(l=s.minSubtotal)&&void 0!==l?l:void 0,includeProducts:s.includeProducts.map(e=>({label:e.name,value:e.refId,key:e.refId})),includeCategories:s.includeCategories.map(e=>e.refId),usageLimitTotal:null!==(r=s.usageLimitTotal)&&void 0!==r?r:void 0,usageLimitPerCustomer:null!==(a=s.usageLimitPerCustomer)&&void 0!==a?a:void 0,startsAt:s.startsAt?R()(s.startsAt):void 0,endsAt:s.endsAt?R()(s.endsAt):void 0,active:s.active,isPublic:null!==(c=s.isPublic)&&void 0!==c&&c,individualUseOnly:s.individualUseOnly};o.setFieldsValue(d),u(ee(d))},[s,o]),(0,i.jsxs)("div",{className:"px-4 mx-auto max-w-7xl sm:px-6 lg:px-8",children:[(0,i.jsxs)("div",{className:"flex flex-col gap-4 mb-6 sm:flex-row sm:items-center sm:justify-between",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)(K,{level:2,className:"mb-2",children:s?"Edit Coupon":"Create Coupon"}),c&&(0,i.jsxs)("div",{className:"flex flex-col gap-2 text-sm text-gray-600 sm:flex-row sm:items-center",children:[(0,i.jsx)(Q,{className:"flex-shrink-0",children:"Summary:"}),(0,i.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,i.jsx)(Q,{code:!0,className:"text-xs",children:c}),(0,i.jsx)(f.ZP,{type:"text",size:"small",icon:(0,i.jsx)(S.Z,{size:12}),onClick:()=>{c&&"undefined"!=typeof navigator&&navigator.clipboard.writeText(c)}})]})]})]}),(0,i.jsxs)(g.Z,{children:[(0,i.jsx)(f.ZP,{icon:(0,i.jsx)(D.Z,{size:16}),disabled:!(null==s?void 0:s.refId),onClick:()=>I(!0),children:"View Redemption"}),(0,i.jsx)(f.ZP,{type:"primary",icon:(0,i.jsx)(O.Z,{size:16}),loading:a,onClick:()=>o.submit(),children:"Save Coupon"})]})]}),(0,i.jsx)(x.Z,{form:o,layout:"vertical",initialValues:er,onFinish:e=>{var t,n,i,s,l,a,o,c;r({code:e.code.trim().toUpperCase(),title:e.title||"",description:e.description||"",discountType:e.discountType,percentOff:null!==(n=e.percentOff)&&void 0!==n?n:null,percentMaxDiscount:null!==(i=e.maxDiscount)&&void 0!==i?i:null,amountOff:null!==(s=e.amountOff)&&void 0!==s?s:null,
1shippingMaxDiscount:null!==(l=e.shippingMaxDiscount)&&void 0!==l?l:null,minSubtotal:null!==(a=e.minSubtotal)&&void 0!==a?a:null,usageLimitTotal:null!==(o=e.usageLimitTotal)&&void 0!==o?o:null,usageLimitPerCustomer:null!==(c=e.usageLimitPerCustomer)&&void 0!==c?c:null,startsAt:e.startsAt?e.startsAt.toISOString():null,endsAt:e.endsAt?e.endsAt.toISOString():null,active:e.active,isPublic:e.isPublic,individualUseOnly:"FREE_SHIPPING"!==e.discountType&&e.individualUseOnly,includeProducts:(null===(t=e.includeProducts)||void 0===t?void 0:t.map(e=>e.value))||[],includeCategories:e.includeCategories||[]})},onValuesChange:(e,t)=>{u(eo(t))},autoComplete:"off",children:(0,i.jsxs)(v.Z,{gutter:[24,24],children:[(0,i.jsxs)(j.Z,{xs:24,lg:16,children:[(0,i.jsxs)(Z.Z,{title:"Basic Information",className:"!mb-6",children:[(0,i.jsxs)(v.Z,{gutter:16,children:[(0,i.jsx)(j.Z,{xs:24,sm:14,children:(0,i.jsx)(x.Z.Item,{name:"code",label:"Coupon Code",rules:[{required:!0,message:"Please enter a coupon code"},{pattern:el,message:"6-24 chars, letters/numbers/dashes"}],children:(0,i.jsx)(m.default,{placeholder:"e.g., SAVE-10",onChange:e=>o.setFieldsValue({code:e.target.value.toUpperCase()})})})}),(0,i.jsx)(j.Z,{xs:24,sm:10,children:(0,i.jsx)(x.Z.Item,{label:" ",colon:!1,children:(0,i.jsx)(f.ZP,{onClick:()=>{let e=()=>Math.random().toString(36).slice(2,6).toUpperCase(),t="".concat(e(),"-").concat(e(),"-").concat(e());o.setFieldsValue({code:t})},icon:(0,i.jsx)(et,{}),children:"Generate Code"})})})]}),(0,i.jsx)(x.Z.Item,{name:"title",label:"Title",children:(0,i.jsx)(m.default,{placeholder:"Internal title (optional)"})}),(0,i.jsx)(x.Z.Item,{name:"description",label:"Description",children:(0,i.jsx)(X,{rows:3,placeholder:"Description for admins or customers",showCount:!0,maxLength:160})})]}),(0,i.jsxs)(Z.Z,{title:"Discount",className:"!mb-6",children:[(0,i.jsx)(x.Z.Item,{name:"discountType",label:"Discount Type",rules:[{required:!0}],children:(0,i.jsxs)(h.default,{size:"large",className:"!h-14",children:[(0,i.jsx)(J,{value:"PERCENTAGE",children:(0,i.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,i.jsx)(P.Z,{size:16})," ",(0,i.jsx)("div",{children:"Percentage off"})]})}),(0,i.jsx)(J,{value:"FIXED",children:(0,i.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,i.jsx)(T.Z,{size:16})," ",(0,i.jsx)("div",{children:"Fixed amount off"})]})}),(0,i.jsx)(J,{value:"FREE_SHIPPING",children:(0,i.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,i.jsx)(k.Z,{size:16})," ",(0,i.jsx)("div",{children:"Free shipping"})]})})]})}),(0,i.jsx)(x.Z.Item,{shouldUpdate:(e,t)=>e.discountType!==t.discountType,children:e=>{let{getFieldValue:t}=e,n=t("discountType");return"PERCENTAGE"===n?(0,i.jsxs)(v.Z,{gutter:8,children:[(0,i.jsx)(j.Z,{span:12,children:(0,i.jsx)(x.Z.Item,{name:"percentOff",label:"Percent Off",rules:[{required:!0}],children:(0,i.jsx)(N.Z,{min:1,max:100,step:1,addonAfter:"%",className:"!w-full"})})}),(0,i.jsx)(j.Z,{span:12,children:(0,i.jsx)(x.Z.Item,{name:"maxDiscount",label:"Max Discount (RM)",children:(0,i.jsx)(N.Z,{min:0,step:.01,precision:2,className:"!w-full"})})})]}):"FIXED"===n?(0,i.jsx)(x.Z.Item,{name:"amountOff",label:"Amount Off (RM)",rules:[{required:!0}],children:(0,i.jsx)(N.Z,{min:0,step:.01,precision:2,className:"!w-full",placeholder:"0.00"})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(x.Z.Item,{name:"shippingMaxDiscount",label:"Max shipping discount (RM)",rules:[{required:!0,message:"Enter the maximum shipping discount"}],children:(0,i.jsx)(N.Z,{min:0,step:.01,precision:2,className:"!w-full",placeholder:"0.00"})}),(0,i.jsx)(y.Z,{type:"info",showIcon:!0,message:"Free shipping coupon",description:"Waives the shipping charge up to the max discount above. Free shipping vouchers always stack with other vouchers (max one per order)."})]})}})]}),(0,i.jsx)(Z.Z,{title:"Restriction & Limits",className:"!mb-6",children:(0,i.jsxs)(v.Z,{gutter:16,children:[(0,i.jsx)(j.Z,{xs:24,children:(0,i.jsx)(x.Z.Item,{name:"minSubtotal",label:"Min Subtotal (RM)",children:(0,i.jsx)(N.Z,{min:0,step:.01,precision:2,className:"!w-full",placeholder:"0.00"})})}),(0,i.jsx)(j.Z,{xs:24,sm:12,children:(0,i.jsx)(x.Z.Item,{name:"usageLimitTotal",label:"Usage limit per coupon",children:(0,i.jsx)(N.Z,{min:0,className:"!w-full",placeholder:"Unlimited if empty"})})}),(0,i.jsx)(j.Z,{xs:24,sm:12,children:(0,i.jsx)(x.Z.Item,{name:"usageLimitPerCustomer",label:"Usage limit per customer",children:(0,i.jsx)(N.Z,{min:0,className:"!w-full",placeholder:"Unlimited if empty"})})}),(0,i.jsx)(j.Z,{xs:24,children:(0,i.jsx)(x.Z.Item,{noStyle:!0,shouldUpdate:(e,t)=>
1e.discountType!==t.discountType,children:e=>{let{getFieldValue:t}=e;return"FREE_SHIPPING"===t("discountType")?null:(0,i.jsx)(x.Z.Item,{name:"individualUseOnly",label:"Individual use only",valuePropName:"checked",children:(0,i.jsx)(A.Z,{children:"Check this box if the coupon cannot be used in conjunction with other coupons."})})}})})]})}),(0,i.jsx)(Z.Z,{title:"Targeting",className:"!mb-6",children:(0,i.jsxs)(v.Z,{gutter:16,children:[(0,i.jsx)(j.Z,{xs:24,sm:12,children:(0,i.jsx)(x.Z.Item,{name:"includeProducts",label:"Include products",children:(0,i.jsx)(F.Z,{mode:"multiple",allowClear:!0,placeholder:"Search product name",fetchOptions:ea})})}),(0,i.jsx)(j.Z,{xs:24,sm:12,children:(0,i.jsx)(x.Z.Item,{name:"includeCategories",label:"Include categories",children:(0,i.jsx)(E.Z,{showSearch:!0,treeNodeFilterProp:"label",treeData:ei.data,treeLine:!0,treeDefaultExpandAll:!0,multiple:!0,treeCheckable:!0,showCheckedStrategy:E.Z.SHOW_CHILD,allowClear:!0,placeholder:"Select categories",loading:ei.isLoading,disabled:!ei.data})})})]})})]}),(0,i.jsx)(j.Z,{xs:24,lg:8,children:(0,i.jsxs)(Z.Z,{title:"Schedule & Status",className:"!mb-6",children:[(0,i.jsx)(y.Z,{message:"Schedule when this coupon is valid",description:"Leave empty for immediate and indefinite availability.",type:"info",showIcon:!0,className:"!mb-4"}),(0,i.jsx)(x.Z.Item,{label:"Validity",children:(0,i.jsx)($,{showTime:!0,className:"w-full",onChange:e=>{if(e){let[t,n]=e;o.setFieldsValue({startsAt:null!=t?t:void 0,endsAt:null!=n?n:void 0})}else o.setFieldsValue({startsAt:void 0,endsAt:void 0})},allowEmpty:[!0,!0],placeholder:["Start","End"],value:[null!=Y?Y:null,null!=en?en:null]})}),(0,i.jsx)(x.Z.Item,{name:"startsAt",hidden:!0,children:(0,i.jsx)(m.default,{})}),(0,i.jsx)(x.Z.Item,{name:"endsAt",hidden:!0,children:(0,i.jsx)(m.default,{})}),(0,i.jsxs)("div",{className:"flex gap-2 items-center h-8",children:[(0,i.jsx)(x.Z.Item,{name:"active",valuePropName:"checked",className:"!mb-0",children:(0,i.jsx)(b.Z,{})}),(0,i.jsx)("p",{className:"mb-0",children:"Active (can be redeemed)"})]}),(0,i.jsxs)("div",{className:"flex gap-2 items-center h-8 mt-3",children:[(0,i.jsx)(x.Z.Item,{name:"isPublic",valuePropName:"checked",className:"!mb-0",children:(0,i.jsx)(b.Z,{})}),(0,i.jsx)("p",{className:"mb-0",children:"Public Listed (visible to customers)"})]})]})})]})}),(0,i.jsx)(C.Z,{title:"Coupon Redemptions",open:p,onCancel:()=>I(!1),footer:null,width:820,destroyOnClose:!0,children:(0,i.jsx)(w.Z,{rowKey:e=>e.orderRefId,loading:es.isFetching,dataSource:(null===(t=es.data)||void 0===t?void 0:t.rows)||[],pagination:{current:_,pageSize:H,showSizeChanger:!0,pageSizeOptions:[10,25,50,100],total:(null===(n=es.data)||void 0===n?void 0:n.total)||0},onChange:e=>{B(e.current||1),W(e.pageSize||10)},columns:[{title:"Customer Name",dataIndex:"customerName"},{title:"Order ID",dataIndex:"orderId",render:(e,t)=>(0,i.jsx)(M(),{href:"".concat(G.Z.ORDER,"/").concat(t.orderRefId),className:"font-semibold",children:e})},{title:"Order Status",dataIndex:"orderStatus",render:e=>(0,i.jsx)(q,{status:e})}]})})]})},ei=n(83214),es=!0,el=e=>{let{user:t}=e,{couponId:n}=(0,s.useRouter)().query,d=(0,l.a)({queryKey:["coupon",n],queryFn:()=>(0,V.DE)(n),enabled:!!n,select:e=>e.data}),u=(0,r.D)({mutationFn:e=>(0,V.CG)(n,e)});return(0,i.jsx)(c.Z,{user:t,card:!1,activeMenu:["coupon"],children:d.isPending?(0,i.jsx)("div",{className:"flex justify-center py-20",children:(0,i.jsx)(a.Z,{size:"large"})}):(0,i.jsx)(en,{coupon:d.data,onSubmit:e=>{o.Am.promise(u.mutateAsync(e),{pending:"Saving coupon...",success:"Coupon saved successfully",error:{render(e){let{data:t}=e;return(0,ei._g)(t)}}})},saving:u.isPending})})}},69504:function(e,t,n){"use strict";n.d(t,{A9:function(){return c},IU:function(){return l},c0:function(){return o},kS:function(){return r},o9:function(){return a},x4:function(){return s}});var i=n(5409);let s=async e=>i.Z.post("/auth/login",e),l=async e=>i.Z.post("/auth/signup",e),r=async()=>i.Z.post("/auth/logout"),a=async e=>i.Z.post("/auth/forget-password",e),o=async e=>i.Z.post("/auth/password-reset/confirm",e),c=async e=>i.Z.post("/auth/verify-user",e)},9482:function(e,t,n){"use strict";n.d(t,{$T:function(){return c},CG:function(){return a},DE:function(){return l},KV:function(){return s},S8:function(){return d},VW:function(){return o},lk:function(){return r}});var i=n(5409);let s=e=>i.Z.get("/admin/coupon",{params:e}),l=e=>i.Z.get("/admin/coupon/".concat(e)),r=e=>i.Z.post("/admin/coupon",e),a=(e,t)=>i.Z.put("/admin/coupon/".concat(e),t),o=e=>i.Z.delete("/admin/coupon/".concat(e)),c=(e,t)=>i.Z.put("/admin/coupon/".concat(e,"/status"),t),d=e=>i.Z.get("/admin/coupon/redemptions",{params:e})},72626:function(e,t,n){"use strict";n.d(t,{PA:function(){return s},Yc:function(){return l},lq:function(){return r},vd:function(){return a}});var i=n(5409);let s=()=>i.Z.get("admin/option/category"),l=()=>i.Z.get("option/categories/tree"),r=e=>i.Z.get("option/categories/children",{params:e?{parentId:e}:void 0}),a=(e,t)=>i.Z.get("option/products",{params:{productType:e,search:t}})},39936:function(e,t,n){"use strict";n.d(t,{Bz:function(){return s},Ir:function(){return u},Lv:function(){return d},gk:function(){return a},iT:function(){return r},jw:function(){return l},nM:function(){return c},ry:function(){return o}});var i=n(5409);let s=e=>i.Z.get("/products",{params:e}),l=e=>i.Z.get("/admin/product",{params:e}),r=e=>{let{refId:t,isPublished:n}=e;return i.Z.get("/products/".concat(t),{params:{isPublished:n}})},a=e=>i.Z.get("/admin/product/".concat(e.id)),o=e=>i.Z.post("/admin/product",e),c=e=>i.Z.put("/admin/product/".concat(e.id),e),d=e=>i.Z.put("/admin/product/".concat(e.id,"/status"),e),u=e=>i.Z.delete("/admin/product/".concat(e.id))},62581:function(e,t,n){"use strict";var i,s;n.d(t,{Z:function(){return i}}),(s=i||(i={})).LOGIN="/login",s.ADMIN_DASHBOARD="/admin/dashboard",s.HOME="/",s.USER="/admin/user",s.ROLE="/admin/role",s.NEW_ROLE="/admin/role/new",s.SYSTEM_CONFIG="/admin/system-config",s.PRODUCT="/admin/product",s.BLOG="/admin/blog",s.ORDER="/admin/order",s.ABANDONMENT="/admin/abandonment",s.WARRANTY_REGISTER="/admin/warranty-register",s.WARRANTY_CLAIM="/admin/warranty-claim",s.COUPON="/admin/coupon",s.OUR_PARTNERS="/admin/our-partners",s.REVIEW="/admin/review",s.CONTENT_BANNER="/admin/content/banners",s.CONTENT_REVIEW="/admin/content/reviews",s.CONTENT_VIDEO="/admin/content/videos",s.CONTENT_POPUP="/admin/content/popups"},94170:function(e,t,n){"use strict";var i,s,l,r,a,o,c,d,u,m;n.d(t,{As:function(){return l},fH:function(){return r},hY:function(){return s}}),(o=i||(i={})).EN="en",o.ZH_HK="zh-HK",(c=s||(s={})).LOGIN="login",c.FORGET_PASSWORD="forget_password",c.SIGNUP="signup",(d=l||(l={})).ASC="asc",d.DESC="desc",(u=r||(r={})).VERIFIED="VERIFIED",u.PENDING_FOR_VERIFICATION="PENDING_FOR_VERIFICATION",u.VERIFICATION_EXPIRED="VERIFICATION_EXPIRED",(m=a||(a={})).ADMIN="Admin",m.CUSTOMER="Customer"},26134:function(e,t,n){"use strict";n.d(t,{f:function(){return i}});let i=(e,t,n)=>void 0===t?void 0!==n?n:Array.isArray(t)?[]:{}:e?t:void 0!==n?n:Array.isArray(t)?[]:{}},83214:function(e,t,n){"use strict";n.d(t,{_g:function(){return l},i$:function(){return r}});var i=n(52043),s=n.n(i);let l=e=>{if("response"in e){var t,n;return null===(n=e.response)||void 0===n?void 0:null===(t=n.data)||void 0===t?void 0:t.message}return e.message},r=(e,t)=>{let n=s()(e);return e&&n.isValid()?s()(e).format("DD MMM YYYY, hh:mm a"):t||null}},91340:function(e,t,n){"use strict";n.d(t,{Zd:function(){return l},hv:function(){return a},rD:function(){return o},wN:function(){return r}});let i="session_id",s="session_header_enabled";function l(){try{let e=localStorage.getItem(i);if(e&&e.length>0)return e;let t="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():c();return localStorage.setItem(i,t),t}catch(e){return c()}}function r(){try{localStorage.setItem(s,"1")}catch(e){}}function a(){try{localStorage.setItem(s,"0"),localStorage.removeItem(i)}catch(e){}}function o(){try{return"1"===localStorage.getItem(s)}catch(e){return!1}}function c(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}},function(e){e.O(0,[5989,4237,7610,8174,9834,8051,9513,4540,928,4298,4190,6631,6220,9575,7444,9406,150,1887,5934,8060,9059,8672,1795,8374,7894,7645,8463,7206,8929,8734,9185,2888,9774,179],function(){return e(e.s=18014)}),_N_E=e.O()}]);
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.