Skip to content

Commit

Permalink
fix: shared report permissions (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm authored Sep 27, 2024
1 parent 727a222 commit d18720c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/backend/src/features/mail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export const sendReportMail = ({
text: `Bonjour,
vous trouverez ci-joint le compte-rendu de notre rendez-vous.
Ce compte-rendu est un nouveau dispositif en phase de développement pour but d’aider l’usager
dans sa démarche. Aidez-nous à l’améliorer en répondant à ce questionnaire anonyme de moins d’une minute : https://adtk8x51mbw.eu.typeform.com/to/LHrKhXkd
Ce compte-rendu est un nouveau dispositif en phase de développement pour but d’aider l’usager dans sa démarche. Aidez-nous à l’améliorer en répondant à ce questionnaire anonyme de moins d’une minute : https://adtk8x51mbw.eu.typeform.com/to/LHrKhXkd
Cordialement`,
attachments: [
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<body>
<div id="root"></div>
<script src="/env.js"></script>
<script src="/version.js"></script>
<script type="module">
const matomoUrl = import.meta.env.PROD ? window.ENV.VITE_MATOMO_URL : import.meta.env.VITE_MATOMO_URL;

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cr-vif/frontend",
"private": true,
"version": "1.0.0",
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -10,6 +10,7 @@
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "pnpm env:gen && vite preview --host",
"env:gen": "vite-node ./scripts/createEnvFile.ts",
"version": "vite-node ./scripts/setVersion.ts",
"prepare": "pnpm dsfr && panda codegen",
"dsfr": "copy-dsfr-to-public && pnpm panda-ds",
"icons": "only-include-used-icons",
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/scripts/createEnvFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const createEnvFile = async () => {
.map(([key, value]) => `${key}: "${value}"`)
.join(",\n");


const contentJs = `window.ENV = { ${values} };`;

await fs.writeFile("./dist/env.js", contentJs);
Expand Down
11 changes: 11 additions & 0 deletions packages/frontend/scripts/setVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pjson from '../package.json';
import fs from "node:fs/promises";

const version = pjson.version + "." + Math.floor(Date.now() / 1000).toString(16);

const setVersion = async () => {
const contentJs = `window.APP_VERSION = "${version}";`;
await fs.writeFile("./dist/version.js", contentJs);
}

setVersion();
1 change: 1 addition & 0 deletions packages/frontend/src/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const ENV = envSchema.parse(isDev ? import.meta.env : window.ENV);
declare global {
interface Window {
ENV: typeof ENV;
APP_VERSION?: string;
}
}
1 change: 1 addition & 0 deletions packages/frontend/src/features/menu/MenuTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const MenuTitle = ({
alignItems="center"
w="100%"
py={{ base: "16px", lg: "30px" }}
pl={{ base: undefined, lg: "16px" }}
// mt={{ base: "0", lg: "48px" }}
// mb={{ base: "16px", lg: "48px" }}
bgColor="white"
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReportSearch } from "#components/ReportSearch.js";
import { css } from "#styled-system/css";
import { Box, Flex, Stack } from "#styled-system/jsx";
import { Box, Flex, Stack, styled } from "#styled-system/jsx";
import Badge from "@codegouvfr/react-dsfr/Badge";
import Button from "@codegouvfr/react-dsfr/Button";
import Footer from "@codegouvfr/react-dsfr/Footer";
Expand Down Expand Up @@ -139,3 +139,11 @@ const Layout = ({ children }: PropsWithChildren) => {
</Flex>
);
};

const VersionDisplay = () => {
const version = window.APP_VERSION;

if (!version) return null;

return <styled.div>Version {version}</styled.div>;
};

0 comments on commit d18720c

Please sign in to comment.