1 line
21 KiB
JavaScript
1 line
21 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[824],{8436:(e,t,s)=>{Promise.resolve().then(s.bind(s,5793))},5793:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>k});var a=s(5155),r=s(2115),i=s(6046),n=s(9606),l=s(2679),o=s(534),c=s(3312),d=s(3900),u=s(8986),f=s(9749),m=s(2291),h=s(2928),p=s(4505),x=s(6336),g=s(6889),y=s(1902),b=s(1719);let v=(0,s(7711).default)(()=>Promise.all([s.e(4),s.e(277),s.e(445),s.e(896)]).then(s.bind(s,2896)).then(e=>e.RichTextEditor),{loadableGenerated:{webpack:()=>[2896]},ssr:!1}),w=o.Ikc({description:o.YjP().min(50,"Описание должно содержать минимум 50 символов").max(2048,"Описание не может превышать 2048 символов"),location:o.YjP().min(1,"Укажите базовую локацию"),workSchedule:o.Ikc({isAlwaysReady:o.zMY(),schedulePerDay:o.g1P(o.YjP(),o.YOg(o.Ikc({start:o.YjP().regex(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,"Неверный формат времени").optional(),end:o.YjP().regex(/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/,"Неверный формат времени").optional()})))})}),j=["Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье"],N=(()=>{let e=[];for(let t=0;t<24;t++)for(let s=0;s<60;s+=30){let a=t.toString().padStart(2,"0"),r=s.toString().padStart(2,"0");e.push("".concat(a,":").concat(r))}return e})();function k(){let e=(0,i.useRouter)(),{user:t,isLoading:s,getProfile:o,becomePerformerFull:k}=(0,h.B)(),[C,L]=r.useState([]),[A,S]=r.useState(""),[P,R]=r.useState({Понедельник:[],Вторник:[],Среда:[],Четверг:[],Пятница:[],Суббота:[],Воскресенье:[]}),[T,F]=r.useState(!1),[E,D]=r.useState(1),[z,_]=r.useState(null),I=(0,n.mN)({resolver:(0,l.u)(w),defaultValues:{description:"",location:"",workSchedule:{isAlwaysReady:!0,schedulePerDay:P}}}),$=I.watch("workSchedule.isAlwaysReady"),B=I.watch("description"),V=e=>{var t;let s=document.createElement("div");return s.innerHTML=e,(null===(t=s.textContent)||void 0===t?void 0:t.length)||0},J=B?V(B):0,Y=I.watch("location"),O=J>=50&&C.length>=1&&Y.length>=1,q=()=>{A.trim()&&!C.includes(A.trim())&&(L([...C,A.trim()]),S(""))},M=e=>{L(C.filter(t=>t!==e))},U=e=>{$&&I.setValue("workSchedule.isAlwaysReady",!1);let t={...P};t[e].length>0?t[e]=[]:t[e]=[{start:"09:00",end:"18:00"}],R(t)},W=e=>{$&&I.setValue("workSchedule.isAlwaysReady",!1);let t={...P};t[e]=[...t[e]||[],{start:"00:00",end:"00:00"}],R(t)},Z=(e,t)=>{let s={...P},a=s[e].filter((e,s)=>s!==t);s[e]=a,R(s)},H=(e,t,s,a)=>{$&&I.setValue("workSchedule.isAlwaysReady",!1);let r={...P};r[e][t][s]=a,R(r)};r.useEffect(()=>{let e=setTimeout(async()=>{if(Y.length<2){_(null);return}try{let e=await fetch("https://nominatim.openstreetmap.org/search?format=json&q=".concat(encodeURIComponent(Y),"&limit=5&addressdetails=1&countrycodes=ru"),{headers:{"Accept-Language":"ru"}}),t=(await e.json()).map(e=>{let t=e.address.city||e.address.town||e.address.village||"",s=e.address.road||"",a=e.address.house_number||"";return[t,s,a].filter(Boolean).join(", ")});_(t.length>0?t[0]:null)}catch(e){console.error("Ошибка поиска адресов:",e),_(null)}},300);return()=>clearTimeout(e)},[Y]);let K=e=>{I.setValue("location",e)},G=z&&z.toLowerCase().startsWith(Y.toLowerCase()),Q=async t=>{try{let s=V(t.description);if(s<50){alert("Описание должно содержать минимум 50 символов. Текущая длина: ".concat(s));return}await k({description:t.description,competencies:C,location:t.location,workSchedule:{isAlwaysReady:t.workSchedule.isAlwaysReady,schedulePerDay:P}}),e.push("/dashboard/profile")}catch(e){console.error("Failed to become performer",e)}};r.useEffect(()=>{o()},[o]),r.useEffect(()=>{s||t?t&&(t.roles.includes("Master")||t.roles.includes("Candidate"))&&e.push("/dashboard/profile"):e.push("/auth/login")},[s,t,e]);let[X,ee]=r.useState(!1);return(r.useEffect(()=>{ee(!0)},[]),X)?(0,a.jsxs)("div",{className:"container max-w-4xl mx-auto py-8 px-4",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold mb-2",children:"Стать исполнителем"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"Заполните информацию о себе, чтобы начать принимать заказы"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center mb-8 gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat(1===E?"text-blue-600":"text-muted-foreground"),children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center border-2 ".concat(1===E?"border-blue-600 bg-blue-600 text-white":"border-muted"),children:E>1?(0,a.jsx)(x.A,{className:"w-4 h-4"}):"1"}),(0,a.jsx)("span",{className:"font-medium",children:"Основная информация"})]}),(0,a.jsx)("div",{className:"w-16 h-0.5 ".concat(E>1?"bg-blue-600":"bg-muted")}),(0,a.jsxs)("div",{className:"flex items-center gap-2 ".concat(2===E?"text-blue-600":"text-muted-foreground"),children:[(0,a.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center border-2 ".concat(2===E?"border-blue-600 bg-blue-600 text-white":"border-muted"),children:"2"}),(0,a.jsx)("span",{className:"font-medium",children:"График работы"})]})]}),(0,a.jsx)("form",{onSubmit:I.handleSubmit(Q),children:(0,a.jsx)(f.Zp,{children:(0,a.jsxs)(f.Wu,{className:"pt-6",children:[1===E&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(u.J,{htmlFor:"description",children:["Описание ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Расскажите о себе, своем опыте и услугах (минимум 50 символов)"}),(0,a.jsx)(v,{content:I.watch("description")||"",onChange:e=>I.setValue("description",e),placeholder:"Опишите свой опыт, навыки и услуги, которые вы предоставляте...",maxLength:2048}),(0,a.jsxs)("div",{className:"flex justify-between text-sm",children:[I.formState.errors.description?(0,a.jsx)("p",{className:"text-red-500",children:I.formState.errors.description.message}):(0,a.jsx)("p",{className:"text-muted-foreground",children:J>=50?"✓ Минимум достигнут":"".concat(50-J," символов до минимума")}),(0,a.jsxs)("p",{className:"text-muted-foreground",children:[J," / 2048"]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(u.J,{children:["Компетенции ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Укажите навыки и услуги, которые вы предоставляете"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(d.p,{placeholder:"Например: Сантехника, Электрика",value:A,onChange:e=>S(e.target.value),onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),q())}}),(0,a.jsx)(c.$,{type:"button",onClick:q,children:"Добавить"})]}),C.length>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:C.map(e=>(0,a.jsxs)("div",{className:"bg-blue-100 text-blue-700 px-3 py-1 rounded-full text-sm flex items-center gap-2",children:[e,(0,a.jsx)("button",{type:"button",onClick:()=>M(e),className:"hover:text-blue-900",children:"\xd7"})]},e))})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)(u.J,{htmlFor:"location",children:["Базовая локация ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Укажите адрес (Tab для выбора подсказки)"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(d.p,{id:"location",placeholder:"Город, улица, дом",value:Y,onChange:e=>K(e.target.value),onKeyDown:e=>{"Tab"===e.key&&z?(e.preventDefault(),I.setValue("location",z),_(null)):"Escape"===e.key&&_(null)},onBlur:()=>_(null),autoComplete:"off",className:"text-base"}),G&&(0,a.jsxs)("div",{className:"absolute inset-y-0 left-0 pointer-events-none flex items-center px-3",children:[(0,a.jsx)("span",{className:"text-base text-transparent",children:Y}),(0,a.jsx)("span",{className:"text-base text-muted-foreground",children:z.slice(Y.length)})]})]}),I.formState.errors.location&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:I.formState.errors.location.message})]}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(c.$,{type:"button",onClick:()=>D(2),disabled:!O,children:"Далее"})})]}),2===E&&(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,a.jsx)(m.S,{id:"always-ready",checked:$,onCheckedChange:e=>{I.setValue("workSchedule.isAlwaysReady",e),e&&R({Понедельник:[],Вторник:[],Среда:[],Четверг:[],Пятница:[],Суббота:[],Воскресенье:[]})}}),(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)(u.J,{htmlFor:"always-ready",className:"cursor-pointer",children:"Всегда готов к заказам"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Если включено, клиенты будут видеть вас доступным в любое время"})]})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)(c.$,{type:"button",variant:"outline",className:"w-full justify-between",onClick:()=>F(!T),children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(g.A,{className:"w-4 h-4"}),"Настроить расписание"]}),T?(0,a.jsx)(y.A,{className:"w-4 h-4"}):(0,a.jsx)(b.A,{className:"w-4 h-4"})]}),T&&(0,a.jsxs)("div",{className:"space-y-3 mt-4",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"Для каждого дня недели укажите периоды работы. Если для дня нет расписания - работает 24 часа."}),j.map(e=>{var t,s,r;return(0,a.jsxs)("div",{className:"border rounded-lg p-4 space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(m.S,{id:e,checked:(null===(t=P[e])||void 0===t?void 0:t.length)>0,onCheckedChange:()=>U(e)}),(0,a.jsx)("label",{htmlFor:e,className:"font-medium cursor-pointer flex-1",children:e}),(null===(s=P[e])||void 0===s?void 0:s.length)>0&&(0,a.jsx)(c.$,{type:"button",variant:"outline",size:"sm",onClick:()=>W(e),children:"+ Добавить период"})]}),null===(r=P[e])||void 0===r?void 0:r.map((t,s)=>{var r;return(0,a.jsxs)("div",{className:"flex items-center gap-2 pl-7",children:[(0,a.jsxs)("select",{className:"flex h-9 w-32 rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",value:t.start,onChange:t=>H(e,s,"start",t.target.value),children:[(0,a.jsx)("option",{value:"",disabled:!0,children:"Начало"}),N.map(e=>(0,a.jsx)("option",{value:e,children:e},"start-".concat(e)))]}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"—"}),(0,a.jsxs)("select",{className:"flex h-9 w-32 rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",value:t.end,onChange:t=>H(e,s,"end",t.target.value),children:[(0,a.jsx)("option",{value:"",disabled:!0,children:"Конец"}),N.filter(e=>e>t.start).map(e=>(0,a.jsx)("option",{value:e,children:e},"end-".concat(e)))]}),(null===(r=P[e])||void 0===r?void 0:r.length)>1&&(0,a.jsx)(c.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>Z(e,s),className:"text-red-500 hover:text-red-700",children:"Удалить"})]},s)})]},e)})]})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)(c.$,{type:"button",variant:"outline",onClick:()=>D(1),children:"Назад"}),(0,a.jsxs)(c.$,{type:"submit",disabled:s,children:[s&&(0,a.jsx)(p.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Стать исполнителем"]})]})]})]})})})]}):(0,a.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,a.jsx)(p.A,{className:"w-8 h-8 animate-spin"})})}},3312:(e,t,s)=>{"use strict";s.d(t,{$:()=>c});var a=s(5155),r=s(2115),i=s(2317),n=s(1027),l=s(7549);let o=(0,n.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"}}),c=r.forwardRef((e,t)=>{let{className:s,variant:r,size:n,asChild:c=!1,...d}=e,u=c?i.DX:"button";return(0,a.jsx)(u,{className:(0,l.cn)(o({variant:r,size:n,className:s})),ref:t,...d})});c.displayName="Button"},9749:(e,t,s)=>{"use strict";s.d(t,{BT:()=>c,Wu:()=>d,ZB:()=>o,Zp:()=>n,aR:()=>l,wL:()=>u});var a=s(5155),r=s(2115),i=s(7549);let n=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...r})});n.displayName="Card";let l=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("flex flex-col space-y-1.5 p-6",s),...r})});l.displayName="CardHeader";let o=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("h3",{ref:t,className:(0,i.cn)("text-2xl font-semibold leading-none tracking-tight",s),...r})});o.displayName="CardTitle";let c=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("p",{ref:t,className:(0,i.cn)("text-sm text-muted-foreground",s),...r})});c.displayName="CardDescription";let d=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("p-6 pt-0",s),...r})});d.displayName="CardContent";let u=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("flex items-center p-6 pt-0",s),...r})});u.displayName="CardFooter"},2291:(e,t,s)=>{"use strict";s.d(t,{S:()=>o});var a=s(5155),r=s(2115),i=s(6352),n=s(8867),l=s(7549);let o=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(i.bL,{ref:t,className:(0,l.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...r,children:(0,a.jsx)(i.C1,{className:(0,l.cn)("flex items-center justify-center text-current"),children:(0,a.jsx)(n.A,{className:"h-4 w-4"})})})});o.displayName=i.bL.displayName},3900:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var a=s(5155),r=s(2115),i=s(7549);let n=r.forwardRef((e,t)=>{let{className:s,type:r,...n}=e;return(0,a.jsx)("input",{type:r,className:(0,i.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:t,...n})});n.displayName="Input"},8986:(e,t,s)=>{"use strict";s.d(t,{J:()=>c});var a=s(5155),r=s(2115),i=s(4352),n=s(1027),l=s(7549);let o=(0,n.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(i.b,{ref:t,className:(0,l.cn)(o(),s),...r})});c.displayName=i.b.displayName},2928:(e,t,s)=>{"use strict";s.d(t,{B:()=>n});var a=s(9827),r=s(3030),i=s(3705);let n=(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:n,refreshToken:l}=(await i.F.post("/auth/login",{phone:s,password:a})).data;(0,r.setCookie)("accessToken",n),(0,r.setCookie)("refreshToken",l),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 n=s?"[]":JSON.stringify(a||{});await i.F.put("/profile/schedule",{accountId:e,isAlwaysReady:s,workingDaysJson:n}),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 n=!1,l=[],o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;l.forEach(s=>{e?s.reject(e):s.resolve(t)}),l=[]};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(n)return new Promise((e,t)=>{l.push({resolve:e,reject:t})}).then(e=>(s.headers.Authorization="Bearer ".concat(e),i(s))).catch(e=>Promise.reject(e));s._retry=!0,n=!0;let e=(0,r.getCookie)("refreshToken");try{let{accessToken:t,refreshToken:n}=(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",n),i.defaults.headers.common.Authorization="Bearer ".concat(t),o(null,t),i(s)}catch(e){return o(e,null),(0,r.deleteCookie)("accessToken"),(0,r.deleteCookie)("refreshToken"),window.location.href="/auth/login",Promise.reject(e)}finally{n=!1}}return Promise.reject(e)})},7549:(e,t,s)=>{"use strict";s.d(t,{cn:()=>i,n:()=>n});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 n(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}}},e=>{var t=t=>e(e.s=t);e.O(0,[92,273,44,441,517,358],()=>t(8436)),_N_E=e.O()}]); |