(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2439],{10988:function(e,t,r){Promise.resolve().then(r.bind(r,53446))},12536:function(e,t,r){"use strict";var a=r(57437),s=r(27260);t.Z=()=>(0,a.jsx)("div",{className:"flex justify-center mt-[30vh]",children:(0,a.jsx)(s.Z,{})})},53446:function(e,t,r){"use strict";r.r(t);var a=r(57437),s=r(8325),n=r(93951),i=r(78071),l=r(75716),o=r(96256),c=r(58062),d=r(1815),u=r(60793),h=r(84088),p=r(46082),g=r(26167),v=r(20651),T=r(12003),x=r(67108),f=r(24033),m=r(2265),b=r(12536),y=r(20625),j=r(434);t.default=()=>{let[e,t]=(0,m.useState)([]),r=(0,f.useSearchParams)().get("page"),[w,k]=(0,m.useState)(10),[P,S]=(0,m.useState)(!1),N=async()=>{var e,a,s;S(!0);let o=new i.O,c=await o.service().get("".concat(n.Z.familySharing.user,"?page=").concat(r?+r:1,"&limit=10"),{next:{cache:"no-store"}}),d=null==c?void 0:null===(a=c.data)||void 0===a?void 0:null===(e=a.result)||void 0===e?void 0:e.map(e=>{var t,r,a,s,n,i,o,c;return{productName:"".concat(null==e?void 0:null===(a=e.credentialId)||void 0===a?void 0:null===(r=a.familySharingId)||void 0===r?void 0:null===(t=r.product)||void 0===t?void 0:t.name," - ").concat(null==e?void 0:null===(n=e.orderId)||void 0===n?void 0:null===(s=n.productVariation)||void 0===s?void 0:s.name),key:null==e?void 0:null===(i=e.orderId)||void 0===i?void 0:i.id,id:null==e?void 0:null===(o=e.orderId)||void 0===o?void 0:o.id,date:(0,l.P)(null==e?void 0:null===(c=e.orderId)||void 0===c?void 0:c.createdAt),username:null==e?void 0:e.credentialId.username,password:null==e?void 0:e.credentialId.password,expiresIn:(0,l.P)(null==e?void 0:e.expiresIn),remainingDays:(0,l.y)(null==e?void 0:e.expiresIn)}});k(null==c?void 0:null===(s=c.data)||void 0===s?void 0:s.totalCount),t(d),S(!1)};return(0,m.useEffect)(()=>{N()},[r]),(0,a.jsx)(o.Card,{shadow:"sm",px:"lg",py:"sm",radius:"md",className:"bg-tertiary text-textPrimary",children:(0,a.jsxs)(c.CardSection,{px:10,py:10,className:"flex flex-col gap-3 justify-around",children:[(0,a.jsx)("div",{className:"flex gap-4 items-center",children:(0,a.jsx)(d.Title,{order:2,children:"Family Sharing"})}),(0,a.jsx)(m.Suspense,{fallback:(0,a.jsx)(b.Z,{}),children:(0,a.jsx)(u.ScrollArea,{className:"w-auto",children:(0,a.jsxs)(h.Table,{children:[(0,a.jsx)(p.TableThead,{children:(0,a.jsxs)(p.TableTr,{children:[(0,a.jsx)(p.TableTd,{children:"Order Id"}),(0,a.jsx)(p.TableTd,{children:"Product Name"}),(0,a.jsx)(p.TableTd,{children:"Date"}),(0,a.jsx)(p.TableTd,{children:"Username"}),(0,a.jsx)(p.TableTd,{children:"Password"}),(0,a.jsx)(p.TableTd,{children:"Expires In"}),(0,a.jsx)(p.TableTd,{children:"Remaining Days"})]})}),(0,a.jsx)(p.TableTbody,{children:e.length>0&&e.map(e=>(0,a.jsxs)(p.TableTr,{children:[(0,a.jsx)(p.TableTd,{children:null==e?void 0:e.id}),(0,a.jsx)(p.TableTd,{children:e.productName}),(0,a.jsx)(p.TableTd,{children:e.date}),(0,a.jsx)(p.TableTd,{children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"mt-1",children:[" ",e.username]}),(0,a.jsx)("div",{children:(0,a.jsx)(g.CopyButton,{value:e.username,timeout:2e3,children:e=>{let{copied:t,copy:r}=e;return(0,a.jsx)(v.Tooltip,{label:t?"Copied":"Copy",withArrow:!0,position:"right",children:(0,a.jsx)(T.ActionIcon,{color:t?"teal":"gray",variant:"subtle",onClick:r,children:t?(0,a.jsx)(y.Z,{style:{width:(0,x.h)(16)}}):(0,a.jsx)(j.Z,{style:{width:(0,x.h)(16)}})})})}})})]})}),(0,a.jsx)(p.TableTd,{children:(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)("div",{className:"mt-1",children:[" ",e.password]}),(0,a.jsx)("div",{children:(0,a.jsx)(g.CopyButton,{value:e.password,timeout:2e3,children:e=>{let{copied:t,copy:r}=e;return(0,a.jsx)(v.Tooltip,{label:t?"Copied":"Copy",withArrow:!0,position:"right",children:(0,a.jsx)(T.ActionIcon,{color:t?"teal":"gray",variant:"subtle",onClick:r,children:t?(0,a.jsx)(y.Z,{style:{width:(0,x.h)(16)}}):(0,a.jsx)(j.Z,{style:{width:(0,x.h)(16)}})})})}})})]})}),(0,a.jsx)(p.TableTd,{children:e.expiresIn}),(0,a.jsx)(p.TableTd,{children:e.remainingDays})]},e.key))})]})})}),(0,a.jsx)(s.$R,{totalPages:w})]})})}},27260:function(e,t,r){"use strict";var a=r(57437);t.Z=()=>(0,a.jsx)("div",{className:"rounded-md h-12 w-12 border-4 border-t-4 border-blue-500 animate-spin absolute "})},93250:function(e,t,r){"use strict";r.r(t);var a=r(57437),s=r(37886),n=r(17099),i=r(16512),l=r(24033);t.default=e=>{let{title:t}=e,r=(0,l.useRouter)(),o=(0,l.usePathname)(),c="";c=o.split("/").includes("edit")?o.replace(/\/[^\/]+\/edit$/,""):o.split("/").includes("create")?o.replace(/\/create(\/[^\/]+)?$/,""):o;let d=(0,l.useSearchParams)().get("page");return(0,a.jsxs)(n.Button,{onClick:()=>{r.push("".concat(c).concat(d?"?page=".concat(d):""))},color:s.r.primary,children:[(0,a.jsx)(i.Z,{className:"mr-1"})," Back to ",t]})}},8325:function(e,t,r){"use strict";r.d(t,{$R:function(){return a.default},Gi:function(){return s.default}}),r(57437),r(37886),r(61396),r(24033),r(93250);var a=r(33539),s=r(91123)},33539:function(e,t,r){"use strict";r.r(t);var a=r(57437),s=r(37886),n=r(93269),i=r(24033),l=r(2265);t.default=e=>{let{totalPages:t}=e,r=(0,i.useRouter)(),o=(0,i.usePathname)(),c=(0,i.useSearchParams)(),d=(0,l.useCallback)((e,t)=>{let r=new URLSearchParams(c.toString());return r.set(e,t),r.toString()},[c]);return(0,a.jsx)(n.Pagination,{color:s.r.primary,onChange:e=>{r.push(o+"?"+d("page",e.toString()))},total:t?Math.ceil(t/10):1,value:parseInt(c.get("page")||"1")})}},91123:function(e,t,r){"use strict";r.r(t);var a=r(57437),s=r(46082),n=r(84088),i=r(2265);t.default=e=>{let{columns:t,elements:r,actions:l}=e,o=r.map(e=>(0,a.jsxs)(s.TableTr,{children:[t.map(t=>(0,a.jsx)(s.TableTd,{children:e[t.key]},t.key)),l&&(0,a.jsx)(s.TableTd,{className:"flex gap-2",children:i.createElement(l,{id:e.id})},"actions")]},e.id)),c=t.map(e=>(0,a.jsx)(s.TableTh,{children:e.displayName},e.key));return l&&c.push((0,a.jsx)(s.TableTh,{children:"Actions"},"actions")),(0,a.jsxs)(n.Table,{className:"",children:[(0,a.jsx)(s.TableThead,{children:(0,a.jsx)(s.TableTr,{children:c})}),(0,a.jsx)(s.TableTbody,{children:o.length>0?o:(0,a.jsx)(s.TableTr,{children:(0,a.jsx)(s.TableTd,{children:"No data found"})})})]})}},93951:function(e,t){"use strict";t.Z={auth:{login:"/auth/login",register:"/auth/register",getProfile:"/auth/me",changePassword:"/auth/user/password/change",google:"/auth/google/callback",googleLogin:"/auth/login/google",activateAccount:"/otp/activateAccount",resendOTP:"/otp/resendActivateAccount",resetPasswordOtp:"/otp",profileUpdate:"/auth/user"},notification:{base:"/notification"},products:{base:"/product/user",featured:"/category/featured/all",navbar:"/category/featured/navbar",search:"/product/user/search",admin:"/product/products/search",category:"/product/category"},crousel:{crousel:"/crousel"},orders:{base:"/order",user:"/order/finall-by-user",cancel:"/order/cancel"},payement:{esewa:"/checkout/esewa/verify",khalti:"/checkout/khalti/verify",nepalPay:"/checkout/nepalPay/verify"},coupon:{discount:"/coupon/validate-coupon"},review:{create:"/review/create",find:"/review/find"},qAndA:{create:"/qa/create",find:"/qa/find"},blog:{base:"/blog",all:"/blog/all",user:"/blog/all/user",findOne:"/blog/user"},familySharing:{user:"/family-sharing/findAll-by-user"},ticket:{base:"/ticketing",user:"/ticketing/user",getAll:"/ticketing/find-all-user"},contactUs:{base:"/contactus"},category:{base:"/category"}}},78071:function(e,t,r){"use strict";r.d(t,{O:function(){return o},i:function(){return c}});var a,s,n=r(11490),i=r(93951);class l{constructor(){this.login=async(e,t)=>{var r,a;let s=new o,n=await s.service().push(i.Z.auth.login,{email:e,password:t});if(!n.success)return{status:n.status,message:n.message,data:n.data};let l=null===(r=n.data)||void 0===r?void 0:r.accessToken,c=null===(a=n.data)||void 0===a?void 0:a.refreshToken,[d,u,h]=l.split("."),p=JSON.parse(atob(u));return{id:p.sub,roles:p.roles,expiredAt:p.exp,accessToken:l,refreshToken:c,status:n.status}},this.getMe=()=>{let e=n.Z.get("currentUser");if(!e)throw Error("Access token not found in cookie");let[t,r,a]=e.split("."),s=JSON.parse(atob(r)),i=s.sub,l=s.roles,o=s.exp;if(o&&Date.now()>=1e3*o)throw Error("Access token has expired");return{id:i,roles:l,expiredAt:o}},this.checkLoggedIn=()=>{let e=n.Z.get("currentUser");if(!e)return!1;let[,t]=e.split("."),r=JSON.parse(atob(t)).exp;return!(!r||Date.now()>=1e3*r)}}}(a=s||(s={})).GET="GET",a.POST="POST",a.PUT="PATCH",a.DELETE="DELETE";class o{getAuthorization(){return function(){var e;let t=n.Z.get("currentUser");return{Authorization:"Bearer ".concat(null===(e=JSON.parse(t||"{}"))||void 0===e?void 0:e.accessToken)}}()}service(){return this}setupHeaders(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return e?{"Content-Type":"multipart/form-data",...this.getAuthorization()}:{"Content-Type":"application/json",...this.getAuthorization()}}async request(e,t,r){try{let a={headers:new Headers(r.headers),...r.next},s=await fetch("".concat(this.baseURL).concat(t),{method:e,...a,body:r.body});return await s.json()}catch(e){if(console.log(e),e instanceof TypeError&&"Failed to fetch"===e.message)return new Promise(()=>{});return this.normalizeError(e)}}async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={headers:this.setupHeaders(!1),...t};return this.request(s.GET,e,r)}async push(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.request(s.POST,e,{body:JSON.stringify(t),headers:this.setupHeaders(r)})}async update(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return this.request(s.PUT,e,{body:JSON.stringify(t),headers:this.setupHeaders(r)})}async remove(e){return this.request(s.DELETE,"".concat(e),{headers:this.setupHeaders(!1)})}normalizeError(e){return Promise.reject(e)}constructor(){this.baseURL="https://www.backend.toolsmandu.com"}}let c=new l},37886:function(e,t,r){"use strict";var a,s;r.d(t,{r:function(){return a}}),(s=a||(a={})).primary="rgba(0, 0, 0, 1)",s.delete="red"},75716:function(e,t,r){"use strict";function a(e){return e?new Date(e).toISOString().split("T")[0]:"Invalid Date"}function s(e){if(!e)return"Invalid date";{let t=new Date(e),r=new Date(new Date().getTime()+207e5);r.setUTCHours(0,0,0,0);let a=new Date(t.getTime()+207e5);return a.setUTCHours(0,0,0,0),Math.floor((a.getTime()-r.getTime())/864e5)}}r.d(t,{P:function(){return a},y:function(){return s}})}},function(e){e.O(0,[8114,8252,5250,5304,1004,7439,834,2971,4938,1744],function(){return e(e.s=10988)}),_N_E=e.O()}]);