From bcc323028c789a0b81061fd054968f44afd1aacf Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 11 Feb 2024 16:00:02 +0100 Subject: [PATCH] direct redirecting --- public/locales/de/translation.json | 6 --- public/locales/en/translation.json | 6 --- src/Components/AppRoutes/index.js | 11 ----- src/Pages/Store/Calendar/Auth/index.js | 58 ++++++-------------------- 4 files changed, 13 insertions(+), 68 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index abe5581..d6bfc4f 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -230,12 +230,6 @@ }, "calendar": { "pageTitle": "Kalender", - "authFinish": { - "title": "Erfolgreich verbunden", - "description": "Die Verbindung mit Ihrem Google-Kalender war erfolgreich.", - "button": "Weiter zum Kalender", - "countDownRedirect": "Sie werden in {{countDown}} Sekunden weitergeleitet." - }, "authFailed": { "title": "Verbindung fehlgeschlagen", "description": "Die Verbindung mit Ihrem Google-Kalender ist fehlgeschlagen.", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 98ccf24..6eedffd 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -233,12 +233,6 @@ }, "calendar": { "pageTitle": "Calendar", - "authFinish": { - "title": "Connection successful", - "description": "Connection to your calendar was successful.", - "button": "Continue to calendar", - "countDownRedirect": "Redirecting to calendar in {{countDown}} seconds" - }, "authFailed": { "title": "Connection failed", "description": "Connection to your calendar failed.", diff --git a/src/Components/AppRoutes/index.js b/src/Components/AppRoutes/index.js index 14380fc..804634d 100644 --- a/src/Components/AppRoutes/index.js +++ b/src/Components/AppRoutes/index.js @@ -181,14 +181,3 @@ export function AppRoutes({ setUserSession }) { ); } - -/* - - - - } - /> -*/ diff --git a/src/Pages/Store/Calendar/Auth/index.js b/src/Pages/Store/Calendar/Auth/index.js index 4c0cdbc..f318119 100644 --- a/src/Pages/Store/Calendar/Auth/index.js +++ b/src/Pages/Store/Calendar/Auth/index.js @@ -1,4 +1,4 @@ -import { Button, Flex, Result, Spin, Typography, notification } from "antd"; +import { Button, Flex, Result, Spin, notification } from "antd"; import { Link, useParams, useNavigate } from "react-router-dom"; import { Constants, myFetch } from "../../../../utils"; import { useEffect, useState } from "react"; @@ -9,6 +9,7 @@ export default function StoreCalendarAuth() { const { t } = useTranslation(); const [notificationApi, notificationContextHolder] = notification.useNotification(); + const navigate = useNavigate(); const { status } = useParams(); @@ -23,6 +24,13 @@ export default function StoreCalendarAuth() { t: t, }) .then((res) => { + if (status === "finish") { + navigate( + `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${res.storeId}/${Constants.ROUTE_PATHS.STORE.CALENDAR}` + ); + return; + } + setIsRequesting(false); setStoreId(res.storeId); }) @@ -44,59 +52,19 @@ export default function StoreCalendarAuth() { {notificationContextHolder} - + - - {status === "finish" && } , ]} /> ); } - -function CountdownRedirect({ storeId }) { - const { t } = useTranslation(); - const navigate = useNavigate(); - - const [count, setCount] = useState(5); - - useEffect(() => { - if (count > 0) { - const timer = setTimeout(() => { - setCount(count - 1); - }, 1000); - return () => clearTimeout(timer); - } else { - navigate( - `${Constants.ROUTE_PATHS.STORE.OVERVIEW}/${storeId}/${Constants.ROUTE_PATHS.STORE.CALENDAR}` - ); - } - }, [count, navigate]); - - return ( - - {t("calendar.authFinish.countDownRedirect", { countDown: count })} - - ); -}