1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4618,9810],{77397:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/abandonment",function(){return a(15849)}])},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}},49810:function(e,t,a){"use strict";a.d(t,{Z:function(){return z}});var n=a(52676),r=a(75271),l=a(46035),s=a(33022),i=a(40150),d=a(28994),o=a(85304),c=a(4180),u=a(16624),m=a(27026),h=a.n(m),x=a(78051),g=a(98807),v=a(15036),p=a(32623),b=a.n(p);let y=e=>{let{isMobile:t,isDrawerOpen:a,setIsDrawerOpen:r,collapsed:l,setCollapsed:s,fullName:i}=e,{logout:d}=(0,o.a)();return(0,n.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,n.jsxs)("div",{className:"flex items-center h-full gap-2",children:[(0,n.jsx)(x.ZP,{onClick:()=>{t?r(!a):s(!l)},"aria-controls":"sidebar",className:"flex items-center justify-center w-8 px-1 py-0",icon:(0,n.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,n.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,n.jsx)(h(),{href:"/",className:"h-full",children:(0,n.jsx)(b(),{src:c.Z,alt:"Samugiken",className:"w-[100%] h-[60px]"})})]}),(0,n.jsx)("div",{className:"flex items-center justify-center",children:(0,n.jsx)("div",{className:"flex items-center justify-center col-row",children:(0,n.jsx)(g.Z,{arrow:!0,placement:"bottomRight",overlayClassName:"shadow-[rgba(0,0,0,0.35)_0_5px_15px] rounded-xl top-10",trigger:["click"],dropdownRender:()=>(0,n.jsxs)("div",{className:"flex flex-col p-3 bg-white rounded-md shadow-md gap-y-1",children:[(0,n.jsx)(h(),{href:"/my-profile",className:"font-medium leading-[normal] text-primary hover:text-primary",children:(0,n.jsx)("div",{className:"cursor-pointer rounded-[4px] p-3 duration-100 hover:bg-primary/10",children:"My Profile"})}),(0,n.jsx)(v.Z,{className:"!my-2"}),(0,n.jsx)(x.ZP,{type:"primary",danger:!0,onClick:d,children:"Logout"})]}),children:(0,n.jsxs)("div",{className:"flex items-center cursor-pointer gap-x-3",children:[(0,n.jsx)("div",{className:"flex items-center gap-2 ml-2",children:(0,n.jsx)("span",{className:"font-semibold",children:i})}),(0,n.jsx)(u.ZP,{name:i,round:!0,maxInitials:1,size:"35",textSizeRatio:2,fgColor:"white",color:"black"})]})})})})]})};var f=a(73640),N=a(62581),j=a(26134),w=a(1952),A=a(7144),C=a(42439),Z=a(88483),R=a(42720),k=a(43146),E=a(57221),S=a(84176),I=a(54216),O=a(12285),D=a(20188),T=a(19254);let _=e=>{var t,a,l,s,i,d,c,u,m,x,g;let{activeMenu:v,activeDropdown:p}=e,[b,y]=(0,r.useState)(v),{user:_}=(0,o.a)(),P=null==_?void 0:_.role.accessRights,F=e=>{y([e])},M=[{key:"dashboard",label:(0,n.jsx)(h(),{href:N.Z.ADMIN_DASHBOARD,children:"Dashboard"}),icon:(0,n.jsx)(w.Z,{width:16,height:16}),onClick:()=>F("dashboard")},...(0,j.f)(null==P?void 0:null===(t=P.PRODUCT)||void 0===t?void 0:t.READ,[{key:"product",label:(0,n.jsx)(h(),{href:N.Z.PRODUCT,children:"Product"}),icon:(0,n.jsx)(A.Z,{width:16,height:16}),onClick:()=>F("product")}]),...(0,j.f)(null==P?void 0:null===(a=P.REVIEW)||void 0===a?void 0:a.READ,[{key:"review",label:(0,n.jsx)(h(),{href:N.Z.REVIEW,children:"Reviews"}),icon:(0,n.jsx)(C.Z,{width:16,height:16}),onClick:()=>F("review")}]),...(0,j.f)(null==P?void 0:null===(l=P.WARRANTY)||void 0===l?void 0:l.READ,[{key:"warranty",label:"Warranty",icon:(0,n.jsx)(T.Z,{width:16,height:16}),children:[{key:"warranty-register",label:(0,n.jsx)(h(),{href:N.Z.WARRANTY_REGISTER,children:"Warranty Register"}),onClick:()=>F("warranty-register")},{key:"warranty-claim",label:(0,n.jsx)(h(),{href:N.Z.WARRANTY_CLAIM,children:"Warranty Claim"}),onClick:()=>F("warranty-claim")}]}]),...(0,j.f)(null==P?void 0:null===(s=P.COUPON)||void 0===s?void 0:s.READ,[{key:"c
1oupon",label:(0,n.jsx)(h(),{href:N.Z.COUPON,children:"Coupon"}),icon:(0,n.jsx)(Z.Z,{width:16,height:16}),onClick:()=>F("coupon")}]),...(0,j.f)(null==P?void 0:null===(i=P.ORDER)||void 0===i?void 0:i.READ,[{key:"order",label:(0,n.jsx)(h(),{href:N.Z.ORDER,children:"Orders"}),icon:(0,n.jsx)(T.Z,{width:16,height:16}),onClick:()=>F("order")},{key:"abandonment",label:(0,n.jsx)(h(),{href:N.Z.ABANDONMENT,children:"Abandonment"}),icon:(0,n.jsx)(R.Z,{width:16,height:16}),onClick:()=>F("abandonment")}]),...(0,j.f)(null==P?void 0:null===(d=P.BLOG)||void 0===d?void 0:d.READ,[{key:"blog",label:(0,n.jsx)(h(),{href:N.Z.BLOG,children:"Blog"}),icon:(0,n.jsx)(k.Z,{width:16,height:16}),onClick:()=>F("blog")}]),...(0,j.f)(null==P?void 0:null===(c=P.OUR_PARTNERS)||void 0===c?void 0:c.READ,[{key:"our-partners",label:(0,n.jsx)(h(),{href:N.Z.OUR_PARTNERS,children:"Our Partners"}),icon:(0,n.jsx)(E.Z,{width:16,height:16}),onClick:()=>F("our-partners")}]),...(0,j.f)(null==P?void 0:null===(u=P.CONTENT_MANAGEMENT)||void 0===u?void 0:u.READ,[{key:"content",label:"Content Management",icon:(0,n.jsx)(S.Z,{width:16,height:16}),children:[{key:"content-banners",label:(0,n.jsx)(h(),{href:N.Z.CONTENT_BANNER,children:"Banners"}),onClick:()=>F("content-banners")},{key:"content-reviews",label:(0,n.jsx)(h(),{href:N.Z.CONTENT_REVIEW,children:"Customer Reviews"}),onClick:()=>F("content-reviews")},{key:"content-videos",label:(0,n.jsx)(h(),{href:N.Z.CONTENT_VIDEO,children:"Product Videos"}),onClick:()=>F("content-videos")},{key:"content-popups",label:(0,n.jsx)(h(),{href:N.Z.CONTENT_POPUP,children:"Popups"}),onClick:()=>F("content-popups")}]}]),...(0,j.f)(null==P?void 0:null===(m=P.USER)||void 0===m?void 0:m.READ,[{key:"user",label:(0,n.jsx)(h(),{href:N.Z.USER,children:"User"}),icon:(0,n.jsx)(I.Z,{width:16,height:16}),onClick:()=>F("user")}]),...(0,j.f)(null==P?void 0:null===(x=P.ROLE)||void 0===x?void 0:x.READ,[{key:"role",label:(0,n.jsx)(h(),{href:N.Z.ROLE,children:"Role"}),icon:(0,n.jsx)(O.Z,{width:16,height:16}),onClick:()=>F("role")}]),...(0,j.f)(null==P?void 0:null===(g=P["SYSTEM_CONFIG/CATEGORY"])||void 0===g?void 0:g.READ,[{key:"system-config",label:(0,n.jsx)(h(),{href:N.Z.SYSTEM_CONFIG,children:"System Config"}),icon:(0,n.jsx)(D.Z,{width:16,height:16}),onClick:()=>F("category")}])];return(0,n.jsx)(f.Z,{theme:"light",mode:"inline",defaultOpenKeys:p||[],defaultSelectedKeys:b,items:M,className:"h-full font-medium"})};var P=a(63309);let{Sider:F,Content:M}=s.default;var z=e=>{let{children:t,user:a,activeMenu:u=[],activeDropdown:m=[],seoConfig:h,withPadding:x=!0,card:g=!0,contentClassName:v}=e,p=(0,d.ac)("(max-width: 768px)"),[f,N]=(0,r.useState)(!1),[j,w]=(0,r.useState)(!1);return(0,n.jsx)(o.H,{user:a,children:(0,n.jsxs)(s.default,{className:"!min-h-screen",children:[(0,n.jsx)(l.PB,{...h}),(0,n.jsx)(y,{isMobile:p,isDrawerOpen:j,setIsDrawerOpen:w,collapsed:f,setCollapsed:N,fullName:(null==a?void 0:a.firstName)+" "+(null==a?void 0:a.lastName)||""}),(0,n.jsx)("div",{className:"mt-[64px]"}),(0,n.jsxs)(s.default,{hasSider:!0,style:{minHeight:"100%"},children:[p?(0,n.jsx)(i.Z,{placement:"left",open:j,onClose:()=>w(!1),width:"250px",styles:{body:{padding:0}},closable:!1,children:(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("div",{className:"py-2",children:(0,n.jsx)(b(),{src:c.Z,alt:"Samugiken",className:"w-[100%] h-[70px]"})}),(0,n.jsx)(_,{activeMenu:u,activeDropdown:m})]})}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:f?"duration-200 ml-[80px]":"duration-200 ml-[250px]"}),(0,n.jsx)(F,{trigger:null,collapsible:!0,collapsed:f,theme:"light",width:250,className:"hide-scrollbar",style:{overflow:"scroll",position:"fixed",marginTop:"64px",left:0,top:0,bottom:0,zIndex:100},children:(0,n.jsx)(_,{activeMenu:u,activeDropdown:m})})]}),(0,n.jsx)(M,{className:(0,P.cn)("min-h-full",x&&"px-3 py-5 md:p-9"),children:(0,n.jsx)("div",{className:(0,P.cn)(g&&"rounded-lg bg-white p-8 shadow-sm",v),children:t})})]})]})})}},5409:function(e,t,a){"use strict";a.d(t,{J:function(){return i}});var n=a(15989),r=a(39771),l=a(91340);let s=n.Z.create({baseURL:r.T5+"/api",headers:{"Content-Type":"application/json"},withCredentials:!0});s.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 i=n.Z.create({baseURL:r.T5+"/api",headers:{"Content-Type":"multipart/form-data"},maxContentLength:1/0,maxBodyLength:1/0,withCredentials:!0});t.Z=s},56346:function(e,t,a){"use strict";var n=a(75271),r=a(94170);t.Z=e=>
1{let[t,a]=(0,n.useState)({page:1,pageSize:10,total:0,sortOrder:r.As.DESC,sortField:"createdAt",...e});return[t,a,(e,t,n)=>{a(t=>{var a;return{...t,page:e.current||1,pageSize:e.pageSize||10,sortField:null!==(a=null==n?void 0:n.field)&&void 0!==a?a:null==t?void 0:t.sortField,sortOrder:"ascend"==n.order?r.As.ASC:n.order?r.As.DESC:t.sortOrder}})}]}},85304:function(e,t,a){"use strict";a.d(t,{H:function(){return h},a:function(){return x}});var n=a(52676),r=a(75271),l=a(76517),s=a(73414),i=a(71030),d=a(83214),o=a(62581),c=a(69504),u=a(91340);let m=(0,r.createContext)(null),h=e=>{let{children:t,user:a}=e,h=(0,s.useRouter)(),{mutate:x}=(0,i.D)({mutationFn:c.kS,onError:e=>l.Am.error((0,d._g)(e)),onSuccess:()=>{h.push(o.Z.LOGIN)}});return(0,r.useEffect)(()=>{a?(0,u.hv)():(0,u.wN)()},[a]),(0,n.jsx)(m.Provider,{value:{user:a,logout:x},children:t})},x=()=>{let e=(0,r.useContext)(m);if(!e)throw Error("useAuth must be used within a AuthProvider");return e}},15849:function(e,t,a){"use strict";a.r(t),a.d(t,{__N_SSP:function(){return K},default:function(){return q}});var n=a(52676),r=a(49810),l=a(47645),s=a(87927),i=a(69834),d=a(71030),o=a(45231),c=a(77894),u=a(4948),m=a(21844),h=a(78051),x=a(57722),g=a(27610),v=a(91709),p=a(76517),b=a(75271),y=a(56346),f=a(83214),N=a(5409);let j=()=>N.Z.get("/admin/abandonment/order-stats"),w=()=>N.Z.get("/admin/abandonment/cart-stats"),A=e=>N.Z.get("/admin/abandonment/orders",{params:e}),C=e=>N.Z.get("/admin/abandonment/carts",{params:e}),Z=e=>N.Z.post("/admin/abandonment/contact",e);var R=a(99508),k=a(63468),E=a(49727),S=a(54778),I=a(19544);let O=e=>{let{whatsapp:t,email:a,contacted:r,pending:l,onMarkContacted:s}=e,[i,d]=(0,b.useState)("");return(0,n.jsxs)(R.Z,{size:4,children:[t?(0,n.jsx)(g.Z,{title:"WhatsApp +".concat(t),children:(0,n.jsx)(h.ZP,{size:"small",type:"text",icon:(0,n.jsx)(E.Z,{className:"w-4 h-4 text-green-600"}),href:"https://wa.me/".concat(t),target:"_blank",rel:"noreferrer"})}):(0,n.jsx)(g.Z,{title:"No phone number on file",children:(0,n.jsx)(h.ZP,{size:"small",type:"text",disabled:!0,icon:(0,n.jsx)(S.Z,{className:"w-4 h-4"})})}),(0,n.jsx)(g.Z,{title:a,children:(0,n.jsx)(h.ZP,{size:"small",type:"text",icon:(0,n.jsx)(I.Z,{className:"w-4 h-4 text-blue-600"}),href:"mailto:".concat(a)})}),(0,n.jsx)(k.Z,{title:"Mark as contacted",description:(0,n.jsx)(m.default.TextArea,{rows:2,maxLength:500,placeholder:"Note (optional)",value:i,onChange:e=>d(e.target.value)}),okText:"Save",onConfirm:()=>{s(i.trim()||void 0),d("")},children:(0,n.jsx)(h.ZP,{size:"small",loading:l,children:r?"Log again":"Mark contacted"})})]})};var D=a(79406);let T=e=>"RM ".concat(Number(null!=e?e:0).toFixed(2)),_=e=>{let{open:t,onClose:a,title:r,subtitle:l,items:s}=e,i=s.reduce((e,t)=>e+t.quantity*t.unitPrice,0);return(0,n.jsxs)(D.Z,{open:t,onCancel:a,footer:null,width:720,title:r,children:[l?(0,n.jsx)("p",{className:"mt-0 mb-3 text-xs text-gray-500",children:l}):null,(0,n.jsx)(c.Z,{size:"small",rowKey:(e,t)=>String(t),dataSource:s,pagination:!1,columns:[{title:"Product",key:"product",render:(e,t)=>{var a;return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-medium",children:t.name}),(null===(a=t.variation)||void 0===a?void 0:a.length)?(0,n.jsx)("div",{className:"mt-1",children:t.variation.map((e,t)=>(0,n.jsxs)(x.Z,{className:"mb-1",children:[e.attribute?"".concat(e.attribute,": "):"",e.value]},t))}):(0,n.jsx)("div",{className:"text-xs text-gray-400",children:"No variation"})]})}},{title:"Qty",dataIndex:"quantity",width:70},{title:"Unit price",dataIndex:"unitPrice",width:120,render:e=>T(e)},{title:"Subtotal",key:"subtotal",width:120,render:(e,t)=>T(t.quantity*t.unitPrice)}],summary:()=>(0,n.jsxs)(c.Z.Summary.Row,{children:[(0,n.jsx)(c.Z.Summary.Cell,{index:0,colSpan:3,children:(0,n.jsx)("span",{className:"font-semibold",children:"Total"})}),(0,n.jsx)(c.Z.Summary.Cell,{index:1,children:(0,n.jsx)("span",{className:"font-semibold",children:T(i)})})]})})]})},P=e=>"RM ".concat(Number(null!=e?e:0).toFixed(2)),F={under1h:"Under 1 hour",under24h:"1 - 24 hours",under7d:"1 - 7 days",over7d:"Over 7 days"},M={under1h:"green",under24h:"blue",under7d:"orange",over7d:"default"},z=()=>{var e,t,a,r,l,s,N,j,A,R,k,E,S,I;let[D,T,z]=(0,y.Z)({sortField:"value"}),[L,U]=(0,b.useState)(""),[B,W]=(0,b.useState)("all"),[G,V]=(0,b.useState)(),[Y,K]=(0,b.useState)(null),q=(0,i.a)({queryKey:["admin","abandonment","cart-stats"],queryFn:async()=>(await w()).data}),H=(0,i.a)({queryKey:["admin","abandonment","carts",D,L,B,G],queryFn:async()=>(await C({page:D.page,pageSize:D.pageSize,sortField:D.sortField,sortOrder:D.sortOrder,search:L||void 0,contactStatus:B,bucket:G})).data}),Q=(0,d.D)({mutationFn:async e=>Z(e),onSuccess:()=>{p.Am.success("Logged as contacted"),H.refetch()},onError:e=>p.Am.error((0,f._g)(e))}),$=q.data,J=null!==(r=null==$?void 0:$.buckets.map(e=>({bucket:F[e.bucket],carts:e.carts,value:e.value})))&&void 0!==r?r:[],X=null!==(l=null==$?void 0:$.buckets.reduce((e,t)=>
1e+t.value,0))&&void 0!==l?l:0,ee=null!==(s=null==$?void 0:$.buckets.reduce((e,t)=>e+t.carts,0))&&void 0!==s?s:0,et=null!==(N=null==$?void 0:$.buckets.reduce((e,t)=>e+t.guestCarts,0))&&void 0!==N?N:0;return(0,n.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[(0,n.jsxs)("div",{className:"p-4 rounded-lg border bg-amber-50 border-amber-100",children:[(0,n.jsx)("div",{className:"text-xs font-semibold text-amber-800",children:"Sitting in carts now"}),(0,n.jsx)("div",{className:"mt-1 text-2xl font-bold text-amber-900",children:P(X)}),(0,n.jsxs)("div",{className:"mt-1 text-xs text-amber-700",children:[ee," carts"]})]}),(0,n.jsxs)("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[(0,n.jsx)("div",{className:"text-xs font-semibold text-gray-600",children:"Guest carts"}),(0,n.jsx)("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:et}),(0,n.jsx)("div",{className:"mt-1 text-xs text-gray-500",children:"No account â counted here, not callable"})]}),(0,n.jsxs)("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:[(0,n.jsx)("div",{className:"text-xs font-semibold text-gray-600",children:"Reachable carts"}),(0,n.jsx)("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:ee-et}),(0,n.jsx)("div",{className:"mt-1 text-xs text-gray-500",children:"Logged-in customers"})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-4 text-base font-semibold text-gray-800",children:"Carts by time since last touched"}),q.isError?(0,n.jsx)("div",{className:"py-12 text-sm text-center text-red-500",children:"Failed to load statistics."}):(0,n.jsx)(o.Z,{data:J,xField:"bucket",yField:"carts",height:280,style:{fill:"#e73042"}})]}),(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-3 text-base font-semibold text-gray-800",children:"Most wanted products sitting in carts"}),(0,n.jsx)(c.Z,{size:"small",rowKey:"productName",loading:q.isLoading,dataSource:null!==(j=null==$?void 0:$.topProducts)&&void 0!==j?j:[],pagination:!1,columns:[{title:"Product",dataIndex:"productName",ellipsis:!0},{title:"Qty",dataIndex:"quantity",width:70},{title:"Carts",dataIndex:"carts",width:80},{title:"Value",dataIndex:"value",width:120,render:e=>P(e)}]})]})]}),(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-3 justify-between items-center mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"m-0 text-base font-semibold text-gray-800",children:"Carts worth a nudge"}),(0,n.jsx)("p",{className:"mt-1 mb-0 text-xs text-gray-500",children:"Logged-in customers only, active in the last 30 days."})]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-3 items-center",children:[(0,n.jsx)(u.default,{allowClear:!0,placeholder:"All ages",className:"w-36",value:G,onChange:e=>{V(e),T(e=>({...e,page:1}))},options:Object.keys(F).map(e=>({value:e,label:F[e]}))}),(0,n.jsx)(m.default.Search,{allowClear:!0,placeholder:"Name or email",className:"w-56",onSearch:e=>{U(e),T(e=>({...e,page:1}))}}),(0,n.jsx)(u.default,{className:"w-40",value:B,onChange:e=>{W(e),T(e=>({...e,page:1}))},options:[{value:"all",label:"All"},{value:"uncontacted",label:"Not contacted"},{value:"contacted",label:"Contacted"}]})]})]}),(0,n.jsx)(c.Z,{rowKey:"cartRefId",size:"small",scroll:{x:1150},loading:H.isLoading,dataSource:null!==(A=null===(e=H.data)||void 0===e?void 0:e.rows)&&void 0!==A?A:[],onChange:z,rowClassName:e=>e.contacted?"opacity-50":"over7d"===e.bucket?"opacity-70":"",pagination:{current:null!==(R=null===(t=H.data)||void 0===t?void 0:t.page)&&void 0!==R?R:D.page,pageSize:D.pageSize,total:null!==(k=null===(a=H.data)||void 0===a?void 0:a.total)&&void 0!==k?k:0,showSizeChanger:!0,showTotal:(e,t)=>"".concat(t[0],"-").concat(t[1]," of ").concat(e," items")},columns:[{title:"Customer",key:"customer",render:(e,t)=>{var a;return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-medium",children:"".concat(t.firstName," ").concat(t.lastName).trim()||t.email}),(0,n.jsx)("div",{className:"text-xs text-gray-500",children:t.email}),(0,n.jsx)("div",{className:"text-xs text-gray-500",children:null!==(a=t.phone)&&void 0!==a?a:"-"})]})}},{title:"In their cart",key:"items",width:150,render:(e,t)=>(0,n.jsxs)(h.ZP,{type:"link",className:"px-0",onClick:()=>K(t),children:[t.items.length," item",1===t.items.length?"":"s"]})},{title:"Qty",dataIndex:"itemCount",sorter:!0,width:80},{title:"Cart value",dataIndex:"value",sorter:!0,width:130,render:e=>
1P(e)},{title:"Last touched",dataIndex:"lastActivity",sorter:!0,width:190,render:(e,t)=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{children:(0,f.i$)(e)}),(0,n.jsx)(x.Z,{color:M[t.bucket],children:F[t.bucket]})]})},{title:"Status",key:"status",width:190,render:(e,t)=>{var a,r;return t.contacted?(0,n.jsx)(g.Z,{title:null!==(a=t.contactNote)&&void 0!==a?a:"",children:(0,n.jsxs)("span",{className:"text-xs text-gray-500",children:["Contacted ",(0,f.i$)(null!==(r=t.contactedAt)&&void 0!==r?r:void 0),t.contactedBy?" by ".concat(t.contactedBy):""]})}):(0,n.jsx)(x.Z,{color:"orange",children:"Not contacted"})}},{title:"Action",key:"action",width:180,render:(e,t)=>(0,n.jsx)(O,{whatsapp:t.whatsapp,email:t.email,contacted:t.contacted,pending:Q.isPending,onMarkContacted:e=>Q.mutate({cartRefId:t.cartRefId,note:e})})}]}),(0,n.jsx)(_,{open:!!Y,onClose:()=>K(null),title:"".concat("".concat(null!==(E=null==Y?void 0:Y.firstName)&&void 0!==E?E:""," ").concat(null!==(S=null==Y?void 0:Y.lastName)&&void 0!==S?S:"").trim()," â cart contents"),subtitle:Y?"Last touched ".concat((0,f.i$)(Y.lastActivity)):void 0,items:null!==(I=null==Y?void 0:Y.items)&&void 0!==I?I:[]}),(0,n.jsx)(v.Z,{className:"mt-3",type:"info",showIcon:!0,message:"Carts are a live snapshot â there is no history behind this list. A customer who changes their cart after you call reappears here as a fresh row."})]})]})};var L=a(67310),U=a(52043),B=a.n(U);let W=e=>"RM ".concat(Number(null!=e?e:0).toFixed(2)),G={neverInitiated:"Never reached payment",dropped:"Dropped at payment",declined:"Declined"},V=e=>{let{label:t,value:a,hint:r,className:l}=e;return(0,n.jsxs)("div",{className:"p-4 rounded-lg border ".concat(null!=l?l:"bg-gray-50 border-gray-200"),children:[(0,n.jsx)("div",{className:"text-xs font-semibold text-gray-600",children:t}),(0,n.jsx)("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:a}),r?(0,n.jsx)("div",{className:"mt-1 text-xs text-gray-500",children:r}):null]})},Y=()=>{var e,t,a,r,l,s,N,w,C,R,k,E,S,I,D,T,P,F,M;let[z,U,Y]=(0,y.Z)({sortField:"lastAbandonedAt"}),[K,q]=(0,b.useState)(""),[H,Q]=(0,b.useState)("all"),[$,J]=(0,b.useState)(null),X=(0,i.a)({queryKey:["admin","abandonment","order-stats"],queryFn:async()=>(await j()).data}),ee=(0,i.a)({queryKey:["admin","abandonment","orders",z,K,H],queryFn:async()=>(await A({page:z.page,pageSize:z.pageSize,sortField:z.sortField,sortOrder:z.sortOrder,search:K||void 0,contactStatus:H})).data}),et=(0,d.D)({mutationFn:async e=>Z(e),onSuccess:()=>{p.Am.success("Logged as contacted"),ee.refetch()},onError:e=>p.Am.error((0,f._g)(e))}),ea=X.data,en=null!==(r=null==ea?void 0:ea.monthly.flatMap(e=>["neverInitiated","dropped","declined"].map(t=>({month:B()("".concat(e.month,"-01")).format("MMM YY"),bucket:G[t],orders:e[t]}))))&&void 0!==r?r:[],er=null!==(l=null==ea?void 0:ea.monthly.map(e=>({month:B()("".concat(e.month,"-01")).format("MMM YY"),value:e.value})))&&void 0!==l?l:[];return(0,n.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[(0,n.jsx)(V,{label:"Ringgit lost (12 mo)",value:W(null!==(s=null==ea?void 0:ea.totals.value)&&void 0!==s?s:0),hint:"".concat(null!==(N=null==ea?void 0:ea.totals.orders)&&void 0!==N?N:0," abandoned orders"),className:"bg-red-50 border-red-100"}),(0,n.jsx)(V,{label:"Never reached payment",value:String(null!==(w=null==ea?void 0:ea.totals.neverInitiated)&&void 0!==w?w:0),hint:"Checkout page friction"}),(0,n.jsx)(V,{label:"Dropped at payment",value:String(null!==(C=null==ea?void 0:ea.totals.dropped)&&void 0!==C?C:0),hint:"Left the bank page"}),(0,n.jsx)(V,{label:"Declined",value:String(null!==(R=null==ea?void 0:ea.totals.declined)&&void 0!==R?R:0),hint:"Card or bank rejected"})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-4 text-base font-semibold text-gray-800",children:"Where checkout breaks down"}),X.isError?(0,n.jsx)("div",{className:"py-12 text-sm text-center text-red-500",children:"Failed to load statistics."}):(0,n.jsx)(o.Z,{data:en,xField:"month",yField:"orders",colorField:"bucket",stack:!0,height:280,legend:{color:{position:"bottom"}}})]}),(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-4 text-base font-semibold text-gray-800",children:"Ringgit lost (last 12 months)"}),X.isError?(0,n.jsx)("div",{className:"py-12 text-sm text-center text-red-500",children:"Failed to load statistics."}):(0,n.jsx)(L.Z,{data:er,xField:"month",yField:"value",shape:"smooth",height:280,style:{stroke:"#e73042"}})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-1 text-base font-semibold text-gray-800",children:"Decline rate by payment channel"}),(0,n.jsx)("p",{className:"mt-0 mb-3 text-xs text-gray-500",children:"Only payments that came back from the bank carry a channel â customers who walked away at the bank page are not counted here."}),(0,n.jsx)(c.Z,{size:"small",rowKey:"channel",loading:X.isLoading,dataSource:null!==(k=null==ea?void 0:ea.channels)&&void 0!==k?k:[],pagination:!1,columns:[{title:"Channel",dataIndex:"channel"},{title:"Paid",dataIndex:"success",width:80},{title:"Failed",dataIndex:"failed",width:80},{title:"Decline rate",dataIndex:"declineRate",width:120,render:e=>(0,n.jsxs)(x.Z,{color:e>=.3?"red":e>=.15?"orange":"green",children:[(100*e).toFixed(1),"%"]})}]})]}),(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsx)("h3",{className:"m-0 mb-3 text-base font-semibold text-gray-800",children:"Most abandoned products"}),(0,n.jsx)(c.Z,{size:"small",rowKey:"productName",loading:X.isLoading,dataSource:null!==(E=null==ea?void 0:ea.topProducts)&&void 0!==E?E:[],pagination:!1,columns:[{title:"Product",dataIndex:"productName",ellipsis:!0},{title:"Qty",dataIndex:"quantity",width:70},{title:"Orders",dataIndex:"orders",width:80},{title:"Value",dataIndex:"value",width:120,render:e=>W(e)}]})]})]}),(0,n.jsxs)("div",{className:"p-4 bg-white rounded-lg border border-gray-200",children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-3 justify-between items-center mb-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h3",{className:"m-0 text-base font-semibold text-gray-800",children:"Customers to call"}),(0,n.jsx)("p",{className:"mt-1 mb-0 text-xs text-gray-500",children:"Last 14 days, one row per customer. Excludes orders still inside their 15-minute payment window."})]}),(0,n.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,n.jsx)(m.default.Search,{allowClear:!0,placeholder:"Name or email",className:"w-56",onSearch:e=>{q(e),U(e=>({...e,page:1}))}}),(0,n.jsx)(u.default,{className:"w-40",value:H,onChange:e=>{Q(e),U(e=>({...e,page:1}))},options:[{value:"all",label:"All"},{value:"uncontacted",label:"Not contacted"},{value:"contacted",label:"Contacted"}]})]})]}),(0,n.jsx)(c.Z,{rowKey:"userRefId",size:"small",scroll:{x:1150},loading:ee.isLoading,dataSource:null!==(S=null===(e=ee.data)||void 0===e?void 0:e.rows)&&void 0!==S?S:[],onChange:Y,rowClassName:e=>e.contacted?"opacity-50":"",pagination:{current:null!==(I=null===(t=ee.data)||void 0===t?void 0:t.page)&&void 0!==I?I:z.page,pageSize:z.pageSize,total:null!==(D=null===(a=ee.data)||void 0===a?void 0:a.total)&&void 0!==D?D:0,showSizeChanger:!0,showTotal:(e,t)=>"".concat(t[0],"-").concat(t[1]," of ").concat(e," items")},columns:[{title:"Customer",key:"customer",render:(e,t)=>{var a;return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-medium",children:"".concat(t.firstName," ").concat(t.lastName).trim()||t.email}),(0,n.jsx)("div",{className:"text-xs text-gray-500",children:t.email}),(0,n.jsx)("div",{className:"text-xs text-gray-500",children:null!==(a=t.phone)&&void 0!==a?a:"-"})]})}},{title:"Wanted to buy",key:"items",width:150,render:(e,t)=>(0,n.jsxs)(h.ZP,{type:"link",className:"px-0",onClick:()=>J(t),children:[t.items.length," item",1===t.items.length?"":"s"]})},{title:"Last abandoned",dataIndex:"lastAbandonedAt",sorter:!0,width:170,render:(e,t)=>{var a;return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{children:(0,f.i$)(e)}),(0,n.jsx)("div",{className:"text-xs text-gray-500",children:null!==(a=t.lastOrderCode)&&void 0!==a?a:"-"})]})}},{title:"Times",dataIndex:"abandonedCount",sorter:!0,width:90,render:e=>e>1?(0,n.jsxs)(x.Z,{color:"red",children:[e,"x"]}):e},{title:"Value at risk",dataIndex:"totalValue",sorter:!0,width:140,render:(e,t)=>(0,n.jsx)(g.Z,{title:"Latest order ".concat(W(t.lastOrderTotal)),children:W(e)})},{title:"Status",key:"status",width:190,render:(e,t)=>{var a,r;return t.contacted?(0,n.jsx)(g.Z,{title:null!==(a=t.contactNote)&&void 0!==a?a:"",children:(0,n.jsxs)("span",{className:"text-xs text-gray-500",children:["Contacted ",(0,f.i$)(null!==(r=t.contactedAt)&&void 0!==r?r:void 0),t.contactedBy?" by ".concat(t.contactedBy):""]})}):(0,n.jsx)(x.Z,{color:"orange",children:"Not contacted"})}},{title:"Action",key:"action",width:180,render:(e,t)=>
1(0,n.jsx)(O,{whatsapp:t.whatsapp,email:t.email,contacted:t.contacted,pending:et.isPending,onMarkContacted:e=>et.mutate({orderRefId:t.lastOrderRefId,note:e})})}]}),(0,n.jsx)(_,{open:!!$,onClose:()=>J(null),title:"".concat("".concat(null!==(T=null==$?void 0:$.firstName)&&void 0!==T?T:""," ").concat(null!==(P=null==$?void 0:$.lastName)&&void 0!==P?P:"").trim()," â abandoned order"),subtitle:$?"".concat(null!==(F=$.lastOrderCode)&&void 0!==F?F:"No order code"," \xb7 abandoned ").concat((0,f.i$)($.lastAbandonedAt)):void 0,items:null!==(M=null==$?void 0:$.items)&&void 0!==M?M:[]}),(0,n.jsx)(v.Z,{className:"mt-3",type:"info",showIcon:!0,message:"An expired order cannot be paid â the cart was cleared and stock released at checkout. Contacting the customer means asking them to order again."})]})]})};var K=!0,q=e=>{let{user:t}=e,[a,i]=(0,s.v1)("tab",s.Oi.withDefault("orders"));return(0,n.jsx)(r.Z,{user:t,activeMenu:["abandonment"],card:!1,children:(0,n.jsx)("div",{className:"p-4 bg-white rounded-xl md:p-6",children:(0,n.jsx)(l.Z,{activeKey:a,onChange:i,destroyInactiveTabPane:!0,items:[{key:"orders",label:"Abandoned orders",children:(0,n.jsx)(Y,{})},{key:"carts",label:"Abandoned carts",children:(0,n.jsx)(z,{})}]})})})}},69504:function(e,t,a){"use strict";a.d(t,{A9:function(){return o},IU:function(){return l},c0:function(){return d},kS:function(){return s},o9:function(){return i},x4:function(){return r}});var n=a(5409);let r=async e=>n.Z.post("/auth/login",e),l=async e=>n.Z.post("/auth/signup",e),s=async()=>n.Z.post("/auth/logout"),i=async e=>n.Z.post("/auth/forget-password",e),d=async e=>n.Z.post("/auth/password-reset/confirm",e),o=async e=>n.Z.post("/auth/verify-user",e)},62581:function(e,t,a){"use strict";var n,r;a.d(t,{Z:function(){return n}}),(r=n||(n={})).LOGIN="/login",r.ADMIN_DASHBOARD="/admin/dashboard",r.HOME="/",r.USER="/admin/user",r.ROLE="/admin/role",r.NEW_ROLE="/admin/role/new",r.SYSTEM_CONFIG="/admin/system-config",r.PRODUCT="/admin/product",r.BLOG="/admin/blog",r.ORDER="/admin/order",r.ABANDONMENT="/admin/abandonment",r.WARRANTY_REGISTER="/admin/warranty-register",r.WARRANTY_CLAIM="/admin/warranty-claim",r.COUPON="/admin/coupon",r.OUR_PARTNERS="/admin/our-partners",r.REVIEW="/admin/review",r.CONTENT_BANNER="/admin/content/banners",r.CONTENT_REVIEW="/admin/content/reviews",r.CONTENT_VIDEO="/admin/content/videos",r.CONTENT_POPUP="/admin/content/popups"},94170:function(e,t,a){"use strict";var n,r,l,s,i,d,o,c,u,m;a.d(t,{As:function(){return l},fH:function(){return s},hY:function(){return r}}),(d=n||(n={})).EN="en",d.ZH_HK="zh-HK",(o=r||(r={})).LOGIN="login",o.FORGET_PASSWORD="forget_password",o.SIGNUP="signup",(c=l||(l={})).ASC="asc",c.DESC="desc",(u=s||(s={})).VERIFIED="VERIFIED",u.PENDING_FOR_VERIFICATION="PENDING_FOR_VERIFICATION",u.VERIFICATION_EXPIRED="VERIFICATION_EXPIRED",(m=i||(i={})).ADMIN="Admin",m.CUSTOMER="Customer"},26134:function(e,t,a){"use strict";a.d(t,{f:function(){return n}});let n=(e,t,a)=>void 0===t?void 0!==a?a:Array.isArray(t)?[]:{}:e?t:void 0!==a?a:Array.isArray(t)?[]:{}},83214:function(e,t,a){"use strict";a.d(t,{_g:function(){return l},i$:function(){return s}});var n=a(52043),r=a.n(n);let l=e=>{if("response"in e){var t,a;return null===(a=e.response)||void 0===a?void 0:null===(t=a.data)||void 0===t?void 0:t.message}return e.message},s=(e,t)=>{let a=r()(e);return e&&a.isValid()?r()(e).format("DD MMM YYYY, hh:mm a"):t||null}},91340:function(e,t,a){"use strict";a.d(t,{Zd:function(){return l},hv:function(){return i},rD:function(){return d},wN:function(){return s}});let n="session_id",r="session_header_enabled";function l(){try{let e=localStorage.getItem(n);if(e&&e.length>0)return e;let t="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():o();return localStorage.setItem(n,t),t}catch(e){return o()}}function s(){try{localStorage.setItem(r,"1")}catch(e){}}function i(){try{localStorage.setItem(r,"0"),localStorage.removeItem(n)}catch(e){}}function d(){try{return"1"===localStorage.getItem(r)}catch(e){return!1}}function o(){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,[3623,7759,2706,5989,4237,7610,8174,9834,8051,9513,4540,928,4298,4190,6631,6220,9575,7444,9406,150,5934,9059,8672,1795,8374,7894,7645,1635,2978,2888,9774,179],function(){return e(e.s=77397)}),_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.