From d9a085ae26c8d7e7fc8163f2584727f4d62cb4d8 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 9 Sep 2023 18:44:15 +0200 Subject: [PATCH] Created the Verify.jsx --- src/states/Verify/Verify.jsx | 74 ++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/states/Verify/Verify.jsx diff --git a/src/states/Verify/Verify.jsx b/src/states/Verify/Verify.jsx new file mode 100644 index 0000000..16b4301 --- /dev/null +++ b/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 erfolgreich verifiziert + Du kannst dich nun mit deinem Account anmelden. + + + + + } + {!success && (userId && code) && + Verifikation deines Accounts + + {!error && Bitte bestätige deinen Account, indem du auf "Bestätigen" klickst.} + {error && Entweder ist der Verifikationslink ungültig oder dein Account wurde bereits verifiziert.} + + {!error && + + } + {error && + + } + + } + {!success && (!userId || !code) && + Verifikationslink ungültig + Bitte verwende den Link, den wir dir per E-Mail zugesendet haben. + + + + + } + {!isMobile && Confirm} + + ); +} \ No newline at end of file