1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{8496:(e,t,a)=>{Promise.resolve().then(a.t.bind(a,1791,23)),Promise.resolve().then(a.t.bind(a,347,23)),Promise.resolve().then(a.bind(a,2673)),Promise.resolve().then(a.bind(a,4674)),Promise.resolve().then(a.bind(a,6795)),Promise.resolve().then(a.bind(a,2599))},2673:(e,t,a)=>{"use strict";a.d(t,{AuthProvider:()=>n});var r=a(5155),s=a(2115),o=a(2928),i=a(4505);function n(e){let{children:t}=e,{checkAuth:a,isInitialized:n}=(0,o.B)();return((0,s.useEffect)(()=>{a()},[a]),n)?(0,r.jsx)(r.Fragment,{children:t}):(0,r.jsx)("div",{className:"flex min-h-screen items-center justify-center",children:(0,r.jsx)(i.A,{className:"h-8 w-8 animate-spin text-blue-600"})})}},4674:(e,t,a)=>{"use strict";a.d(t,{ThemeProvider:()=>o});var r=a(5155);a(2115);var s=a(7113);function o(e){let{children:t,...a}=e;return(0,r.jsx)(s.N,{...a,children:t})}},3312:(e,t,a)=>{"use strict";a.d(t,{$:()=>d});var r=a(5155),s=a(2115),o=a(2317),i=a(1027),n=a(7549);let l=(0,i.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=s.forwardRef((e,t)=>{let{className:a,variant:s,size:i,asChild:d=!1,...c}=e,u=d?o.DX:"button";return(0,r.jsx)(u,{className:(0,n.cn)(l({variant:s,size:i,className:a})),ref:t,...c})});d.displayName="Button"},6795:(e,t,a)=>{"use strict";a.d(t,{Toaster:()=>i});var r=a(5155),s=a(7113),o=a(814);let i=e=>{let{...t}=e,{theme:a="system"}=(0,s.D)();return(0,r.jsx)(o.l$,{theme:a,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,a)=>{"use strict";a.d(t,{B:()=>i});var r=a(9827),s=a(3030),o=a(3705);let i=(0,r.v)((e,t)=>({user:null,isAuth:!1,isLoading:!1,isInitialized:!1,checkAuth:async()=>{if(!(0,s.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,s.deleteCookie)("accessToken"),(0,s.deleteCookie)("refreshToken"),e({user:null,isAuth:!1,isInitialized:!0})}finally{e({isLoading:!1})}},login:async(a,r)=>{e({isLoading:!0});try{let{accessToken:i,refreshToken:n}=(await o.F.post("/auth/login",{phone:a,password:r})).data;(0,s.setCookie)("accessToken",i),(0,s.setCookie)("refreshToken",n),e({isAuth:!0}),await t().getProfile()}finally{e({isLoading:!1})}},register:async t=>{e({isLoading:!0});try{let{confirmPassword:e,...a}=t;await o.F.post("/auth/register",a)}finally{e({isLoading:!1})}},logout:()=>{(0,s.deleteCookie)("accessToken"),(0,s.deleteCookie)("refreshToken"),e({user:null,isAuth:!1}),window.location.href="/auth/login"},getProfile:async()=>{try{let t=await o.F.get("/profile",{params:{_t:Date.now()}});e({user:t.data,isAuth:!0})}catch(e){console.error("Profile load failed",e)}},updateProfile:async a=>{e({isLoading:!0});try{await o.F.put("/profile",a),await t().getProfile()}finally{e({isLoading:!1})}},changePhone:async a=>{e({isLoading:!0});try{await o.F.post("/profile/change-phone",{newPhone:a}),await t().getProfile()}finally{e({isLoading:!1})}},becomePerformer:async()=>{e({isLoading:!0});try{await o.F.post("/profile/become-performer"),await t().getProfile()}finally{e({isLoading:!1})}},becomePerformerFull:async a=>{e({isLoading:!0});try{await o.F.post("/profile/become-performer",{description:a.description,competencies:a.competencies,location:a.location,currentLocation:null,isAlwaysReady:a.workSchedule.isAlwaysReady,workingDays:a.workSchedule.isAlwaysReady?null:JSON.stringify(a.workSchedule.schedulePerDay)}),await t().getProfile()}finally{e({isLoading:!1})}},updateCompetencies:async a=>{e({isLoading:!0});try{await o.F.put("/profile/competencies",{Competencies:a}),await t().getProfile()}finally{e({isLoading:!1})}},uploadAvatar:async a=>{e({isLoading:!0});try{let e=new FormData;e.append("file",a),await o.F.post("/profile/avatar",e,{headers:{"Content-Type":"multipart/form-data"}}),await t().getProfile()}finally{e({isLoading:!1})}},changePassword:async(a,r)=>{e({isLoading:!0});try{var s;let e=null===(s=t().user)||void 0===s?void 0:s.id;if(!e)throw Error("Пользователь не авторизован");await o.F.post("/profile/change-password",{accountId:e,oldPassword:a,newPassword:r})}finally{e({isLoading:!1})}},updateLocation:async(a,r)=>{e({isLoading:!0});try{var s;let e=null===(s=t().user)||void 0===s?void 0:s.id;if(!e)throw Error("Пользователь не авторизован");await o.F.put("/profile/location",{accountId:e,location:a,currentLocation:r}),await t().getProfile()}finally{e({isLoading:!1})}},updateSchedule:async(a,r)=>{e({isLoading:!0});try{var s;let e=null===(s=t().user)||void 0===s?void 0:s.id;if(!e)throw Error("Пользователь не авторизован");let i=a?"[]":JSON.stringify(r||{});await o.F.put("/profile/schedule",{accountId:e,isAlwaysReady:a,workingDaysJson:i}),await t().getProfile()}finally{e({isLoading:!1})}}}))},3705:(e,t,a)=>{"use strict";a.d(t,{F:()=>o});var r=a(2651),s=a(3030);let o=r.A.create({baseURL:"http://127.0.0.1:5000/api",headers:{"Content-Type":"application/json"}});o.interceptors.request.use(e=>{let t=(0,s.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 i=!1,n=[],l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;n.forEach(a=>{e?a.reject(e):a.resolve(t)}),n=[]};o.interceptors.response.use(e=>e,async e=>{var t;let a=e.config;if((null===(t=e.response)||void 0===t?void 0:t.status)===401&&!a._retry){if(i)return new Promise((e,t)=>{n.push({resolve:e,reject:t})}).then(e=>(a.headers.Authorization="Bearer ".concat(e),o(a))).catch(e=>Promise.reject(e));a._retry=!0,i=!0;let e=(0,s.getCookie)("refreshToken");try{let{accessToken:t,refreshToken:i}=(await r.A.post("".concat("http://127.0.0.1:5000/api","/auth/refresh"),{refreshToken:e})).data;return(0,s.setCookie)("accessToken",t),(0,s.setCookie)("refreshToken",i),o.defaults.headers.common.Authorization="Bearer ".concat(t),l(null,t),o(a)}catch(e){return l(e,null),(0,s.deleteCookie)("accessToken"),(0,s.deleteCookie)("refreshToken"),window.location.href="/auth/login",Promise.reject(e)}finally{i=!1}}return Promise.reject(e)})},7549:(e,t,a)=>{"use strict";a.d(t,{cn:()=>o,n:()=>i});var r=a(3463),s=a(9795);function o(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,s.QP)((0,r.$)(t))}function i(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,a)=>{"use strict";a.d(t,{Header:()=>k});var r=a(5155),s=a(8173),o=a.n(s),i=a(2115),n=a(7725),l=a(2104),d=a(7113),c=a(3312),u=a(8385),f=a(6967),m=a(8867),h=a(3565),p=a(7549);let g=u.bL,x=u.l9;u.YJ,u.ZL,u.Pb,u.z6,i.forwardRef((e,t)=>{let{className:a,inset:s,children:o,...i}=e;return(0,r.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",s&&"pl-8",a),...i,children:[o,(0,r.jsx)(f.A,{className:"ml-auto h-4 w-4"})]})}).displayName=u.ZP.displayName,i.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.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",a),...s})}).displayName=u.G5.displayName;let y=i.forwardRef((e,t)=>{let{className:a,sideOffset:s=4,...o}=e;return(0,r.jsx)(u.ZL,{children:(0,r.jsx)(u.UC,{ref:t,sideOffset:s,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",a),...o})})});y.displayName=u.UC.displayName;let v=i.forwardRef((e,t)=>{let{className:a,inset:s,...o}=e;return(0,r.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",s&&"pl-8",a),...o})});function b(){let{setTheme:e}=(0,d.D)();return(0,r.jsxs)(g,{children:[(0,r.jsx)(x,{asChild:!0,children:(0,r.jsxs)(c.$,{variant:"outline",size:"icon",className:"rounded-full",children:[(0,r.jsx)(n.A,{className:"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),(0,r.jsx)(l.A,{className:"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),(0,r.jsx)("span",{className:"sr-only",children:"Toggle theme"})]})}),(0,r.jsxs)(y,{align:"end",children:[(0,r.jsx)(v,{onClick:()=>e("light"),children:"Светлая"}),(0,r.jsx)(v,{onClick:()=>e("dark"),children:"Темная"}),(0,r.jsx)(v,{onClick:()=>e("system"),children:"Системная"})]})]})}v.displayName=u.q7.displayName,i.forwardRef((e,t)=>{let{className:a,children:s,checked:o,...i}=e;return(0,r.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",a),checked:o,...i,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(u.VF,{children:(0,r.jsx)(m.A,{className:"h-4 w-4"})})}),s]})}).displayName=u.H_.displayName,i.forwardRef((e,t)=>{let{className:a,children:s,...o}=e;return(0,r.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",a),...o,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(u.VF,{children:(0,r.jsx)(h.A,{className:"h-2 w-2 fill-current"})})}),s]})}).displayName=u.hN.displayName,i.forwardRef((e,t)=>{let{className:a,inset:s,...o}=e;return(0,r.jsx)(u.JU,{ref:t,className:(0,p.cn)("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",a),...o})}).displayName=u.JU.displayName,i.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(u.wv,{ref:t,className:(0,p.cn)("-mx-1 my-1 h-px bg-muted",a),...s})}).displayName=u.wv.displayName;var w=a(853),N=a(1466),j=a(2928);function k(){var e,t,a;let{isAuth:s,user:i}=(0,j.B)(),n=(null==i?void 0:null===(e=i.roles)||void 0===e?void 0:e.includes("Master"))||(null==i?void 0:null===(t=i.roles)||void 0===t?void 0:t.includes("Company"));return(0,r.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,r.jsxs)("div",{className:"container mx-auto flex h-16 items-center justify-between px-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-8",children:[(0,r.jsx)(o(),{href:"/",className:"flex items-center space-x-2",children:(0,r.jsx)("span",{className:"text-2xl font-black tracking-tight text-blue-600 dark:text-blue-500",children:"Nashel"})}),(0,r.jsxs)("nav",{className:"hidden md:flex gap-6 items-center text-sm font-medium transition-colors",children:[(0,r.jsxs)(o(),{href:"/map",className:"flex items-center gap-2 hover:text-blue-600",children:[(0,r.jsx)(w.A,{className:"h-4 w-4"}),"Поиск"]}),(0,r.jsx)(o(),{href:"/orders",className:"hover:text-blue-600",children:"Мои заказы"})]})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(b,{}),s?(0,r.jsx)(c.$,{variant:"ghost",asChild:!0,className:"hidden sm:flex items-center gap-2",children:(0,r.jsxs)(o(),{href:"/dashboard/profile",children:[(0,r.jsx)(N.A,{className:"h-4 w-4"}),(null==i?void 0:null===(a=i.roles)||void 0===a?void 0:a.includes("Company"))&&(null==i?void 0:i.companyName)?i.companyName:(null==i?void 0:i.firstName)&&(null==i?void 0:i.lastName)?"".concat(i.firstName," ").concat(i.lastName):"Профиль"]})}):(0,r.jsx)(c.$,{variant:"ghost",asChild:!0,className:"hidden sm:flex items-center gap-2",children:(0,r.jsxs)(o(),{href:"/auth/login",children:[(0,r.jsx)(N.A,{className:"h-4 w-4"}),"Войти"]})}),n?(0,r.jsx)(c.$,{className:"bg-blue-600 hover:bg-blue-700 text-white",asChild:!0,children:(0,r.jsx)(o(),{href:"/orders",children:"Подобрать заказы"})}):(0,r.jsx)(c.$,{className:"bg-blue-600 hover:bg-blue-700 text-white",asChild:!0,children:(0,r.jsx)(o(),{href:"/dashboard/become-performer",children:"Стать исполнителем"})})]})]})})}},347:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[189,92,173,634,554,139,164,441,517,358],()=>t(8496)),_N_E=e.O()}]); |