diff --git a/src/app/providers/auth/index.tsx b/src/app/providers/auth/index.tsx index 564c313..5eb58e7 100644 --- a/src/app/providers/auth/index.tsx +++ b/src/app/providers/auth/index.tsx @@ -1,10 +1,9 @@ -import axios from 'axios' import { createContext, ReactNode, useContext, useState } from 'react' import { useNavigate } from 'react-router-dom' import { RoutePath } from '@/app/providers/router/config' -import { RefereshTokenDto, UserDto } from '@/entities/auth/dto' -import { urlApi } from '@/shared/lib/baseApi' +import { refreshToken } from '@/entities/auth/api' +import { UserDto } from '@/entities/auth/dto' interface AuthContextProps { user: UserDto @@ -48,16 +47,7 @@ export const AuthProvider = ({ children }: AuthProviderProps) => { const checkAuthUser = async () => { setLoading(true) try { - const response = await axios.post( - `${urlApi}/auth/refresh`, - {}, - { - headers: { - 'Secret-Access-Token': import.meta.env.VITE_BASE_AUTH_KEY, - }, - withCredentials: true, - }, - ) + const response = await refreshToken() localStorage.setItem('token', response.data.accessToken) setUser(response.data.user) setIsAuthenticated(true) diff --git a/src/entities/auth/api.ts b/src/entities/auth/api.ts index 899e056..f7c4aae 100644 --- a/src/entities/auth/api.ts +++ b/src/entities/auth/api.ts @@ -1,6 +1,7 @@ import { AxiosResponse } from 'axios' import { + RefereshTokenDto, UserSignInDto, UserSignInDtoResponse, UserSignUpContext, @@ -20,3 +21,9 @@ export const signUp = async ( ): Promise> => { return baseApi.post('/auth/sign-up', body) } + +export const refreshToken = async (): Promise< + AxiosResponse +> => { + return baseApi.get('/auth/refresh') +} diff --git a/src/pages/Profile.tsx b/src/pages/Profile.tsx index 3d88bca..ee25001 100644 --- a/src/pages/Profile.tsx +++ b/src/pages/Profile.tsx @@ -36,7 +36,7 @@ const formSchemaApplicant = z.object({ .min(50, { message: 'Должно быть не менее 50 символов', }) - .max(450), + .max(1450), }) const formSchemaRecruiter = z.object({ diff --git a/src/pages/SignIn.tsx b/src/pages/SignIn/SignIn.tsx similarity index 100% rename from src/pages/SignIn.tsx rename to src/pages/SignIn/SignIn.tsx diff --git a/src/pages/SignIn/model.ts b/src/pages/SignIn/model.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/pages/index.ts b/src/pages/index.ts index a185398..6d30c0a 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -11,7 +11,7 @@ export const CreateVacancyPage = lazy(() => import('./CreateVacancy')) export const ProfilePage = lazy(() => import('./Profile')) export const CandidateProfilePage = lazy(() => import('./CandidateProfile')) export const SignUpPage = lazy(() => import('./SignUp/SignUp')) -export const SignInPage = lazy(() => import('./SignIn')) +export const SignInPage = lazy(() => import('./SignIn/SignIn')) export const ErrorPage = lazy(() => import('./Error')) export const VacanciesStatisticsPage = lazy( () => import('./VacanciesStatistics'), diff --git a/src/widgets/LoginForm.tsx b/src/widgets/LoginForm.tsx index 25013ee..dc085d3 100644 --- a/src/widgets/LoginForm.tsx +++ b/src/widgets/LoginForm.tsx @@ -50,8 +50,6 @@ export const LoginForm = () => { }) const onSubmit = async (values: z.infer) => { - // Do something with the form values. - // ✅ This will be type-safe and validated. signInUser(values) } diff --git a/src/widgets/ProfileForm/JobExpirience.tsx b/src/widgets/ProfileForm/JobExpirience.tsx index 20b8529..adce23c 100644 --- a/src/widgets/ProfileForm/JobExpirience.tsx +++ b/src/widgets/ProfileForm/JobExpirience.tsx @@ -116,7 +116,7 @@ export const JobExpirience = ({ user }: JobExperienceProps) => { - + Добавить место работы