Skip to content

Commit

Permalink
feat: add documents section
Browse files Browse the repository at this point in the history
  • Loading branch information
RenauxLeaInsee committed Oct 31, 2024
1 parent d80ce80 commit 2e7a6f2
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 9 deletions.
Binary file added public/documents/chi/courrier/courrier.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 23 additions & 4 deletions src/components/surveyHomepage/DocumentTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,22 @@ export const DocumentTile = ({ title, description, url, pictogramUrl }: Props) =
const link = document.createElement("a");
link.setAttribute("data-fr-assess-file", "bytes");
link.href = url;
link.download = `ressources.${file.extension}`;
link.download = getFileName(url, file.extension);
link.click();
};

if (!file.isDownloadable) {
return <></>;
}

return (
<div className="container">
<Tile
disabled={!file.isDownloadable}
desc={description}
className="fr-mb-3w"
detail={
<p style={{ "color": fr.colors.decisions.text.mention.grey.default }} className="fr-text--xs">
{file.isDownloadable &&
`${file.extension && `${file.extension.toLocaleUpperCase()} - `} ${file.size && (file.size / 1024).toFixed(0)} Ko`}
{`${file.extension && `${file.extension.toLocaleUpperCase()} - `} ${file.size && (file.size / 1024).toFixed(0)} Ko`}
</p>
}
imageSvg
Expand All @@ -79,3 +81,20 @@ export const DocumentTile = ({ title, description, url, pictogramUrl }: Props) =
</div>
);
};

const getFileName = (url: string, extension?: string) => {
if (url.includes("courrier")) {
return `courrier.${extension}`;
}
if (url.includes("mail")) {
return `mail.${extension}`;
}
if (url.includes("questionnaire")) {
return `questionnaire.${extension}`;
}
if (url.includes("notice")) {
return `notice.${extension}`;
}

return `ressource.${extension}`;
};
7 changes: 7 additions & 0 deletions src/components/surveyHomepage/SurveyHomepage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const SideMenuCustom = ({
linkProps: {
to: "/$survey/introduction",
params: { survey: surveyId },
resetScroll: false,
},
text: t("survey introduction"),
},
Expand All @@ -158,6 +159,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: t("legal framework"),
},
Expand All @@ -167,6 +169,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: t("what are your answers for?"),
},
Expand All @@ -176,6 +179,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: t("documents to the surveyed"),
},
Expand All @@ -185,6 +189,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: t("some results"),
},
Expand All @@ -194,6 +199,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: supportTranslation("FAQ"),
},
Expand All @@ -219,6 +225,7 @@ const SideMenuCustom = ({
params: {
survey: surveyId,
},
resetScroll: false,
},
text: supportTranslation("contact support"),
},
Expand Down
33 changes: 29 additions & 4 deletions src/routes/$survey/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,57 @@ function DocumentsIndex() {
const { survey } = Route.useParams();
const { t: homeTranslation } = useTranslation("SurveyHomepage");
const { t } = useTranslation("Documents");

return (
<section className={fr.cx("fr-col-12", "fr-col-md-6", "fr-pr-md-4w")}>
<h3>{homeTranslation("documents to the surveyed")}</h3>
<div>
<DocumentTile
title={t("downloadEMail")}
description={t("downloadEMailDescription")}
url={`/img/${survey}/mail/img-01.png`}
url={`/documents/${survey}/mail/mail.pdf`}
pictogramUrl={"/static/img/mail-send.svg"}
/>
<DocumentTile
title={t("downloadEMail")}
description={t("downloadEMailDescription")}
url={`/documents/${survey}/mail/mail.png`}
pictogramUrl={"/static/img/mail-send.svg"}
/>
<DocumentTile
title={t("downloadInstructions")}
description={t("downloadInstructionsDescription")}
url={`/img/${survey}/notice/img-01.png`}
url={`/documents/${survey}/notice/notice.pdf`}
pictogramUrl={"/static/img/document-download.svg"}
/>
<DocumentTile
title={t("downloadInstructions")}
description={t("downloadInstructionsDescription")}
url={`/documents/${survey}/notice/notice.png`}
pictogramUrl={"/static/img/document-download.svg"}
/>
<DocumentTile
title={t("downloadQuestioning")}
description={t("downloadQuestioningDescription")}
url={`/img/${survey}/questionnaire/img-01.png`}
url={`/documents/${survey}/questionnaire/questionnaire.pdf`}
pictogramUrl={"/static/img/document-signature.svg"}
/>
<DocumentTile
title={t("downloadQuestioning")}
description={t("downloadQuestioningDescription")}
url={`/documents/${survey}/questionnaire/questionnaire.png`}
pictogramUrl={"/static/img/document-signature.svg"}
/>
<DocumentTile
title={t("downloadMail")}
description={t("downloadMailDescription")}
url={`/documents/${survey}/courrier/courrier.pdf`}
pictogramUrl={"/static/img/document.svg"}
/>
<DocumentTile
title={t("downloadMail")}
description={t("downloadMailDescription")}
url={`/img/${survey}/courrier/img-01.png`}
url={`/documents/${survey}/courrier/courrier.png`}
pictogramUrl={"/static/img/document.svg"}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
import { createRootRouteWithContext, Outlet, ScrollRestoration } from "@tanstack/react-router";
import { Footer } from "components/Footer";
import { Header } from "components/Header";
import { QueryClient } from "@tanstack/react-query";
Expand Down Expand Up @@ -35,6 +35,7 @@ function RootComponent() {
/>
<Header />
<main>
<ScrollRestoration />
<Outlet />
</main>
<AutoLogoutCountdown />
Expand Down

0 comments on commit 2e7a6f2

Please sign in to comment.