Skip to content

Commit

Permalink
fix: show browser version alert
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Dec 10, 2024
1 parent 6dff92b commit 522ed56
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"@tiptap/starter-kit": "^2.4.0",
"@ungap/with-resolvers": "^0.1.0",
"@xstate/store": "^0.0.5",
"bowser": "^2.11.0",
"browser-image-compression": "^2.0.2",
"buffer": "^6.0.3",
"date-fns": "^3.6.0",
Expand Down
21 changes: 21 additions & 0 deletions packages/frontend/src/components/CompatibilityAlert.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Center } from "#styled-system/jsx";
import Alert from "@codegouvfr/react-dsfr/Alert";
import Bowser from "bowser";

const browser = Bowser.getParser(window.navigator.userAgent);
const isWrongVersion = browser.getBrowser().name === "Firefox" && browser.getBrowserVersion().startsWith("102");

export const CompatibilityAlert = () => {
if (!isWrongVersion) return null;
return (
<Center>
<Alert
severity="warning"
title={`
Votre navigateur n'est pas compatible avec l'application.
Veuillez le mettre à jour, ou utiliser un autre navigateur.
`}
/>
</Center>
);
};
3 changes: 2 additions & 1 deletion packages/frontend/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { RouterOutputs } from "../api";
import { useIsLoggedIn } from "../contexts/AuthContext";
import { MenuButton } from "../features/menu/MenuButton";
import { useIsDesktop } from "../hooks/useIsDesktop";
import { CompatibilityAlert } from "#components/CompatibilityAlert";

export const Route = createRootRouteWithContext<Partial<RouterOutputs<"/api/login">>>()({
beforeLoad: (ctx) => {
Expand Down Expand Up @@ -131,7 +132,7 @@ const Layout = ({ children }: PropsWithChildren) => {
/>
{isLoggedIn ? <MenuButton headerRef={headerRef} /> : null}
{/* <Menu headerRef={headerRef} /> */}

<CompatibilityAlert />
<Box flex="1">{children}</Box>
{/* <TanStackRouterDevtools /> */}

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 522ed56

Please sign in to comment.