(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7292],{526:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>c});var r=t(5155),a=t(2108),n=t(5695),u=t(2115),i=t(2355);function c(e){let{children:s,params:t}=e,{data:c,status:l}=(0,a.useSession)(),o=(0,n.useRouter)(),{showError:d}=(0,i.d)(),[h,f]=(0,u.useState)(""),[m,p]=(0,u.useState)(!0);return((0,u.useEffect)(()=>{(async()=>{f((await t).locale)})()},[t]),(0,u.useEffect)(()=>{if("loading"===l)return;if(!(null==c?void 0:c.user)){d("Please login to access this page","Access Denied"),o.push("/".concat(h,"/login"));return}let e=c.user.role;if("FREELANCER"!==e){d("This page is only accessible to freelancers","Access Denied"),"CLIENT"===e?o.push("/".concat(h,"/client/my-projects")):o.push("/".concat(h));return}p(!1)},[c,l,o,h,d]),"loading"===l||m)?(0,r.jsx)("div",{className:"d-flex align-items-center justify-content-center loading-container",children:(0,r.jsx)("div",{className:"spinner-border text-primary",role:"status",children:(0,r.jsx)("span",{className:"visually-hidden",children:"Loading..."})})}):(null==c?void 0:c.user)&&"FREELANCER"===c.user.role?(0,r.jsx)(r.Fragment,{children:s}):null}t(9447)},2355:(e,s,t)=>{"use strict";t.d(s,{d:()=>i,t:()=>u});var r=t(5155),a=t(2115);let n=(0,a.createContext)(void 0);function u(e){let{children:s}=e,[t,u]=(0,a.useState)([]),i=(0,a.useCallback)(e=>{u(s=>s.filter(s=>s.id!==e))},[]),c=(0,a.useCallback)(e=>{var s;let t=Math.random().toString(36).substr(2,9),r=5e3;switch(e.type){case"success":r=4e3;break;case"error":r=7e3;break;case"warning":r=6e3;break;case"info":r=5e3}let a={id:t,duration:null!=(s=e.duration)?s:r,...e};u(e=>{let s=[...e,a];return s.length>5?s.slice(-5):s}),a.duration&&a.duration>0&&setTimeout(()=>{i(t)},a.duration)},[i]),l=(0,a.useCallback)((e,s)=>{c({type:"success",message:e,title:s})},[c]),o=(0,a.useCallback)((e,s)=>{c({type:"error",message:e,title:s})},[c]),d=(0,a.useCallback)((e,s)=>{c({type:"warning",message:e,title:s})},[c]),h=(0,a.useCallback)((e,s)=>{c({type:"info",message:e,title:s})},[c]);return(0,r.jsx)(n.Provider,{value:{toasts:t,addToast:c,removeToast:i,showSuccess:l,showError:o,showWarning:d,showInfo:h},children:s})}function i(){let e=(0,a.useContext)(n);if(!e)throw Error("useToast must be used within a ToastProvider");return e}},5695:(e,s,t)=>{"use strict";var r=t(8999);t.o(r,"useParams")&&t.d(s,{useParams:function(){return r.useParams}}),t.o(r,"usePathname")&&t.d(s,{usePathname:function(){return r.usePathname}}),t.o(r,"useRouter")&&t.d(s,{useRouter:function(){return r.useRouter}}),t.o(r,"useSearchParams")&&t.d(s,{useSearchParams:function(){return r.useSearchParams}})},8260:(e,s,t)=>{Promise.resolve().then(t.bind(t,526))},9447:()=>{}},e=>{e.O(0,[1870,2108,8441,5964,7358],()=>e(e.s=8260)),_N_E=e.O()}]);