From 7e16f500cb7bc0cfd8bafbf6bb1555704f771231 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 29 Apr 2022 12:13:34 +0200 Subject: chore: remove old pages, components, helpers and types Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch. --- src/components/Pagination/Pagination.tsx | 136 ------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 src/components/Pagination/Pagination.tsx (limited to 'src/components/Pagination/Pagination.tsx') diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx deleted file mode 100644 index 55c366a..0000000 --- a/src/components/Pagination/Pagination.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { settings } from '@utils/config'; -import Link from 'next/link'; -import { useRouter } from 'next/router'; -import { useIntl } from 'react-intl'; -import styles from './Pagination.module.scss'; - -const Pagination = ({ baseUrl, total }: { baseUrl: string; total: number }) => { - const intl = useIntl(); - const { asPath } = useRouter(); - const totalPages = Math.floor(total / settings.postsPerPage); - const currentPage = asPath.includes('/page/') - ? Number(asPath.split(`${baseUrl}/page/`)[1]) - : 1; - const hasPreviousPage = currentPage !== 1; - const hasNextPage = currentPage !== totalPages; - - const getPreviousPageItem = () => { - return ( -
  • - - - {intl.formatMessage( - { - defaultMessage: '{icon} Previous page', - description: 'Pagination: previous page link', - id: 'aMFqPH', - }, - { icon: '←' } - )} - - -
  • - ); - }; - - const getNextPageItem = () => { - return ( -
  • - - - {intl.formatMessage( - { - defaultMessage: 'Next page {icon}', - description: 'Pagination: Next page link', - id: 'R4yaW6', - }, - { icon: '→' } - )} - - -
  • - ); - }; - - const getPages = () => { - const pages = []; - for (let i = 1; i <= totalPages; i++) { - if (i === currentPage) { - pages.push({ - id: `page-${i}`, - link: ( - - {intl.formatMessage( - { - defaultMessage: 'Page {number}', - description: 'Pagination: page number', - id: 'TSXPzr', - }, - { - number: i, - a11y: (chunks: string) => ( - {chunks} - ), - } - )} - - ), - }); - } else { - pages.push({ - id: `page-${i}`, - link: ( - - - {intl.formatMessage( - { - defaultMessage: 'Page {number}', - description: 'Pagination: page number', - id: 'TSXPzr', - }, - { - number: i, - a11y: (chunks: string) => ( - {chunks} - ), - } - )} - - - ), - }); - } - } - - return pages; - }; - - const getItems = () => { - const pages = getPages(); - - return pages.map((page) => ( -
  • - {page.link} -
  • - )); - }; - - return ( - - ); -}; - -export default Pagination; -- cgit v1.2.3