From 6e3ffadcb5427a6c92fe0a4b38ba1995874fb33b Mon Sep 17 00:00:00 2001 From: r1skz3ro Date: Fri, 19 Jul 2024 11:58:55 +0200 Subject: [PATCH] feat: my space tabs refactor --- .../common/Pagination/Pagination.interface.ts | 8 - .../common/Pagination/Pagination.tsx | 80 -------- .../components/common/Tabs/Tabs.interface.ts | 13 +- frontend/src/components/common/Tabs/Tabs.tsx | 29 +-- .../components/modules/Tabs/Tabs.interface.ts | 9 - frontend/src/components/modules/Tabs/Tabs.tsx | 21 -- frontend/src/components/modules/Tabs/index.ts | 1 - .../components/pages/MySpace/MySpace.hooks.ts | 23 +-- .../pages/MySpace/MySpace.interface.ts | 5 - .../src/components/pages/MySpace/MySpace.tsx | 2 +- .../src/components/pages/MySpace/contants.ts | 29 +-- .../PeopleTable/PeopleTable.interface.ts | 5 + .../Modules/PeopleTable/PeopleTable.tsx | 165 ++++++++++++++++ .../pages/People/Modules/PeopleTable/index.ts | 1 + .../components/pages/People/People.hook.ts | 27 ++- .../pages/People/People.interface.ts | 32 ++++ .../src/components/pages/People/People.tsx | 179 +----------------- .../components/pages/People/People.utils.ts | 24 +-- frontend/src/components/pages/People/index.ts | 1 + frontend/src/hooks/useQueryParams.ts | 43 ++--- frontend/src/types/people.ts | 32 ---- 21 files changed, 293 insertions(+), 436 deletions(-) delete mode 100644 frontend/src/components/common/Pagination/Pagination.interface.ts delete mode 100644 frontend/src/components/common/Pagination/Pagination.tsx delete mode 100644 frontend/src/components/modules/Tabs/Tabs.interface.ts delete mode 100644 frontend/src/components/modules/Tabs/Tabs.tsx delete mode 100644 frontend/src/components/modules/Tabs/index.ts create mode 100644 frontend/src/components/pages/People/Modules/PeopleTable/PeopleTable.interface.ts create mode 100644 frontend/src/components/pages/People/Modules/PeopleTable/PeopleTable.tsx create mode 100644 frontend/src/components/pages/People/Modules/PeopleTable/index.ts diff --git a/frontend/src/components/common/Pagination/Pagination.interface.ts b/frontend/src/components/common/Pagination/Pagination.interface.ts deleted file mode 100644 index 03a1ce4d..00000000 --- a/frontend/src/components/common/Pagination/Pagination.interface.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { MouseEvent } from 'react'; - -export interface PaginationProps { - itemsAmount?: number; - setPageNumber: (event: MouseEvent, number?: number) => void; - pageNumber: number; - pagePosition: number; -} diff --git a/frontend/src/components/common/Pagination/Pagination.tsx b/frontend/src/components/common/Pagination/Pagination.tsx deleted file mode 100644 index 03a85da4..00000000 --- a/frontend/src/components/common/Pagination/Pagination.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { ChevronRightIcon } from '@app/static/icons/ChevronRightIcon'; -import { PaginationProps } from './Pagination.interface'; -import { generateClassNames } from '@app/utils'; -import { paginationMaxPages, rowsPerPage } from '@app/components/pages/People/People.utils'; - -export const Pagination = ({ itemsAmount, setPageNumber, pageNumber }: PaginationProps) => { - const pagesButtons = itemsAmount && [...Array(Math.ceil(itemsAmount / rowsPerPage))]; - - const getResultsNumber = (position?: string) => { - if (position === 'start') return pageNumber * rowsPerPage - rowsPerPage + 1; - - return itemsAmount && pageNumber * rowsPerPage > itemsAmount - ? (itemsAmount % rowsPerPage) + (pageNumber * rowsPerPage - rowsPerPage) - : pageNumber * rowsPerPage; - }; - - // TO REFACTOR - const getPageNumber = (index: number) => { - return index + 1; - }; - - return ( -
-

- Showing - {getResultsNumber('start')} - to - {getResultsNumber()} - of - {itemsAmount} - results -

- -
- -
- {pagesButtons && - pagesButtons.map((_, index) => { - if (index + 1 <= paginationMaxPages) { - return ( - - ); - } - })} -
- -
-
- ); -}; diff --git a/frontend/src/components/common/Tabs/Tabs.interface.ts b/frontend/src/components/common/Tabs/Tabs.interface.ts index 4894a7a9..a7560d32 100644 --- a/frontend/src/components/common/Tabs/Tabs.interface.ts +++ b/frontend/src/components/common/Tabs/Tabs.interface.ts @@ -1,9 +1,8 @@ +import { Option } from '../Combobox'; + export interface TabsProps { - tabs: { - key: string; - label: string; - href: string; - }[]; - currentTab: string; - onTabChange: (tab: string) => void; + tabs: Array