-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add surveyList page and SurveyHomepage and remove homepage
- Loading branch information
1 parent
47a10b6
commit 9117fe0
Showing
20 changed files
with
296 additions
and
179 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
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,68 @@ | ||
import { useTranslation } from "i18n"; | ||
import Banner from "../../assets/banner.svg"; | ||
import { tss } from "tss-react/dsfr"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
import content from "resources/content.json"; | ||
import { Card } from "@codegouvfr/react-dsfr/Card"; | ||
import Grid from "@mui/material/Grid"; | ||
|
||
export const SurveysList = () => { | ||
const { t } = useTranslation("SurveyHomepage"); | ||
const { classes, cx } = useStyles(); | ||
|
||
const surveys = content.specifique.map(survey => { | ||
return { titleShort: survey.titleShort, id: survey.id }; | ||
}); | ||
|
||
return ( | ||
<div className={classes.pageContainer}> | ||
<img | ||
src={Banner} | ||
alt="" | ||
role="presentation" | ||
width={"100%"} | ||
className={cx("fr-unhidden-md", "fr-hidden")} | ||
/> | ||
<div className={fr.cx("fr-container", "fr-py-5w")}> | ||
<h2>{t("title")}</h2> | ||
<Grid | ||
sx={{ | ||
display: "grid", | ||
gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))", | ||
paddingBottom: 2, | ||
minHeight: 0, | ||
overflow: "auto", | ||
width: "calc(100% + .5rem)", | ||
paddingRight: ".5rem", | ||
}} | ||
gap={2} | ||
> | ||
{surveys.map(survey => ( | ||
<Card | ||
key={survey.id} | ||
background | ||
border | ||
enlargeLink | ||
horizontal | ||
linkProps={{ | ||
to: "/$survey", | ||
params: { | ||
survey: survey.id, | ||
}, | ||
}} | ||
endDetail={`${import.meta.env.VITE_PORTAIL_URL}/${survey.id}`} | ||
title={survey.titleShort} | ||
titleAs="h5" | ||
/> | ||
))} | ||
</Grid> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const useStyles = tss.withName({ SurveysList }).create({ | ||
pageContainer: { | ||
width: "100vw", | ||
}, | ||
}); |
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
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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
export const fetchContent = async (currentPath: string) => { | ||
try { | ||
const url = `${import.meta.env.VITE_CONTENT_URL}/${currentPath}.json`; | ||
const response = await fetch(url); | ||
|
||
if (!response.ok) { | ||
throw new Error('No content found'); | ||
} | ||
return await response.json(); | ||
try { | ||
const url = `${import.meta.env.VITE_CONTENT_URL}/${currentPath}.json`; | ||
const response = await fetch(url); | ||
|
||
} catch (error) { | ||
console.error('There was a problem:', error); | ||
throw error; | ||
if (!response.ok) { | ||
throw new Error("No content found"); | ||
} | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error("There was a problem:", error); | ||
throw error; | ||
} | ||
}; |
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
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
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
Oops, something went wrong.