-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dsfr): ajout de la page stats (#6090)
* fix: pandacss * fix: build * fix: build * fix(stats): add page * fix: stats
- Loading branch information
Showing
5 changed files
with
99 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Metadata } from "next"; | ||
import { DsfrLayout } from "../../src/modules/layout"; | ||
import { Stats } from "../../src/modules/stats"; | ||
import { getStatsService } from "../../src/api"; | ||
import { cache } from "react"; | ||
import { REVALIDATE_TIME_DAY } from "../../src/config"; | ||
|
||
export const dynamic = "force-static"; | ||
|
||
export const revalidate = REVALIDATE_TIME_DAY; | ||
|
||
export const metadata: Metadata = { | ||
title: "Statistiques", | ||
description: "Statistiques d’utilisation du Code du travail numérique", | ||
}; | ||
|
||
const getStats = cache(async () => { | ||
return getStatsService(); | ||
}); | ||
|
||
async function Index() { | ||
const data = await getStats(); | ||
|
||
return ( | ||
<DsfrLayout> | ||
<Stats | ||
nbDocuments={data.nbDocuments} | ||
nbVisits={data.nbVisits} | ||
nbSearches={data.nbSearches} | ||
nbPageViews={data.nbPageViews} | ||
/> | ||
</DsfrLayout> | ||
); | ||
} | ||
|
||
export default Index; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/code-du-travail-frontend/src/modules/stats/StatsDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import { CallOut } from "@codegouvfr/react-dsfr/CallOut"; | ||
import { css } from "../../../styled-system/css"; | ||
|
||
type StatsProps = { | ||
title: string; | ||
metric: number; | ||
}; | ||
|
||
export const StatsDisplay = (props: StatsProps) => ( | ||
<div className={fr.cx("fr-col-12", "fr-col-md-3")}> | ||
<CallOut className={`${callOut}`}> | ||
<span className={`${metric} ${fr.cx("fr-mt-4v", "fr-display--xs")}`}> | ||
{props.metric} | ||
</span> | ||
<span className={`${title} ${fr.cx("fr-text--bold", "fr-text--xl")}`}> | ||
{props.title} | ||
</span> | ||
</CallOut> | ||
</div> | ||
); | ||
|
||
const metric = css({ | ||
textAlign: "right", | ||
display: "block", | ||
}); | ||
|
||
const title = css({ | ||
textAlign: "left", | ||
}); | ||
|
||
const callOut = css({ | ||
height: "100%", | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/code-du-travail-frontend/src/modules/stats/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import { StatsDisplay } from "./StatsDisplay"; | ||
|
||
type StatsProps = { | ||
nbDocuments: number; | ||
nbVisits: number; | ||
nbSearches: number; | ||
nbPageViews: number; | ||
}; | ||
|
||
export const Stats = (props: StatsProps) => ( | ||
<div className={fr.cx("fr-grid-row")}> | ||
<div className={fr.cx("fr-my-4w", "fr-col-12")}> | ||
<h1 className={fr.cx("fr-mt-0")}>Statistiques d'utilisation</h1> | ||
<div className={fr.cx("fr-grid-row", "fr-grid-row--gutters")}> | ||
<StatsDisplay title="Contenus référencés" metric={props.nbDocuments} /> | ||
<StatsDisplay title="Visites" metric={props.nbVisits} /> | ||
<StatsDisplay title="Recherches" metric={props.nbSearches} /> | ||
<StatsDisplay title="Consultations" metric={props.nbPageViews} /> | ||
</div> | ||
<p className={fr.cx("fr-mt-4v")}> | ||
Statistiques d’utilisation depuis le 01/01/2020 | ||
</p> | ||
</div> | ||
</div> | ||
); |