From bd911ce600c700e32fdb7537009457fb0b7e3ba5 Mon Sep 17 00:00:00 2001 From: VictoriaBorovskaya Date: Sun, 26 Nov 2023 21:49:34 +0600 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D0=BA=D1=80=D1=8B=D1=82=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B9=D1=82=D0=B8=D0=BD=D0=B3=20=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=84=D0=B8=D0=BB=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/project/contacts/Contacts.tsx | 4 +- src/entities/project/request/RequestInfo.tsx | 4 +- src/pages/profile/ProfileUserPage.tsx | 66 ++------------------ src/pages/profile/ProfileUserPageBase.tsx | 65 +++++++++++++++++++ src/shared/api/clients/projects.ts | 4 +- 5 files changed, 76 insertions(+), 67 deletions(-) create mode 100644 src/pages/profile/ProfileUserPageBase.tsx diff --git a/src/entities/project/contacts/Contacts.tsx b/src/entities/project/contacts/Contacts.tsx index d3ec7e4c..8cdc787a 100644 --- a/src/entities/project/contacts/Contacts.tsx +++ b/src/entities/project/contacts/Contacts.tsx @@ -27,9 +27,9 @@ export const Contacts = ({ ownerId }: { ownerId: string }) => { Организатор - + {/* - + */} diff --git a/src/entities/project/request/RequestInfo.tsx b/src/entities/project/request/RequestInfo.tsx index 298a1146..28cb675d 100644 --- a/src/entities/project/request/RequestInfo.tsx +++ b/src/entities/project/request/RequestInfo.tsx @@ -17,9 +17,9 @@ export const RequestInfo = ({ name, spec }: RequestInfoProps) => { {name} {spec} - + {/* - + */} ); }; diff --git a/src/pages/profile/ProfileUserPage.tsx b/src/pages/profile/ProfileUserPage.tsx index 967dfb20..4e9084ba 100644 --- a/src/pages/profile/ProfileUserPage.tsx +++ b/src/pages/profile/ProfileUserPage.tsx @@ -1,65 +1,9 @@ -import { - Flex, - Tabs, - TabList, - TabPanels, - TabPanel, - Tab, - Heading, - Container, -} from '@chakra-ui/react'; -import { useLayoutEffect } from 'react'; -import { useParams, useSearchParams } from 'react-router-dom'; +import { Navigate } from 'react-router-dom'; -import { ProfileCard, ProfileCardNotAuth } from '~/widgets/profile-card'; +import { BasePageProps, PATHS } from '~/shared/lib/router'; -import { GoBack } from '~/shared/ui/GoBack'; +import { ProfileUserPageBase } from './ProfileUserPageBase'; -import { AboutMeTab } from './tabs/about-me'; -import { NotAuthTab } from './tabs/not-auth'; -import { ProjectsTab } from './tabs/projects'; - -const tabs = ['about', 'projects', 'reviews']; - -export function ProfileUserPage() { - const [searchParams, setSearchParams] = useSearchParams(); - const { id } = useParams(); - - useLayoutEffect(() => { - if (!searchParams.get('tab')) { - setSearchParams({ tab: tabs[0] }); - } - }, [searchParams]); - - return ( - - - - - Профиль - - - {id ? : } - name === searchParams.get('tab')) - : undefined - } - onChange={(index) => { - setSearchParams({ tab: tabs[index] }); - }} - > - - Обо мне - Проекты - - - {id ? : } - {id ? : } - - - - ); +export function ProfileUserPage({ user }: BasePageProps) { + return user.isAuth ? : ; } diff --git a/src/pages/profile/ProfileUserPageBase.tsx b/src/pages/profile/ProfileUserPageBase.tsx new file mode 100644 index 00000000..cca76a1c --- /dev/null +++ b/src/pages/profile/ProfileUserPageBase.tsx @@ -0,0 +1,65 @@ +import { + Flex, + Tabs, + TabList, + TabPanels, + TabPanel, + Tab, + Heading, + Container, +} from '@chakra-ui/react'; +import { useLayoutEffect } from 'react'; +import { useParams, useSearchParams } from 'react-router-dom'; + +import { ProfileCard, ProfileCardNotAuth } from '~/widgets/profile-card'; + +import { GoBack } from '~/shared/ui/GoBack'; + +import { AboutMeTab } from './tabs/about-me'; +import { NotAuthTab } from './tabs/not-auth'; +import { ProjectsTab } from './tabs/projects'; + +const tabs = ['about', 'projects', 'reviews']; + +export function ProfileUserPageBase() { + const [searchParams, setSearchParams] = useSearchParams(); + const { id } = useParams(); + + useLayoutEffect(() => { + if (!searchParams.get('tab')) { + setSearchParams({ tab: tabs[0] }); + } + }, [searchParams]); + + return ( + + + + + Профиль + + + {id ? : } + name === searchParams.get('tab')) + : undefined + } + onChange={(index) => { + setSearchParams({ tab: tabs[index] }); + }} + > + + Обо мне + Проекты + + + {id ? : } + {id ? : } + + + + ); +} diff --git a/src/shared/api/clients/projects.ts b/src/shared/api/clients/projects.ts index c5cec262..a56b3b86 100644 --- a/src/shared/api/clients/projects.ts +++ b/src/shared/api/clients/projects.ts @@ -94,8 +94,8 @@ export class ProjectsApiClient extends BaseApiClient { `/api/rest/projects/${project_id}`, ); const statusAdapter = { - preparation: 'Подготовка', - in_work: 'В работе', + preparation: 'Скоро начнется', + in_work: 'Проект идёт', finished: 'Проект завершён', }; const { deadline, status, ...rest } = data;