From 58182e1a46d7113e2dfa54e056b9d78af0c375f3 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 20 Jul 2024 13:00:52 +0200 Subject: [PATCH] Create Verify state --- dashboard/src/states/Verify/Verify.jsx | 74 ++++++++++++++++++++++++++ dashboard/src/states/Verify/index.js | 1 + 2 files changed, 75 insertions(+) create mode 100644 dashboard/src/states/Verify/Verify.jsx create mode 100644 dashboard/src/states/Verify/index.js diff --git a/dashboard/src/states/Verify/Verify.jsx b/dashboard/src/states/Verify/Verify.jsx new file mode 100644 index 0000000..4c06364 --- /dev/null +++ b/dashboard/src/states/Verify/Verify.jsx @@ -0,0 +1,74 @@ +import {Button, CircularProgress, Stack, Typography, useMediaQuery, useTheme} from "@mui/material"; +import ConfirmImage from "@/common/assets/images/confirm.svg"; +import {useState} from "react"; +import {postRequest} from "@/common/utils/RequestUtil.js"; + +export const Verify = () => { + const userId = location.pathname.split("/")[2]; + const code = location.pathname.split("/")[3]; + + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down("lg")); + + const [loading, setLoading] = useState(false); + const [error, setError] = useState(false); + const [success, setSuccess] = useState(false); + + const verify = () => { + setLoading(true); + + setTimeout(async () => { + try { + await postRequest("/user/verify", {id: userId, code}); + setSuccess(true); + } catch (e) { + setError(true); + setLoading(false); + } + }, 1000); + } + + return ( + + {success && + Account verified successfully + You can now login to your account. + + + + + } + {!success && (userId && code) && + Account verification + + {!error && Please click the button below to verify your account.} + {error && Either the verification link is invalid or your account has already been verified.} + + {!error && + + } + {error && + + } + + } + {!success && (!userId || !code) && + Invalid verification link + Please make sure you have clicked the correct link. + + + + + } + {!isMobile && Confirm} + + ); +} \ No newline at end of file diff --git a/dashboard/src/states/Verify/index.js b/dashboard/src/states/Verify/index.js new file mode 100644 index 0000000..794fd48 --- /dev/null +++ b/dashboard/src/states/Verify/index.js @@ -0,0 +1 @@ +export {Verify as default} from "./Verify.jsx"; \ No newline at end of file