(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,42060,e=>{"use strict";var t=e.i(43476),a=e.i(18566),l=e.i(59544),s=e.i(57688);e.s(["default",0,function({image:e="/images/error-state.svg",title:i="Something went wrong",description:r="We couldn't complete your request. Please try again or return to the home page.",buttonText:n="Return to Home",buttonHref:o="/",onClick:c,loading:d=!1,className:u,variant:m="page",retryText:x="Try again",onRetry:p}){let g=(0,a.usePathname)(),h="page"===m?g.includes("/admin")?"min-h-[calc(100vh-4rem)] lg:min-h-[calc(100vh-5rem)]":"pb-8 pt-36 md:pt-40 xl:pt-44 2xl:pt-48":"section"===m?"rounded-2xl glass-card-v2 px-6 py-10 md:px-8 md:py-12":"rounded-xl border border-[#E5DFFF] bg-white/70 px-4 py-5";return(0,t.jsx)("section",{className:`relative flex w-full items-center justify-center px-4 ${h} ${u??""}`,role:"status","aria-live":"polite",children:(0,t.jsxs)("div",{className:"mx-auto w-full max-w-2xl text-center",children:[(0,t.jsx)("div",{className:"mb-6 flex justify-center sm:mb-8",children:(0,t.jsx)(s.default,{src:e,alt:"","aria-hidden":"true",width:280,height:280,priority:"page"===m,className:`h-auto ${"page"===m?"w-40 sm:w-48 md:w-56 lg:w-64 xl:w-72":"w-24 sm:w-28 md:w-32"}`})}),(0,t.jsx)("h2",{className:`mt-4 font-heading font-medium capitalize leading-tight text-heading ${"page"===m?"text-2xl lg:text-3xl 2xl:text-4xl 2xl:leading-11":"section"===m?"text-xl md:text-2xl":"text-lg md:text-xl"}`,children:i}),(0,t.jsx)("p",{className:`mx-auto mt-4 text-text md:mt-5 ${"page"===m?"text-base sm:text-lg 2xl:text-lg 2xl:leading-7":"text-sm md:text-base"}`,children:r}),(p||n)&&(0,t.jsxs)("div",{className:"mt-8 flex flex-col justify-center gap-3 sm:flex-row",children:[p&&(0,t.jsx)(l.default,{onClick:p,loading:d,className:"w-full sm:w-auto",buttonClassName:"w-full min-w-0 sm:min-w-[180px]",children:x}),n&&(0,t.jsx)(l.default,{href:o,onClick:c,className:"w-full sm:w-auto",buttonClassName:"w-full min-w-0 sm:min-w-[180px]",children:n})]})]})})}])},78700,e=>{"use strict";var t=e.i(71645);let a={page:1,limit:10,searchQuery:"",sortBy:void 0,sortDirection:void 0};e.s(["useAppPagination",0,function({initialState:e}={}){let[l,s]=(0,t.useState)({...a,...e}),i=(0,t.useMemo)(()=>l.sortBy?[{id:l.sortBy,desc:"desc"===l.sortDirection}]:[],[l.sortBy,l.sortDirection]),r=(0,t.useCallback)(e=>{let t=e[0];s(e=>({...e,sortBy:t?.id,sortDirection:t?t.desc?"desc":"asc":void 0,page:1}))},[]);return{params:l,set:(e,t)=>{s(a=>({...a,[e]:t}))},patch:e=>{s(t=>({...t,...e}))},reset:()=>{s({...a,...e})},sortingConfig:(0,t.useMemo)(()=>({state:i,onChange:r}),[i,r])}}])},92408,e=>{"use strict";var t=e.i(43476);e.s(["HeadingToolbar",0,function({title:e,subTitle:a,titleClassName:l="",subTitleClassName:s=""}){return(0,t.jsxs)("div",{children:[e&&(0,t.jsx)("div",{className:`
            font-body text-base lg:text-lg xl:text-xl 2xl:text-2xl font-semibold xl:leading-8.5 text-heading
            ${l}
          `,children:e}),a&&(0,t.jsx)("p",{className:`
            2xl:mt-0.5 font-body text-sm 2xl:text-base font-normal text-text
            ${s}
          `,children:a})]})}])},48268,e=>{"use strict";var t=e.i(43476),a=e.i(71645),l=e.i(4399),s=e.i(74080),i=e.i(73665),r=e.i(18566),n=e.i(71505);function o({user:e}){let[l,c]=(0,a.useState)(!1),[d,u]=(0,a.useState)(!1),[m,x]=(0,a.useState)({top:0,left:0,origin:"top"}),p=(0,r.useRouter)(),g=(0,a.useRef)(null),h=(0,a.useRef)(null),{openModal:f}=(0,n.useModal)(),b=(0,a.useCallback)(()=>{let e=g.current;if(!e)return;let t=e.getBoundingClientRect(),a=h.current?.offsetHeight||96,l=h.current?.offsetWidth||160,s=window.innerHeight-t.bottom,i=t.top,r=s<a+8&&i>s,n=r?Math.max(12,t.top-a-8):Math.min(t.bottom+8,window.innerHeight-a-12),o=t.right-l;x({top:n,left:o=Math.min(o=Math.max(12,o),window.innerWidth-l-12),origin:r?"bottom":"top"})},[]);(0,a.useLayoutEffect)(()=>{l&&(b(),u(!0))},[l,b]),(0,a.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target;g.current?.contains(t)||h.current?.contains(t)||c(!1)},t=e=>{"Escape"===e.key&&c(!1)};return window.addEventListener("resize",b),window.addEventListener("scroll",b,!0),document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[l,b]);let w=e.isActive,y=[{label:"View",onClick:()=>{p.push(`/admin/users/${e.uuid}`),c(!1)},className:"text-link-1"},{label:w?"Deactivate":"Activate",onClick:()=>{w?f("DEACTIVATE_USER",{userId:e.uuid}):f("ACTIVATE_USER",{userId:e.uuid}),c(!1)},className:"text-text"}];return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{ref:g,type:"button",onClick:()=>{u(!1),c(e=>!e)},"aria-label":"User actions","aria-haspopup":"menu","aria-expanded":l,className:"   inline-flex h-8 w-8 items-center justify-center cursor-pointer   rounded-full text-link-1 transition   hover:bg-link-1/10 focus:outline-none   focus:ring-2 focus:ring-link-1/30   ",children:(0,t.jsx)(i.MdMoreVert,{size:22})}),l&&"u">typeof document&&(0,s.createPortal)((0,t.jsx)("div",{ref:h,role:"menu",style:{top:m.top,left:m.left,width:160,visibility:d?"visible":"hidden",transformOrigin:"top"===m.origin?"top right":"bottom right"},className:"   fixed z-9 overflow-hidden rounded-xl   border border-black/5 bg-white py-1.5   shadow-[0_12px_40px_rgba(15,23,42,0.18)]   ring-1 ring-black/5   ",children:y.map(e=>(0,t.jsx)("button",{type:"button",role:"menuitem",onClick:e.onClick,className:`
                  block w-full px-4 py-2.5 text-left cursor-pointer
                  font-body text-sm font-medium
                  transition-colors hover:bg-link-1/5
                  ${e.className}
                `,children:e.label},e.label))}),document.body)]})}function c({status:e}){let a={Active:{label:"Active",color:"bg-success-light text-success"},Inactive:{label:"Inactive",color:"bg-danger-light text-danger"},Pending:{label:"Pending",color:"bg-yellow-100 text-yellow-700"}}[e];return(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-xs font-medium ${a.color}`,children:a.label})}var d=e.i(1973),u=e.i(79865);let m=[{accessorKey:"name",header:"Name",cell:({row:e})=>{let a=e.original;return(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[a.profilePicture?(0,t.jsx)("div",{className:"h-8 w-8 overflow-hidden rounded-full shrink-0",children:(0,t.jsx)(u.UserImage,{src:a.profilePicture,alt:a.name,className:"h-full w-full object-cover"})}):(0,t.jsx)("div",{className:"flex h-8 w-8 min-w-8 items-center justify-center rounded-full bg-slate-200 text-xs font-bold text-slate-700",children:a.name.charAt(0).toUpperCase()}),(0,t.jsx)("span",{className:"font-medium text-slate-900",children:a.name})]})}},{accessorKey:"email",header:"Email",enableSorting:!0,cell:({row:e})=>(0,t.jsx)("span",{className:"",children:e.original.email})},{accessorKey:"phone",header:"Phone Number",cell:({row:e})=>(0,t.jsxs)("span",{className:"",children:[e.original.dialCode," ",e.original.mobileNumber]})},{accessorKey:"registeredOn",header:"Registered On",cell:({row:e})=>(0,t.jsx)("span",{className:"",children:(0,d.convertDateStringToDate)(e.original.createdAt)})},{accessorKey:"totalSpent",header:"Total Spent",cell:({row:e})=>(0,t.jsx)("span",{className:"",children:e.original.totalSpent})},{accessorKey:"creditBalance",header:"Credit Balance",cell:({row:e})=>(0,t.jsx)("span",{className:"",children:e.original.walletBalance})},{accessorKey:"status",header:"Status",cell:({row:e})=>(0,t.jsx)(c,{status:e.original.isActive?"Active":"Inactive"},e.original.uuid)},{id:"actions",header:"Actions",enableSorting:!1,cell:({row:e})=>{let a=e.original;return(0,t.jsx)(o,{user:a})}}];var x=e.i(69620);function p({value:e,onSearch:l}){let[s,i]=(0,a.useState)(e);return(0,a.useEffect)(()=>{i(e)},[e]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{l(s)},500);return()=>clearTimeout(e)},[s,l]),(0,t.jsxs)("div",{className:"relative w-full sm:max-w-72",children:[(0,t.jsx)(x.IoSearchOutline,{size:20,className:"absolute left-4 top-1/2 -translate-y-1/2 text-[#8B5CF6]"}),(0,t.jsx)("input",{type:"text",placeholder:"Search",value:s,onChange:e=>i(e.target.value),className:"   h-11 w-full   rounded-xl   border border-[#E7E3F2]   bg-white   px-12   text-sm text-[#333]   outline-none   placeholder:text-[#9B96AA]   focus:border-[#8B5CF6]   focus:ring-2   focus:ring-[#8B5CF6]/10   "})]})}var g=e.i(78700),h=e.i(92408),f=e.i(19273),b=e.i(66027),w=e.i(42592),y=e.i(67789),v=e.i(42060);e.s(["default",0,function(){let[e,s]=(0,a.useState)({}),i=(0,g.useAppPagination)(),{data:r,loading:n,error:o,isError:c}=function(e){let{data:t,isPending:a,isError:l,error:s}=(0,b.useQuery)({queryKey:["users",e.params.page,e.params.limit,e.params.searchQuery,e.params.sortBy,e.params.sortDirection],queryFn:async()=>{let t={limit:e.params.limit,page:e.params.page,search:e.params.searchQuery,sortBy:e.params.sortBy,sortOrder:e?.params?.sortDirection?.toUpperCase()},a=await (0,w.apiGet)(y.ADMIN_USERS.GET_USERS,t);return{users:a.data.map(e=>({...e,name:`${e.firstName} ${e.lastName}`,creditBalance:e.walletBalance??"100",totalSpent:e.totalSpent??"$10",phoneNumber:`${e.dialCode||""} ${e.mobileNumber||"N/A"}`})),pagination:a.meta}},staleTime:6e4,placeholderData:f.keepPreviousData,retry:!1});return{data:t,loading:a,error:s,isError:l}}(i),d=r?.users??[],u=r?.pagination;return(0,t.jsx)("section",{className:"w-full p-4 pt-6 2xl:pt-8 2xl:p-8",children:c?(0,t.jsx)(v.default,{variant:"section",title:"Unable to load users",description:"The users table failed to load. Please try again.",onRetry:()=>i.patch({}),buttonText:""}):(0,t.jsx)(l.DataTable,{data:d,loading:n,columns:m,appearance:"default",size:"md",getRowId:e=>e.email,rowSelection:e,sorting:i.sortingConfig,onRowSelectionChange:s,onSelectedRowsChange:e=>{},toolbar:(0,t.jsx)(h.HeadingToolbar,{title:"Users",subTitle:`${d.length} User(s) listed`,titleClassName:"",subTitleClassName:""}),filters:(0,t.jsx)(p,{value:i.params.searchQuery,onSearch:e=>{i.patch({searchQuery:e})}}),classNames:{root:"",toolbar:"flex items-center gap-3",filters:"flex items-center gap-2",table:"min-w-full",tableThead:"bg-slate-100 border-t-2 border-slate-400  relative",tableTheadRow:"whitespace-nowrap",tableTheadCell:"px-3 py-2 2xl:p-3 text-left font-body text-sm 2xl:text-base font-medium text-heading relative",tableTbody:"border-t border-slate-300/50 relative",tableTbodyRow:`
              hover:bg-link-1/10 transition-colors
              [&>td]:border-b [&>td]:border-gray-200
            `,tableTbodyCell:"py-2 px-3 font-body text-[13px] 2xl:text-sm text-table-text relative",pagination:""},pagination:{controller:i,pageCount:u?.totalPages,totalItems:u?.total}})})}],48268)}]);