From ee2578b6a1d7ab43f9076f301c114b04fedb4403 Mon Sep 17 00:00:00 2001 From: Wang Sijie Date: Fri, 24 Jun 2022 10:23:52 +0800 Subject: [PATCH] fix(console): mutate settings after SIE guide done (#1198) --- packages/console/src/hooks/use-settings.ts | 1 + .../src/pages/SignInExperience/components/GuideModal.tsx | 2 +- .../src/pages/SignInExperience/components/Welcome.tsx | 7 ++++++- packages/console/src/pages/SignInExperience/index.tsx | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/console/src/hooks/use-settings.ts b/packages/console/src/hooks/use-settings.ts index ae11e5ac1..c402d1b96 100644 --- a/packages/console/src/hooks/use-settings.ts +++ b/packages/console/src/hooks/use-settings.ts @@ -31,6 +31,7 @@ const useSettings = () => { isLoading: !settings && !error, settings: settings?.adminConsole, error, + mutate, updateSettings, }; }; diff --git a/packages/console/src/pages/SignInExperience/components/GuideModal.tsx b/packages/console/src/pages/SignInExperience/components/GuideModal.tsx index 64badc752..6df1e971c 100644 --- a/packages/console/src/pages/SignInExperience/components/GuideModal.tsx +++ b/packages/console/src/pages/SignInExperience/components/GuideModal.tsx @@ -69,7 +69,7 @@ const GuideModal = ({ isOpen, onClose }: Props) => { updateSettings({ customizeSignInExperience: true }), ]); - location.reload(); + onClose(); }); return ( diff --git a/packages/console/src/pages/SignInExperience/components/Welcome.tsx b/packages/console/src/pages/SignInExperience/components/Welcome.tsx index e938fc7d8..7dcbac678 100644 --- a/packages/console/src/pages/SignInExperience/components/Welcome.tsx +++ b/packages/console/src/pages/SignInExperience/components/Welcome.tsx @@ -12,7 +12,11 @@ import { useTheme } from '@/hooks/use-theme'; import GuideModal from './GuideModal'; import * as styles from './Welcome.module.scss'; -const Welcome = () => { +type Props = { + mutate: () => void; +}; + +const Welcome = ({ mutate }: Props) => { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const [isOpen, setIsOpen] = useState(false); const theme = useTheme(); @@ -37,6 +41,7 @@ const Welcome = () => { isOpen={isOpen} onClose={() => { setIsOpen(false); + mutate(); }} /> diff --git a/packages/console/src/pages/SignInExperience/index.tsx b/packages/console/src/pages/SignInExperience/index.tsx index 698f7535b..8e4940a35 100644 --- a/packages/console/src/pages/SignInExperience/index.tsx +++ b/packages/console/src/pages/SignInExperience/index.tsx @@ -32,7 +32,7 @@ const SignInExperience = () => { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { tab } = useParams(); const { data, error, mutate } = useSWR('/api/sign-in-exp'); - const { settings, error: settingsError, updateSettings } = useSettings(); + const { settings, error: settingsError, updateSettings, mutate: mutateSettings } = useSettings(); const [dataToCompare, setDataToCompare] = useState(); const methods = useForm(); @@ -91,7 +91,7 @@ const SignInExperience = () => { } if (!settings?.customizeSignInExperience) { - return ; + return ; } return (