From cc50f8c3e7a501d43ff681c2a9ad8ce2ea2d616c Mon Sep 17 00:00:00 2001 From: Alexandre Valsamou-Stanislawski Date: Wed, 1 Dec 2021 16:28:30 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9pare=20la=20liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Stats/DemandesUtilisateurs.tsx | 146 ++++++++++-------- 1 file changed, 83 insertions(+), 63 deletions(-) diff --git a/mon-entreprise/source/pages/Stats/DemandesUtilisateurs.tsx b/mon-entreprise/source/pages/Stats/DemandesUtilisateurs.tsx index 00465c7ec..f5b95b510 100644 --- a/mon-entreprise/source/pages/Stats/DemandesUtilisateurs.tsx +++ b/mon-entreprise/source/pages/Stats/DemandesUtilisateurs.tsx @@ -1,9 +1,9 @@ -import { FromTop } from 'Components/ui/animate' import { H2, H3 } from 'DesignSystem/typography/heading' import { Link } from 'DesignSystem/typography/link' import { Li, Ul } from 'DesignSystem/typography/list' import { Body } from 'DesignSystem/typography/paragraphs' import { useState } from 'react' +import styled from 'styled-components' import stats from '../../data/stats.json' export default function DemandeUtilisateurs() { @@ -16,79 +16,60 @@ export default function DemandeUtilisateurs() {

En attente d'implémentation

- +

Réalisées

- + ) } -type PaginationProps = { - itemComponent: React.FC - items: Array -} - -function Pagination({ - itemComponent, - items, -}: PaginationProps) { - const [currentPage, setCurrentPage] = useState(0) - return ( - <> -
    - {items - .slice(currentPage * 10, (currentPage + 1) * 10) - .map(itemComponent)} -
-
- Page : - {[...Array(Math.ceil(items.length / 10)).keys()].map((i) => ( - - ))} -
- - ) -} - -function Issue({ - title, - number, - count, - closedAt, -}: { +type IssueProps = { title: string number: number count: number closedAt: string | null -}) { +} + +type PaginationProps = { + items: Array +} + +function Pagination({ items }: PaginationProps) { + const [currentPage, setCurrentPage] = useState(0) return ( - -
  • - {count > 1 && {count} demandes}{' '} - - {title} - {' '} - {closedAt && ( - (Résolu en {formatMonth(new Date(closedAt))}) - )} -
  • -
    + <> +
      + {items.slice(currentPage * 10, (currentPage + 1) * 10).map((item) => ( + + ))} +
    + + {[...Array(Math.ceil(items.length / 10)).keys()].map((i) => ( + setCurrentPage(i)} + currentPage={currentPage === i} + key={i} + > + {i + 1} + + ))} + + + ) +} + +function Issue({ title, number, count, closedAt }: IssueProps) { + return ( +
  • + {count > 1 && {count} demandes}{' '} + + {title} + {' '} + {closedAt && (Résolu en {formatMonth(new Date(closedAt))})} +
  • ) } @@ -98,3 +79,42 @@ function formatMonth(date: string | Date) { year: 'numeric', }) } + +type PagerButtonProps = { + currentPage: boolean +} + +const PagerButton = styled.button` + padding: 0.375rem 0.5rem; + border: 1px solid + ${({ theme, currentPage }) => + currentPage + ? theme.colors.bases.primary[500] + : theme.colors.extended.grey[300]}; + margin-right: 0.25rem; + background-color: ${({ theme, currentPage }) => + currentPage + ? theme.colors.bases.primary[100] + : theme.colors.extended.grey[100]}; + + &:hover { + background-color: ${({ theme }) => theme.colors.bases.primary[100]}; + } + + &:first-child { + border-top-left-radius: 0.25rem; + border-bottom-left-radius: 0.25rem; + } + + &:last-child { + border-top-right-radius: 0.25rem; + border-bottom-right-radius: 0.25rem; + margin-right: 0; + } +` + +const Pager = styled.div` + font-family: ${({ theme }) => theme.fonts.main}; + text-align: center; + margin: auto; +`