Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/dataesr/scanr-ui into st…
Browse files Browse the repository at this point in the history
…aging
  • Loading branch information
ericjeangirard committed Jan 16, 2025
2 parents 4817800 + 0494204 commit 761b22d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/networks/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"networks.get-started.select-source.title": "Quelle source voulez-vous utiliser ?",
"networks.get-started.select-source.description": "Choississez la source de documents à analyser.",
"networks.get-started.select-model.title": "Quelles communautés souhaitez-vous visualiser ?",
"networks.get-started.select-model.description": "Les différentes communautés sont obtenues par co-occurence au sein du corpus de documents correspondant à la recherche effectuée. La visualisation prends la forme d'un réseau composés de noeuds representant les différents élements reliés entre eux en fonction de leur nombre de co-occurence.",
"networks.get-started.select-model.description": "Les différentes communautés sont obtenues par co-occurence au sein du corpus de documents correspondant à la recherche effectuée. La visualisation prend la forme d'un réseau composé de noeuds representant les différents élements reliés entre eux en fonction de leur nombre de co-occurences.",
"networks.search-bar.button.label.anything": "Tout",
"networks.search-bar.modal.title": "Rechercher",
"networks.select-model.modal.title": "Réseau",
Expand Down
32 changes: 29 additions & 3 deletions client/src/pages/trends/components/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import TrendsViewItem from "./item"
import TrendsViewHeader from "./header"
import BaseSkeleton from "../../../../components/skeleton/base-skeleton"

const itemsPerScroll = 10
const scrollPerPage = 3
const scrollYTop = 200

function TrendsViewItems() {
Expand All @@ -27,7 +29,10 @@ function TrendsViewItems() {
if (isFetching && !isFetchingNextPage) return <BaseSkeleton height="500px" />
if (!trends?.pages || error) return <div>no data</div>

const shouldChangePage = trends.pageParams.length === 3
const shouldChangePage = trends.pageParams.length >= scrollPerPage
const totalPages = Math.ceil((trends?.pages?.[0]?.total || 0) / (itemsPerScroll * scrollPerPage))

console.log(totalPages)

return (
<>
Expand All @@ -40,8 +45,29 @@ function TrendsViewItems() {
<Container fluid className="fr-mt-2w">
<ButtonGroup isInlineFrom="xs" align="center">
<Button variant="tertiary" onClick={() => handlePageChange(currentPage - 1)} disabled={currentPage === 1}>
{intl.formatMessage({ id: "trends.page-previous" })}
{intl.formatMessage({ id: "trends.views.page-previous" })}
</Button>
{currentPage > 1 && (
<Button variant="tertiary" onClick={() => handlePageChange(1)}>
{1}
</Button>
)}
{currentPage > 2 && (
<Button variant="tertiary" onClick={() => handlePageChange(currentPage - 1)}>
{currentPage - 1}
</Button>
)}
<Button variant="secondary">{currentPage}</Button>
{currentPage < totalPages - 1 && (
<Button variant="tertiary" onClick={() => handlePageChange(currentPage + 1)}>
{currentPage + 1}
</Button>
)}
{currentPage < totalPages && (
<Button variant="tertiary" onClick={() => handlePageChange(totalPages)}>
{totalPages}
</Button>
)}
<Button
variant="tertiary"
onClick={() => {
Expand All @@ -50,7 +76,7 @@ function TrendsViewItems() {
}}
disabled={!hasNextPage}
>
{intl.formatMessage({ id: "trends.page-next" })}
{intl.formatMessage({ id: "trends.views.page-next" })}
</Button>
</ButtonGroup>
</Container>
Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/trends/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"trends.views.header.count": "Volume ({max})",
"trends.views.header.diff": "Variation (1 year)",
"trends.views.header.trend": "Trend ({count} years)",
"trends.views.page-next": "Next page",
"trends.views.page-previous": "Previous page",
"trends.line-chart.xAxis.accessibility.description": "Years from {min, number} to {max, number}",
"trends.line-chart.yAxis.accessibility.description": "Number of {source}",
"trends.line-chart.yAxis.title.text": "Number of {source}",
Expand Down
2 changes: 2 additions & 0 deletions client/src/pages/trends/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"trends.views.header.count": "Volume ({max})",
"trends.views.header.diff": "Variation (1 an)",
"trends.views.header.trend": "Tendance ({count} ans)",
"trends.views.page-next": "Page suivante",
"trends.views.page-previous": "Page précédente",
"trends.line-chart.xAxis.accessibility.description": "Années de {min, number} à {max, number}",
"trends.line-chart.yAxis.accessibility.description": "Nombre de {source}",
"trends.line-chart.yAxis.title.text": "Nombre de {source}",
Expand Down

0 comments on commit 761b22d

Please sign in to comment.