From bb4324822a55d6121cd645b4d1d07b5415edfd11 Mon Sep 17 00:00:00 2001 From: fakz9 Date: Sat, 10 Aug 2024 06:53:45 +0300 Subject: [PATCH] feat: deals table --- src/client/models/DealSummary.ts | 1 + src/client/services/DealService.ts | 12 ++- src/components/Navbar/Navbar.tsx | 15 ++-- src/components/ObjectSelect/ObjectSelect.tsx | 3 + .../ClientSelectNew/ClientSelectNew.tsx | 17 ++++ .../DealStatusSelect/DealStatusSelect.tsx | 20 +++++ .../components/DealsTable/DealsTable.tsx | 49 ++++++++++ .../components/DealsTable/columns.tsx | 50 +++++++++++ src/pages/DealsPage/index.ts | 1 + src/pages/DealsPage/ui/DealsPage.module.css | 27 ++++++ src/pages/DealsPage/ui/DealsPage.tsx | 89 +++++++++++++++++++ .../LeadsPage/hooks/useDealSummaries.tsx | 10 ++- src/routeTree.gen.ts | 36 ++++++-- src/routes/deals.lazy.tsx | 6 ++ src/shared/enums/DealStatus.ts | 9 +- 15 files changed, 327 insertions(+), 18 deletions(-) create mode 100644 src/components/Selects/ClientSelectNew/ClientSelectNew.tsx create mode 100644 src/pages/DealsPage/components/DealStatusSelect/DealStatusSelect.tsx create mode 100644 src/pages/DealsPage/components/DealsTable/DealsTable.tsx create mode 100644 src/pages/DealsPage/components/DealsTable/columns.tsx create mode 100644 src/pages/DealsPage/index.ts create mode 100644 src/pages/DealsPage/ui/DealsPage.module.css create mode 100644 src/pages/DealsPage/ui/DealsPage.tsx create mode 100644 src/routes/deals.lazy.tsx diff --git a/src/client/models/DealSummary.ts b/src/client/models/DealSummary.ts index da0833d..a0273fc 100644 --- a/src/client/models/DealSummary.ts +++ b/src/client/models/DealSummary.ts @@ -8,6 +8,7 @@ export type DealSummary = { name: string; clientName: string; changedAt: string; + createdAt: string; deadline: string; status: number; totalPrice: number; diff --git a/src/client/services/DealService.ts b/src/client/services/DealService.ts index 36f104e..6560d47 100644 --- a/src/client/services/DealService.ts +++ b/src/client/services/DealService.ts @@ -134,10 +134,20 @@ export class DealService { * @returns DealSummaryResponse Successful Response * @throws ApiError */ - public static getDealSummaries(): CancelablePromise { + public static getDealSummaries({ + full, + }: { + full: (boolean | null), + }): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/deal/summaries', + query: { + 'full': full, + }, + errors: { + 422: `Validation Error`, + }, }); } /** diff --git a/src/components/Navbar/Navbar.tsx b/src/components/Navbar/Navbar.tsx index f191a2b..e3d789b 100644 --- a/src/components/Navbar/Navbar.tsx +++ b/src/components/Navbar/Navbar.tsx @@ -2,13 +2,15 @@ import {Center, Flex, Image, rem, Stack, Tooltip, UnstyledButton, useMantineColo import { IconBarcode, IconBox, - IconCash, IconDashboard, + IconCash, + IconDashboard, IconFileBarcode, IconHome2, IconLogout, IconMan, IconMoon, IconSun, + IconTable, } from '@tabler/icons-react'; import classes from './Navbar.module.css'; import {useAppDispatch} from "../../redux/store.ts"; @@ -40,16 +42,17 @@ function NavbarLink(props: NavbarLinkProps) { } const mockdata = [ - // { - // icon: IconHome2, - // label: 'Главная', - // href: '/' - // }, + { icon: IconCash, label: 'Сделки', href: '/leads' }, + { + icon: IconTable, + label: 'Таблица сделок', + href: '/deals' + }, { icon: IconMan, label: 'Клиенты', diff --git a/src/components/ObjectSelect/ObjectSelect.tsx b/src/components/ObjectSelect/ObjectSelect.tsx index 7378ece..e99ba0c 100644 --- a/src/components/ObjectSelect/ObjectSelect.tsx +++ b/src/components/ObjectSelect/ObjectSelect.tsx @@ -26,10 +26,12 @@ type RestProps = { filterBy?: (item: SelectObjectType) => boolean; }; const defaultGetLabelFn = (item: T): string => { + return item.name; } const defaultGetValueFn = (item: T): string => { + if (!item) return item; return item.id.toString(); } export type ObjectSelectProps = @@ -85,6 +87,7 @@ const ObjectSelect = (props: ObjectSelectProps) => { if (isControlled || !internalValue) return; props.onChange(internalValue); }, [internalValue]); + const restProps = omit(props, ['filterBy', 'groupBy', 'getValueFn', 'getLabelFn']); return (