Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

правка статусов проекта #77

Merged
merged 1 commit into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/entities/project/contacts/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { useApi } from '~/shared/hooks';
import { PATHS } from '~/shared/lib/router';
import { Rating } from '~/shared/ui/rating';

Check warning on line 8 in src/entities/project/contacts/Contacts.tsx

View workflow job for this annotation

GitHub Actions / checks

'Rating' is defined but never used. Allowed unused vars must match /^_/u

import { useGetUser } from '../api';

Expand All @@ -27,9 +27,9 @@
</Heading>
<Text variant="caption">Организатор</Text>
</Stack>
<Flex ml="auto">
{/* <Flex ml="auto">
<Rating />
</Flex>
</Flex> */}
</Flex>
</Skeleton>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/entities/project/request/RequestInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Avatar } from '@chakra-ui/react';
import React from 'react';

import { Rating } from '~/shared/ui/rating';

Check warning on line 5 in src/entities/project/request/RequestInfo.tsx

View workflow job for this annotation

GitHub Actions / checks

'Rating' is defined but never used. Allowed unused vars must match /^_/u

interface RequestInfoProps {
name: string;
Expand All @@ -17,9 +17,9 @@
<Heading variant="h3">{name}</Heading>
<Text variant="caption">{spec}</Text>
</Stack>
<Flex ml="auto">
{/* <Flex ml="auto">
<Rating />
</Flex>
</Flex> */}
</Flex>
);
};
66 changes: 5 additions & 61 deletions src/pages/profile/ProfileUserPage.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Container maxW="md" mb={4}>
<Flex alignItems="center" mt={4} mb={16} h={42} gap={4}>
<GoBack />
<Heading variant="h1" as="h1">
Профиль
</Heading>
</Flex>
{id ? <ProfileCard userId={id} /> : <ProfileCardNotAuth />}
<Tabs
variant="base"
index={
searchParams.get('tab')
? tabs.findIndex((name) => name === searchParams.get('tab'))
: undefined
}
onChange={(index) => {
setSearchParams({ tab: tabs[index] });
}}
>
<TabList>
<Tab>Обо мне</Tab>
<Tab>Проекты</Tab>
</TabList>
<TabPanels>
<TabPanel>{id ? <AboutMeTab userId={id} /> : <NotAuthTab />}</TabPanel>
<TabPanel>{id ? <ProjectsTab userId={id} /> : <NotAuthTab />}</TabPanel>
</TabPanels>
</Tabs>
</Container>
);
export function ProfileUserPage({ user }: BasePageProps) {
return user.isAuth ? <ProfileUserPageBase /> : <Navigate to={PATHS.notFound} replace />;
}
65 changes: 65 additions & 0 deletions src/pages/profile/ProfileUserPageBase.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Container maxW="md" mb={4}>
<Flex alignItems="center" mt={4} mb={16} h={42} gap={4}>
<GoBack />
<Heading variant="h1" as="h1">
Профиль
</Heading>
</Flex>
{id ? <ProfileCard userId={id} /> : <ProfileCardNotAuth />}
<Tabs
variant="base"
index={
searchParams.get('tab')
? tabs.findIndex((name) => name === searchParams.get('tab'))
: undefined
}
onChange={(index) => {
setSearchParams({ tab: tabs[index] });
}}
>
<TabList>
<Tab>Обо мне</Tab>
<Tab>Проекты</Tab>
</TabList>
<TabPanels>
<TabPanel>{id ? <AboutMeTab userId={id} /> : <NotAuthTab />}</TabPanel>
<TabPanel>{id ? <ProjectsTab userId={id} /> : <NotAuthTab />}</TabPanel>
</TabPanels>
</Tabs>
</Container>
);
}
4 changes: 2 additions & 2 deletions src/shared/api/clients/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading