From 54d8df4a7539779301e7dc0b3117379d1b78cf56 Mon Sep 17 00:00:00 2001 From: ledouxm Date: Sun, 8 Dec 2024 12:47:01 +0100 Subject: [PATCH] feat: display disconnect message on login form --- packages/frontend/src/components/LoginForm.tsx | 11 +++++++++++ packages/frontend/src/contexts/AuthContext.tsx | 1 + 2 files changed, 12 insertions(+) diff --git a/packages/frontend/src/components/LoginForm.tsx b/packages/frontend/src/components/LoginForm.tsx index 272892f..493c920 100644 --- a/packages/frontend/src/components/LoginForm.tsx +++ b/packages/frontend/src/components/LoginForm.tsx @@ -10,6 +10,7 @@ import { InputGroup } from "./InputGroup"; import { PasswordInput } from "./PasswordInput"; import { useMutation } from "@tanstack/react-query"; import { type RouterInputs, api, getErrorMessage } from "../api"; +import { useState } from "react"; export const LoginForm = () => { const [authData, setAuthData] = useAuthContext(); @@ -17,9 +18,12 @@ export const LoginForm = () => { const mutation = useMutation((body: LoginFormProps) => api.post("/api/login", { body })); + const [shouldShowPopup] = useState(localStorage.getItem("crvif/update-popup")); + const login = async (values: LoginFormProps) => { const response = await mutation.mutateAsync(values); localStorage.setItem("crvif/version", "1"); + localStorage.removeItem("crvif/update-popup"); setAuthData({ ...authData, ...response }); }; @@ -36,6 +40,13 @@ export const LoginForm = () => { title={{getErrorMessage(mutationError)}} /> ) : null} + {shouldShowPopup && !mutationError ? ( + + ) : null} { const version = localStorage.getItem("crvif/version"); if (!version) { localStorage.removeItem("crvif/auth"); + localStorage.setItem("crvif/update-popup", "true"); localStorage.setItem("crvif/version", "1"); window.location.reload(); }