Files
nashel-frontend/.next/static/chunks/app/layout-7012f6f0145b8f97.js
T

1 line
15 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{8496:(e,t,s)=>{Promise.resolve().then(s.t.bind(s,1791,23)),Promise.resolve().then(s.t.bind(s,347,23)),Promise.resolve().then(s.bind(s,2673)),Promise.resolve().then(s.bind(s,4674)),Promise.resolve().then(s.bind(s,6795)),Promise.resolve().then(s.bind(s,2599))},2673:(e,t,s)=>{"use strict";s.d(t,{AuthProvider:()=>n});var a=s(5155),r=s(2115),i=s(2928),o=s(4505);function n(e){let{children:t}=e,{checkAuth:s,isInitialized:n}=(0,i.B)();return((0,r.useEffect)(()=>{s()},[s]),n)?(0,a.jsx)(a.Fragment,{children:t}):(0,a.jsx)("div",{className:"flex min-h-screen items-center justify-center",children:(0,a.jsx)(o.A,{className:"h-8 w-8 animate-spin text-blue-600"})})}},4674:(e,t,s)=>{"use strict";s.d(t,{ThemeProvider:()=>i});var a=s(5155);s(2115);var r=s(7113);function i(e){let{children:t,...s}=e;return(0,a.jsx)(r.N,{...s,children:t})}},3312:(e,t,s)=>{"use strict";s.d(t,{$:()=>d});var a=s(5155),r=s(2115),i=s(2317),o=s(1027),n=s(7549);let l=(0,o.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=r.forwardRef((e,t)=>{let{className:s,variant:r,size:o,asChild:d=!1,...c}=e,u=d?i.DX:"button";return(0,a.jsx)(u,{className:(0,n.cn)(l({variant:r,size:o,className:s})),ref:t,...c})});d.displayName="Button"},6795:(e,t,s)=>{"use strict";s.d(t,{Toaster:()=>o});var a=s(5155),r=s(7113),i=s(814);let o=e=>{let{...t}=e,{theme:s="system"}=(0,r.D)();return(0,a.jsx)(i.l$,{theme:s,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toaster]:text-muted-foreground",actionButton:"group-[.toaster]:bg-primary group-[.toaster]:text-primary-foreground",cancelButton:"group-[.toaster]:bg-muted group-[.toaster]:text-muted-foreground"}},...t})}},2928:(e,t,s)=>{"use strict";s.d(t,{B:()=>o});var a=s(9827),r=s(3030),i=s(3705);let o=(0,a.v)((e,t)=>({user:null,isAuth:!1,isLoading:!1,isInitialized:!1,checkAuth:async()=>{if(!(0,r.getCookie)("accessToken")){e({isInitialized:!0,isAuth:!1});return}e({isLoading:!0});try{await t().getProfile(),e({isAuth:!0,isInitialized:!0})}catch(t){console.error("Auth check failed",t),(0,r.deleteCookie)("accessToken"),(0,r.deleteCookie)("refreshToken"),e({user:null,isAuth:!1,isInitialized:!0})}finally{e({isLoading:!1})}},login:async(s,a)=>{e({isLoading:!0});try{let{accessToken:o,refreshToken:n}=(await i.F.post("/auth/login",{phone:s,password:a})).data;(0,r.setCookie)("accessToken",o),(0,r.setCookie)("refreshToken",n),e({isAuth:!0}),await t().getProfile()}finally{e({isLoading:!1})}},register:async t=>{e({isLoading:!0});try{let{confirmPassword:e,...s}=t;await i.F.post("/auth/register",s)}finally{e({isLoading:!1})}},logout:()=>{(0,r.deleteCookie)("accessToken"),(0,r.deleteCookie)("refreshToken"),e({user:null,isAuth:!1}),window.location.href="/auth/login"},getProfile:async()=>{try{let t=await i.F.get("/profile",{params:{_t:Date.now()}});e({user:t.data,isAuth:!0})}catch(e){console.error("Profile load failed",e)}},updateProfile:async s=>{e({isLoading:!0});try{await i.F.put("/profile",s),await t().getProfile()}finally{e({isLoading:!1})}},changePhone:async s=>{e({isLoading:!0});try{await i.F.post("/profile/change-phone",{newPhone:s}),await t().getProfile()}finally{e({isLoading:!1})}},becomePerformer:async()=>{e({isLoading:!0});try{await i.F.post("/profile/become-performer"),await t().getProfile()}finally{e({isLoading:!1})}},becomePerformerFull:async s=>{e({isLoading:!0});try{await i.F.post("/profile/become-performer",{description:s.description,competencies:s.competencies,location:s.location,currentLocation:null,isAlwaysReady:s.workSchedule.isAlwaysReady,workingDays:s.workSchedule.isAlwaysReady?null:JSON.stringify(s.workSchedule.schedulePerDay)}),await t().getProfile()}finally{e({isLoading:!1})}},updateCompetencies:async s=>{e({isLoading:!0});try{await i.F.put("/profile/competencies",{Competencies:s}),await t().getProfile()}finally{e({isLoading:!1})}},uploadAvatar:async s=>{e({isLoading:!0});try{let e=new FormData;e.append("file",s),await i.F.post("/profile/avatar",e,{headers:{"Content-Type":"multipart/form-data"}}),await t().getProfile()}finally{e({isLoading:!1})}},changePassword:async(s,a)=>{e({isLoading:!0});try{var r;let e=null===(r=t().user)||void 0===r?void 0:r.id;if(!e)throw Error("Пользователь не авторизован");await i.F.post("/profile/change-password",{accountId:e,oldPassword:s,newPassword:a})}finally{e({isLoading:!1})}},updateLocation:async(s,a)=>{e({isLoading:!0});try{var r;let e=null===(r=t().user)||void 0===r?void 0:r.id;if(!e)throw Error("Пользователь не авторизован");await i.F.put("/profile/location",{accountId:e,location:s,currentLocation:a}),await t().getProfile()}finally{e({isLoading:!1})}},updateSchedule:async(s,a)=>{e({isLoading:!0});try{var r;let e=null===(r=t().user)||void 0===r?void 0:r.id;if(!e)throw Error("Пользователь не авторизован");let o=s?"[]":JSON.stringify(a||{});await i.F.put("/profile/schedule",{accountId:e,isAlwaysReady:s,workingDaysJson:o}),await t().getProfile()}finally{e({isLoading:!1})}}}))},3705:(e,t,s)=>{"use strict";s.d(t,{F:()=>i});var a=s(2651),r=s(3030);let i=a.A.create({baseURL:"http://127.0.0.1:5000/api",headers:{"Content-Type":"application/json"}});i.interceptors.request.use(e=>{let t=(0,r.getCookie)("accessToken");return t&&e.headers&&(e.headers.Authorization="Bearer ".concat(t)),console.log("\uD83D\uDE80 Sending request to: ".concat(e.baseURL).concat(e.url)),e});let o=!1,n=[],l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.forEach(s=>{e?s.reject(e):s.resolve(t)}),n=[]};i.interceptors.response.use(e=>e,async e=>{var t;let s=e.config;if((null===(t=e.response)||void 0===t?void 0:t.status)===401&&!s._retry){if(o)return new Promise((e,t)=>{n.push({resolve:e,reject:t})}).then(e=>(s.headers.Authorization="Bearer ".concat(e),i(s))).catch(e=>Promise.reject(e));s._retry=!0,o=!0;let e=(0,r.getCookie)("refreshToken");try{let{accessToken:t,refreshToken:o}=(await a.A.post("".concat("http://127.0.0.1:5000/api","/auth/refresh"),{refreshToken:e})).data;return(0,r.setCookie)("accessToken",t),(0,r.setCookie)("refreshToken",o),i.defaults.headers.common.Authorization="Bearer ".concat(t),l(null,t),i(s)}catch(e){return l(e,null),(0,r.deleteCookie)("accessToken"),(0,r.deleteCookie)("refreshToken"),window.location.href="/auth/login",Promise.reject(e)}finally{o=!1}}return Promise.reject(e)})},7549:(e,t,s)=>{"use strict";s.d(t,{cn:()=>i,n:()=>o});var a=s(3463),r=s(9795);function i(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.QP)((0,a.$)(t))}function o(e){if(!e)return"—";let t=e.replace(/\D/g,"");if(11===t.length){let e="8"===t[0]?"8":"+7";return"".concat(e," (").concat(t.slice(1,4),") ").concat(t.slice(4,7),"-").concat(t.slice(7,9),"-").concat(t.slice(9,11))}return e}},2599:(e,t,s)=>{"use strict";s.d(t,{Header:()=>L});var a=s(5155),r=s(8173),i=s.n(r),o=s(2115),n=s(7725),l=s(2104),d=s(7113),c=s(3312),u=s(7144),f=s(6967),h=s(8867),m=s(3565),p=s(7549);let g=u.bL,x=u.l9;u.YJ,u.ZL,u.Pb,u.z6,o.forwardRef((e,t)=>{let{className:s,inset:r,children:i,...o}=e;return(0,a.jsxs)(u.ZP,{ref:t,className:(0,p.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",r&&"pl-8",s),...o,children:[i,(0,a.jsx)(f.A,{className:"ml-auto h-4 w-4"})]})}).displayName=u.ZP.displayName,o.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(u.G5,{ref:t,className:(0,p.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...r})}).displayName=u.G5.displayName;let v=o.forwardRef((e,t)=>{let{className:s,sideOffset:r=4,...i}=e;return(0,a.jsx)(u.ZL,{children:(0,a.jsx)(u.UC,{ref:t,sideOffset:r,className:(0,p.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...i})})});v.displayName=u.UC.displayName;let y=o.forwardRef((e,t)=>{let{className:s,inset:r,...i}=e;return(0,a.jsx)(u.q7,{ref:t,className:(0,p.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r&&"pl-8",s),...i})});y.displayName=u.q7.displayName,o.forwardRef((e,t)=>{let{className:s,children:r,checked:i,...o}=e;return(0,a.jsxs)(u.H_,{ref:t,className:(0,p.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),checked:i,...o,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(u.VF,{children:(0,a.jsx)(h.A,{className:"h-4 w-4"})})}),r]})}).displayName=u.H_.displayName,o.forwardRef((e,t)=>{let{className:s,children:r,...i}=e;return(0,a.jsxs)(u.hN,{ref:t,className:(0,p.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...i,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(u.VF,{children:(0,a.jsx)(m.A,{className:"h-2 w-2 fill-current"})})}),r]})}).displayName=u.hN.displayName;let b=o.forwardRef((e,t)=>{let{className:s,inset:r,...i}=e;return(0,a.jsx)(u.JU,{ref:t,className:(0,p.cn)("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",s),...i})});b.displayName=u.JU.displayName;let w=o.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(u.wv,{ref:t,className:(0,p.cn)("-mx-1 my-1 h-px bg-muted",s),...r})});function j(){let{setTheme:e}=(0,d.D)();return(0,a.jsxs)(g,{children:[(0,a.jsx)(x,{asChild:!0,children:(0,a.jsxs)(c.$,{variant:"outline",size:"icon",className:"rounded-full",children:[(0,a.jsx)(n.A,{className:"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),(0,a.jsx)(l.A,{className:"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),(0,a.jsx)("span",{className:"sr-only",children:"Toggle theme"})]})}),(0,a.jsxs)(v,{align:"end",children:[(0,a.jsx)(y,{onClick:()=>e("light"),children:"Светлая"}),(0,a.jsx)(y,{onClick:()=>e("dark"),children:"Темная"}),(0,a.jsx)(y,{onClick:()=>e("system"),children:"Системная"})]})]})}w.displayName=u.wv.displayName;var N=s(853),k=s(1466),C=s(4839),P=s(5236),A=s(2928);function L(){var e,t,s,r;let{isAuth:o,user:n,logout:l}=(0,A.B)(),d=(null==n?void 0:null===(e=n.roles)||void 0===e?void 0:e.includes("Candidate"))||(null==n?void 0:null===(t=n.roles)||void 0===t?void 0:t.includes("Company"))||(null==n?void 0:null===(s=n.roles)||void 0===s?void 0:s.includes("Master"));return(0,a.jsx)("header",{className:"sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",children:(0,a.jsxs)("div",{className:"container mx-auto flex h-16 items-center justify-between px-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-8",children:[(0,a.jsx)(i(),{href:"/",className:"flex items-center space-x-2",children:(0,a.jsx)("span",{className:"text-2xl font-black tracking-tight text-blue-600 dark:text-blue-500",children:"Nashel"})}),(0,a.jsxs)("nav",{className:"hidden md:flex gap-6 items-center text-sm font-medium transition-colors",children:[(0,a.jsxs)(i(),{href:"/map",className:"flex items-center gap-2 hover:text-blue-600",children:[(0,a.jsx)(N.A,{className:"h-4 w-4"}),"Поиск"]}),(0,a.jsx)(i(),{href:"/orders",className:"hover:text-blue-600",children:"Мои заказы"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(j,{}),o?(0,a.jsxs)(g,{children:[(0,a.jsx)(x,{asChild:!0,children:(0,a.jsxs)(c.$,{variant:"ghost",className:"hidden sm:flex items-center gap-2 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus:ring-0 outline-none",children:[(0,a.jsx)(k.A,{className:"h-4 w-4"}),(null==n?void 0:null===(r=n.roles)||void 0===r?void 0:r.includes("Company"))&&(null==n?void 0:n.companyName)?n.companyName:(null==n?void 0:n.firstName)&&(null==n?void 0:n.lastName)?"".concat(n.firstName," ").concat(n.lastName):"Профиль"]})}),(0,a.jsxs)(v,{align:"end",className:"w-56",children:[(0,a.jsx)(b,{children:"Мой аккаунт"}),(0,a.jsx)(w,{}),(0,a.jsx)(y,{asChild:!0,children:(0,a.jsxs)(i(),{href:"/dashboard/profile",className:"cursor-pointer w-full flex items-center",children:[(0,a.jsx)(k.A,{className:"mr-2 h-4 w-4"}),(0,a.jsx)("span",{children:"Профиль"})]})}),(0,a.jsx)(y,{asChild:!0,children:(0,a.jsxs)(i(),{href:"/orders",className:"cursor-pointer w-full flex items-center",children:[(0,a.jsx)(N.A,{className:"mr-2 h-4 w-4"}),(0,a.jsx)("span",{children:"Мои заказы"})]})}),d&&(0,a.jsx)(y,{asChild:!0,children:(0,a.jsxs)(i(),{href:"/dashboard/offers",className:"cursor-pointer w-full flex items-center",children:[(0,a.jsx)(C.A,{className:"mr-2 h-4 w-4"}),(0,a.jsx)("span",{children:"Мои услуги"})]})}),(0,a.jsx)(w,{}),(0,a.jsxs)(y,{className:"text-destructive focus:text-destructive cursor-pointer",onClick:()=>l(),children:[(0,a.jsx)(P.A,{className:"mr-2 h-4 w-4"}),(0,a.jsx)("span",{children:"Выйти из аккаунта"})]})]})]}):(0,a.jsx)(c.$,{variant:"ghost",asChild:!0,className:"hidden sm:flex items-center gap-2",children:(0,a.jsxs)(i(),{href:"/auth/login",children:[(0,a.jsx)(k.A,{className:"h-4 w-4"}),"Войти"]})}),d?(0,a.jsx)(c.$,{className:"bg-blue-600 hover:bg-blue-700 text-white",asChild:!0,children:(0,a.jsx)(i(),{href:"/orders",children:"Подобрать заказы"})}):(0,a.jsx)(c.$,{className:"bg-blue-600 hover:bg-blue-700 text-white",asChild:!0,children:(0,a.jsx)(i(),{href:"/dashboard/become-performer",children:"Стать исполнителем"})})]})]})})}},347:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[189,92,173,814,465,393,31,441,517,358],()=>t(8496)),_N_E=e.O()}]);