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

Commit

Permalink
Refactor: Проект (#90)
Browse files Browse the repository at this point in the history
Co-authored-by: Ruslan Kutliakhmetov <[email protected]>
  • Loading branch information
DieWerkself and ko22009 authored Dec 20, 2023
1 parent 16660ad commit a30bfde
Show file tree
Hide file tree
Showing 50 changed files with 101 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ module.exports = {
],
'react-hooks/exhaustive-deps': 'off',
'react/react-in-jsx-scope': 'off',

'jsx-a11y/accessible-emoji': 'off',
'react/prop-types': 'off',
'import/no-duplicates': 'error',
'import/no-unresolved': 'error',
'import/no-cycle': 'error',
'import/newline-after-import': 'error',
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"search.exclude": {
"**/.yarn": true,
Expand Down
7 changes: 5 additions & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ColorMode } from '@chakra-ui/react';
import { ChakraProvider, createLocalStorageManager } from '@chakra-ui/react';
import {
ChakraProvider,
createLocalStorageManager,
type ColorMode,
} from '@chakra-ui/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
// eslint-disable-next-line import/no-duplicates
Expand Down
7 changes: 5 additions & 2 deletions src/entities/project/api/useGetAllProjects.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { QueryFunctionContext, QueryKey } from '@tanstack/react-query';
import { useInfiniteQuery } from '@tanstack/react-query';
import {
useInfiniteQuery,
type QueryFunctionContext,
type QueryKey,
} from '@tanstack/react-query';

import { api } from '~/shared/api';

Expand Down
13 changes: 12 additions & 1 deletion src/entities/project/card/ui/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { Heading, Text } from '@chakra-ui/react';

import { useIsMobile } from '~/shared/hooks';
import { Status } from '~/shared/ui/Status';

import {
PROJECT_STATUSES_MESSAGES,
type PROJECT_STATUSES,
} from '../../Project.constants';

export interface CardProps {
status: keyof typeof PROJECT_STATUSES;
title?: string;
date?: string | null;
description?: string | null;
fullDescription?: boolean;
}

export const Card = (props: CardProps) => {
const { title, date, description, fullDescription } = props;
const { title, date, description, status, fullDescription } = props;
const isMobile = useIsMobile();

return (
<>
<Status mb={isMobile ? 3 : 4}>{PROJECT_STATUSES_MESSAGES[status]}</Status>
<Heading variant="h2" overflowWrap="anywhere" noOfLines={3}>
{title}
</Heading>
Expand Down
4 changes: 2 additions & 2 deletions src/entities/project/contacts/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { useGetUser } from '../api';
export const Contacts = ({ ownerId }: { ownerId: string }) => {
const { userApi } = useApi();
const { isAuth } = useAuth();
const avatar = userApi.getAvatar(ownerId);
const avatarUrl = userApi.getAvatar(ownerId);
const { data: owner, isSuccess: loadedOwner } = useGetUser(ownerId);

return (
<>
<Heading variant="h2">Участники</Heading>
<Skeleton isLoaded={loadedOwner} borderRadius="2xl" fadeDuration={2}>
<Flex alignItems="center">
<Avatar src={avatar} name={`${owner?.first_name} ${owner?.last_name}`} />
<Avatar src={avatarUrl} name={`${owner?.first_name} ${owner?.last_name}`} />
<Stack pl={2} gap={0} whiteSpace="nowrap" overflow="hidden">
<Heading minWidth={0} variant="h3" overflow="hidden" textOverflow="ellipsis">
{owner?.first_name} {owner?.last_name}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/project/info/ProjectInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ export const ProjectInfo = ({
return (
<>
<Stack gap={0} mb={3} alignItems="start">
<Status mb={3}>{PROJECT_STATUSES_MESSAGES[project.status]}</Status>
<Card
title={project.name}
date={project.startline}
description={project.description}
fullDescription={true}
status={project.status}
/>
</Stack>
{project.status !== PROJECT_STATUSES.finished && (
Expand Down
5 changes: 1 addition & 4 deletions src/entities/project/position/PositionInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Heading, Stack } from '@chakra-ui/layout';
import { Text } from '@chakra-ui/react';

import { STag } from '~/shared/ui/STag';
import { Status } from '~/shared/ui/Status';

import { Card } from '../card';
import type { PROJECT_STATUSES } from '../Project.constants';
import { PROJECT_STATUSES_MESSAGES } from '../Project.constants';

interface Project {
deadline: string | null;
Expand All @@ -31,12 +28,12 @@ export const PositionInfo = ({ mainTags, tags, project }: ProjectInfoProps) => {
return (
<>
<Stack gap={0} mb={3} alignItems="start">
<Status mb={3}>{PROJECT_STATUSES_MESSAGES[project.status]}</Status>
<Card
title={project.name}
date={project.startline}
description={project.description}
fullDescription={true}
status={project.status}
/>
</Stack>

Expand Down
3 changes: 1 addition & 2 deletions src/entities/user/info/Info.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { FlexProps } from '@chakra-ui/react';
import { Box, Divider, Flex } from '@chakra-ui/react';
import { Box, Divider, Flex, type FlexProps } from '@chakra-ui/react';

import type { GetStatistic } from '~/shared/api/model';
import { useAuth } from '~/shared/hooks';
Expand Down
3 changes: 1 addition & 2 deletions src/entities/user/reviews/Reviews.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { StackProps } from '@chakra-ui/react';
import { Box, HStack, Heading, Stack, Text } from '@chakra-ui/react';
import { Box, HStack, Heading, Stack, Text, type StackProps } from '@chakra-ui/react';

import { SLink } from '~/shared/ui/SLink';

Expand Down
2 changes: 1 addition & 1 deletion src/features/project/add/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './AddProject';
export * from './ui';
export * from './api';
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-floating-promises */
import {
Flex,
Button,
Expand All @@ -14,24 +13,23 @@ import {
} from '@chakra-ui/react';
import { useQueryClient } from '@tanstack/react-query';
import { useState } from 'react';
import type { FieldErrors, SubmitHandler } from 'react-hook-form';
import { Controller, useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';

import {
useAddAvatar,
useAddPosition,
useAddProject,
useAddSkills,
} from '~/features/project';
Controller,
useForm,
type FieldErrors,
type SubmitHandler,
} from 'react-hook-form';
import { useNavigate } from 'react-router-dom';

import { stringToServerDate } from '~/shared/lib/adapters';
import { GoBack } from '~/shared/ui/GoBack';

import { useAddAvatar, useAddPosition, useAddProject, useAddSkills } from '../api';

import type { AddProjectForm } from './AddProject.types';
import { AboutProject, Team } from './tabs';

export const AddProjectFormView = ({ userId }: { userId: string }) => {
export const AddProject = ({ userId }: { userId: string }) => {
const navigate = useNavigate();
const queryClient = useQueryClient();
const { mutateAsync: addProject } = useAddProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom';
import { useIsMobile, useAuth } from '~/shared/hooks';
import { PATHS } from '~/shared/lib/router';

export const AddProject = () => {
export const AddProjectButton = () => {
const navigate = useNavigate();
const isMobile = useIsMobile();
const { isAuth } = useAuth();
Expand Down
2 changes: 2 additions & 0 deletions src/features/project/add/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './AddProject';
export * from './AddProjectButton';
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
Image,
useDisclosure,
} from '@chakra-ui/react';
import type { ChangeEvent } from 'react';
import { useState } from 'react';
import type { useForm } from 'react-hook-form';
import { Controller } from 'react-hook-form';
import { useState, type ChangeEvent } from 'react';
import { Controller, type useForm } from 'react-hook-form';

import { Modal } from '~/shared/ui/Modal';
import { STextarea } from '~/shared/ui/STextarea';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Box, Flex, Heading, Stack } from '@chakra-ui/layout';
import { Button, Card, CloseButton, FormControl, FormLabel } from '@chakra-ui/react';
import { useQuery } from '@tanstack/react-query';
import type { Dispatch, SetStateAction } from 'react';
import { useState } from 'react';
import { useState, type Dispatch, type SetStateAction } from 'react';
import { v4 as uuidv4 } from 'uuid';

import { useGetSpecs } from '~/entities/storage';
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/features/project/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './search';
export * from './add';
export * from './request';
export * from './filter';
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Container, Flex, Heading } from '@chakra-ui/layout';
import { Card, Icon, IconButton, Stack } from '@chakra-ui/react';
import { FiChevronLeft } from 'react-icons/fi';

import { RequestButtons } from '~/features/project';

import { DummyPosition } from '~/entities/dummy';
import { PARTICIPANT_STATUSES } from '~/entities/project';

Expand All @@ -14,6 +12,7 @@ import type {
} from '~/shared/api/model';
import { STag } from '~/shared/ui/STag';

import { RequestButtons } from './RequestButtons';
import { RequestParticipant } from './RequestParticipant';

interface RequestsProps {
Expand Down
3 changes: 2 additions & 1 deletion src/features/project/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './RequestButtons';
export * from './Requests';
export * from './RequestParticipant';
export * from './api';
6 changes: 2 additions & 4 deletions src/features/user/update-user/UpdateUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
Center,
Avatar,
} from '@chakra-ui/react';
import type { ChangeEvent } from 'react';
import { useEffect, useState } from 'react';
import { useEffect, useState, type ChangeEvent } from 'react';
import { Controller, useForm } from 'react-hook-form';
import { MdPhotoCamera } from 'react-icons/md';
import { useNavigate } from 'react-router-dom';
Expand All @@ -31,8 +30,7 @@ import {
useUpdateProfile,
useUpdateSkills,
} from './api';
import type { UserTypeForm } from './model';
import { userResponseToUserType } from './model';
import { userResponseToUserType, type UserTypeForm } from './model';

interface UpdateUserProps {
user: GetUserResponse;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blank/BlankPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { ColorMode } from '@chakra-ui/react';
import {
Container,
Flex,
Expand All @@ -10,6 +9,7 @@ import {
Text,
ChakraProvider,
createLocalStorageManager,
type ColorMode,
} from '@chakra-ui/react';

import { Logo } from '~/shared/ui/Logo';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/projects/add/AddProjectPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useNavigate } from 'react-router-dom';

import { AddProjectFormView } from '~/widgets/project';
import { AddProject } from '~/features/project';

import { useAuth } from '~/shared/hooks';
import { PATHS } from '~/shared/lib/router';
Expand All @@ -11,7 +11,7 @@ export const AddProjectPage = () => {
return (
<>
{user.userId ? (
<AddProjectFormView userId={user.userId} />
<AddProject userId={user.userId} />
) : (
() => {
navigate(PATHS.notFound);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/projects/ui/NotAuthProjectPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Flex, Heading, Container } from '@chakra-ui/react';

import { AddProject } from '~/features/project';
import { AddProjectButton } from '~/features/project';
import { Login } from '~/features/user';

import { DummyProject } from '~/entities/dummy';
Expand All @@ -13,7 +13,7 @@ export const NotAuthProjectsPage = () => {
Проекты
</Heading>
<Flex gap={4} alignItems="baseline">
<AddProject />
<AddProjectButton />
</Flex>
</Flex>
<DummyProject />
Expand Down
9 changes: 6 additions & 3 deletions src/pages/projects/ui/ProjectBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import { useEffect, useState } from 'react';
import { FiChevronRight } from 'react-icons/fi';
import { Link, generatePath } from 'react-router-dom';

import { RequestParticipant, Requests } from '~/widgets/project';

import { useUpdateParticipant, useUpdateProject } from '~/features/project';
import {
RequestParticipant,
Requests,
useUpdateParticipant,
useUpdateProject,
} from '~/features/project';

import {
Avatar,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/projects/ui/ProjectsBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Link, generatePath } from 'react-router-dom';

import { ProjectCard } from '~/widgets/project-card';

import { AddProject } from '~/features/project';
import { AddProjectButton } from '~/features/project';

import { DummyProject } from '~/entities/dummy';
import { AvatarsGroup, useGetAllProjects } from '~/entities/project';
Expand Down Expand Up @@ -50,7 +50,7 @@ export const ProjectsBase = ({ userId }: ProjectPageProps) => {
Проекты
</Heading>
<Flex gap={4} alignItems="baseline">
<AddProject />
<AddProjectButton />
</Flex>
</Flex>

Expand Down
4 changes: 2 additions & 2 deletions src/pages/projects/ui/ProjectsPage.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Flex, SimpleGrid, Heading } from '@chakra-ui/react';

import { ProjectCard } from '~/widgets/project-card';

import { AddProject } from '~/features/project';
import { AddProjectButton } from '~/features/project';

import { AvatarsGroup } from '~/entities/project';

Expand All @@ -25,7 +25,7 @@ export const ProjectsPageDesktop = () => {
Проекты
</Heading>
<Flex gap={4} alignItems="baseline">
<AddProject />
<AddProjectButton />
</Flex>
</Flex>
<SimpleGrid
Expand Down
7 changes: 5 additions & 2 deletions src/pages/search/api/useGetAllPositions.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { QueryFunctionContext, QueryKey } from '@tanstack/react-query';
import { useInfiniteQuery } from '@tanstack/react-query';
import {
useInfiniteQuery,
type QueryFunctionContext,
type QueryKey,
} from '@tanstack/react-query';

import { api } from '~/shared/api';
import type { SelectOptions } from '~/shared/types';
Expand Down
3 changes: 1 addition & 2 deletions src/pages/search/ui/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import { useQuery } from '@tanstack/react-query';
import React, { useEffect, useRef, useState } from 'react';
import { Link, generatePath } from 'react-router-dom';

import { FilterUser } from '~/widgets/project';
import { ProjectCard } from '~/widgets/project-card';

import { SearchProject } from '~/features/project';
import { FilterUser, SearchProject } from '~/features/project';

import { DummyNotFound } from '~/entities/dummy';
import { useFilterStore } from '~/entities/project';
Expand Down
Loading

0 comments on commit a30bfde

Please sign in to comment.