module.exports=[62701,a=>{"use strict";var b=a.i(87924),c=a.i(50944),d=a.i(96438),e=a.i(71133);a.s(["default",0,function({image:a="/images/error-state.svg",title:f="Something went wrong",description:g="We couldn't complete your request. Please try again or return to the home page.",buttonText:h="Return to Home",buttonHref:i="/",onClick:j,loading:k=!1,className:l,variant:m="page",retryText:n="Try again",onRetry:o}){let p=(0,c.usePathname)(),q="page"===m?p.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,b.jsx)("section",{className:`relative flex w-full items-center justify-center px-4 ${q} ${l??""}`,role:"status","aria-live":"polite",children:(0,b.jsxs)("div",{className:"mx-auto w-full max-w-2xl text-center",children:[(0,b.jsx)("div",{className:"mb-6 flex justify-center sm:mb-8",children:(0,b.jsx)(e.default,{src:a,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,b.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:f}),(0,b.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:g}),(o||h)&&(0,b.jsxs)("div",{className:"mt-8 flex flex-col justify-center gap-3 sm:flex-row",children:[o&&(0,b.jsx)(d.default,{onClick:o,loading:k,className:"w-full sm:w-auto",buttonClassName:"w-full min-w-0 sm:min-w-[180px]",children:n}),h&&(0,b.jsx)(d.default,{href:i,onClick:j,className:"w-full sm:w-auto",buttonClassName:"w-full min-w-0 sm:min-w-[180px]",children:h})]})]})})}])},61719,a=>{"use strict";var b=a.i(72131);let c={page:1,limit:10,searchQuery:"",sortBy:void 0,sortDirection:void 0};a.s(["useAppPagination",0,function({initialState:a}={}){let[d,e]=(0,b.useState)({...c,...a}),f=(0,b.useMemo)(()=>d.sortBy?[{id:d.sortBy,desc:"desc"===d.sortDirection}]:[],[d.sortBy,d.sortDirection]),g=(0,b.useCallback)(a=>{let b=a[0];e(a=>({...a,sortBy:b?.id,sortDirection:b?b.desc?"desc":"asc":void 0,page:1}))},[]);return{params:d,set:(a,b)=>{e(c=>({...c,[a]:b}))},patch:a=>{e(b=>({...b,...a}))},reset:()=>{e({...c,...a})},sortingConfig:(0,b.useMemo)(()=>({state:f,onChange:g}),[f,g])}}])},38939,a=>{"use strict";var b=a.i(87924);a.s(["HeadingToolbar",0,function({title:a,subTitle:c,titleClassName:d="",subTitleClassName:e=""}){return(0,b.jsxs)("div",{children:[a&&(0,b.jsx)("div",{className:`
            font-body text-base lg:text-lg xl:text-xl 2xl:text-2xl font-semibold xl:leading-8.5 text-heading
            ${d}
          `,children:a}),c&&(0,b.jsx)("p",{className:`
            2xl:mt-0.5 font-body text-sm 2xl:text-base font-normal text-text
            ${e}
          `,children:c})]})}])},78130,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(73732),e=a.i(35112),f=a.i(328),g=a.i(50944),h=a.i(50159);function i({user:a}){let[d,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1),[m,n]=(0,c.useState)({top:0,left:0,origin:"top"}),o=(0,g.useRouter)(),p=(0,c.useRef)(null),q=(0,c.useRef)(null),{openModal:r}=(0,h.useModal)(),s=(0,c.useCallback)(()=>{let a=p.current;if(!a)return;let b=a.getBoundingClientRect(),c=q.current?.offsetHeight||96,d=q.current?.offsetWidth||160,e=window.innerHeight-b.bottom,f=b.top,g=e<c+8&&f>e,h=g?Math.max(12,b.top-c-8):Math.min(b.bottom+8,window.innerHeight-c-12),i=b.right-d;n({top:h,left:i=Math.min(i=Math.max(12,i),window.innerWidth-d-12),origin:g?"bottom":"top"})},[]);(0,c.useLayoutEffect)(()=>{d&&(s(),l(!0))},[d,s]),(0,c.useEffect)(()=>{if(!d)return;let a=a=>{let b=a.target;p.current?.contains(b)||q.current?.contains(b)||j(!1)},b=a=>{"Escape"===a.key&&j(!1)};return window.addEventListener("resize",s),window.addEventListener("scroll",s,!0),document.addEventListener("mousedown",a),document.addEventListener("keydown",b),()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),document.removeEventListener("mousedown",a),document.removeEventListener("keydown",b)}},[d,s]);let t=a.isActive,u=[{label:"View",onClick:()=>{o.push(`/admin/users/${a.uuid}`),j(!1)},className:"text-link-1"},{label:t?"Deactivate":"Activate",onClick:()=>{t?r("DEACTIVATE_USER",{userId:a.uuid}):r("ACTIVATE_USER",{userId:a.uuid}),j(!1)},className:"text-text"}];return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("button",{ref:p,type:"button",onClick:()=>{l(!1),j(a=>!a)},"aria-label":"User actions","aria-haspopup":"menu","aria-expanded":d,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,b.jsx)(f.MdMoreVert,{size:22})}),d&&"u">typeof document&&(0,e.createPortal)((0,b.jsx)("div",{ref:q,role:"menu",style:{top:m.top,left:m.left,width:160,visibility:k?"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:u.map(a=>(0,b.jsx)("button",{type:"button",role:"menuitem",onClick:a.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
                  ${a.className}
                `,children:a.label},a.label))}),document.body)]})}function j({status:a}){let c={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"}}[a];return(0,b.jsx)("span",{className:`inline-flex items-center rounded-full px-3 py-1 text-xs font-medium ${c.color}`,children:c.label})}var k=a.i(49986),l=a.i(99053);let m=[{accessorKey:"name",header:"Name",cell:({row:a})=>{let c=a.original;return(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[c.profilePicture?(0,b.jsx)("div",{className:"h-8 w-8 overflow-hidden rounded-full shrink-0",children:(0,b.jsx)(l.UserImage,{src:c.profilePicture,alt:c.name,className:"h-full w-full object-cover"})}):(0,b.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:c.name.charAt(0).toUpperCase()}),(0,b.jsx)("span",{className:"font-medium text-slate-900",children:c.name})]})}},{accessorKey:"email",header:"Email",enableSorting:!0,cell:({row:a})=>(0,b.jsx)("span",{className:"",children:a.original.email})},{accessorKey:"phone",header:"Phone Number",cell:({row:a})=>(0,b.jsxs)("span",{className:"",children:[a.original.dialCode," ",a.original.mobileNumber]})},{accessorKey:"registeredOn",header:"Registered On",cell:({row:a})=>(0,b.jsx)("span",{className:"",children:(0,k.convertDateStringToDate)(a.original.createdAt)})},{accessorKey:"totalSpent",header:"Total Spent",cell:({row:a})=>(0,b.jsx)("span",{className:"",children:a.original.totalSpent})},{accessorKey:"creditBalance",header:"Credit Balance",cell:({row:a})=>(0,b.jsx)("span",{className:"",children:a.original.walletBalance})},{accessorKey:"status",header:"Status",cell:({row:a})=>(0,b.jsx)(j,{status:a.original.isActive?"Active":"Inactive"},a.original.uuid)},{id:"actions",header:"Actions",enableSorting:!1,cell:({row:a})=>{let c=a.original;return(0,b.jsx)(i,{user:c})}}];var n=a.i(48617);function o({value:a,onSearch:d}){let[e,f]=(0,c.useState)(a);return(0,c.useEffect)(()=>{f(a)},[a]),(0,c.useEffect)(()=>{let a=setTimeout(()=>{d(e)},500);return()=>clearTimeout(a)},[e,d]),(0,b.jsxs)("div",{className:"relative w-full sm:max-w-72",children:[(0,b.jsx)(n.IoSearchOutline,{size:20,className:"absolute left-4 top-1/2 -translate-y-1/2 text-[#8B5CF6]"}),(0,b.jsx)("input",{type:"text",placeholder:"Search",value:e,onChange:a=>f(a.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 p=a.i(61719),q=a.i(38939),r=a.i(42871),s=a.i(33217),t=a.i(11461),u=a.i(9172),v=a.i(62701);a.s(["default",0,function(){let[a,e]=(0,c.useState)({}),f=(0,p.useAppPagination)(),{data:g,loading:h,error:i,isError:j}=function(a){let{data:b,isPending:c,isError:d,error:e}=(0,s.useQuery)({queryKey:["users",a.params.page,a.params.limit,a.params.searchQuery,a.params.sortBy,a.params.sortDirection],queryFn:async()=>{let b={limit:a.params.limit,page:a.params.page,search:a.params.searchQuery,sortBy:a.params.sortBy,sortOrder:a?.params?.sortDirection?.toUpperCase()},c=await (0,t.apiGet)(u.ADMIN_USERS.GET_USERS,b);return{users:c.data.map(a=>({...a,name:`${a.firstName} ${a.lastName}`,creditBalance:a.walletBalance??"100",totalSpent:a.totalSpent??"$10",phoneNumber:`${a.dialCode||""} ${a.mobileNumber||"N/A"}`})),pagination:c.meta}},staleTime:6e4,placeholderData:r.keepPreviousData,retry:!1});return{data:b,loading:c,error:e,isError:d}}(f),k=g?.users??[],l=g?.pagination;return(0,b.jsx)("section",{className:"w-full p-4 pt-6 2xl:pt-8 2xl:p-8",children:j?(0,b.jsx)(v.default,{variant:"section",title:"Unable to load users",description:"The users table failed to load. Please try again.",onRetry:()=>f.patch({}),buttonText:""}):(0,b.jsx)(d.DataTable,{data:k,loading:h,columns:m,appearance:"default",size:"md",getRowId:a=>a.email,rowSelection:a,sorting:f.sortingConfig,onRowSelectionChange:e,onSelectedRowsChange:a=>{},toolbar:(0,b.jsx)(q.HeadingToolbar,{title:"Users",subTitle:`${k.length} User(s) listed`,titleClassName:"",subTitleClassName:""}),filters:(0,b.jsx)(o,{value:f.params.searchQuery,onSearch:a=>{f.patch({searchQuery:a})}}),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:f,pageCount:l?.totalPages,totalItems:l?.total}})})}],78130)}];

//# sourceMappingURL=src_1yuxvbx._.js.map