From c7f08d97336d7447cf5b95a2c95587a1bb52e988 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 18 Feb 2024 19:43:55 +0100 Subject: [PATCH] demo account --- src/Components/AppRoutes/index.js | 10 +++++++++ src/Pages/RedirectToDemo/index.js | 34 +++++++++++++++++++++++++++++++ src/Pages/UserProfile/index.js | 8 +++++++- src/utils.js | 1 + 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/Pages/RedirectToDemo/index.js diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index 1d2772b..a5c2ad9 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -26,6 +26,7 @@ const StoreCalendarAuth = lazy(() => import("../../Pages/Store/Calendar/Auth")); //const Support = lazy(() => import("../../Pages/Support")); //const Feedback = lazy(() => import("../../Pages/Feedback")); const UserProfile = lazy(() => import("../../Pages/UserProfile")); +const RedirectToDemo = lazy(() => import("../../Pages/RedirectToDemo")); export function AuthenticationRoutes() { return ( @@ -84,6 +85,15 @@ export function AuthenticationRoutes() { } /> + + + + } + /> + } diff --git a/src/Pages/RedirectToDemo/index.js b/src/Pages/RedirectToDemo/index.js new file mode 100644 index 0000000..374b3f4 --- /dev/null +++ b/src/Pages/RedirectToDemo/index.js @@ -0,0 +1,34 @@ +import { useEffect } from "react"; +import MyCenteredSpin from "../../Components/MyCenteredSpin"; +import { + myFetch, + setUserSessionToLocalStorage, + showUnkownErrorNotification, +} from "../../utils"; +import { useTranslation } from "react-i18next"; +import { notification } from "antd"; + +export default function RedirectToDemo() { + const { t } = useTranslation(); + const [notificationApi, notificationContextHolder] = + notification.useNotification(); + + useEffect(() => { + myFetch({ + url: "/user/demo", + method: "GET", + }) + .then((response) => { + setUserSessionToLocalStorage(response.XAuthorization); + window.location.href = "/"; + }) + .catch(() => showUnkownErrorNotification(notificationApi, t)); + }, []); + + return ( + <> + {notificationContextHolder} + + + ); +} diff --git a/src/Pages/UserProfile/index.js b/src/Pages/UserProfile/index.js index 21afc81..575c939 100644 --- a/src/Pages/UserProfile/index.js +++ b/src/Pages/UserProfile/index.js @@ -406,6 +406,7 @@ function YourProfileChangeEmailModal() { method: "POST", body: { email: values.email, + password: EncodeStringToBase64(values.password), }, }) .then(() => { @@ -421,7 +422,10 @@ function YourProfileChangeEmailModal() { ), }); }) - .catch(() => setIsRequesting(false)); + .catch(() => { + setIsRequesting(false); + showPasswordIncorrectNotification(notificationApi, t); + }); }) .catch(() => setIsRequesting(false)); }} @@ -434,6 +438,8 @@ function YourProfileChangeEmailModal() { + + diff --git a/src/utils.js b/src/utils.js index b67b94f..91c6765 100644 --- a/src/utils.js +++ b/src/utils.js @@ -66,6 +66,7 @@ export const Constants = { FEEDBACK: "/feedback", SUPPORT: "/support", USER_PROFILE: "/user-profile", + DEMO: "/demo", }, GLOBALS: { MIN_USERNAME_LENGTH: 3,