From 3b35e18150e43a09308f56eb2b4ea4c5e6437d4f Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Sun, 31 Jul 2022 22:57:02 +0800 Subject: [PATCH] fix: onboarding step --- src/routes/onboarding/index.tsx | 5 ++++- src/routes/onboarding/steps/adminAccount.tsx | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routes/onboarding/index.tsx b/src/routes/onboarding/index.tsx index 3094a7c6..68b4b6ad 100644 --- a/src/routes/onboarding/index.tsx +++ b/src/routes/onboarding/index.tsx @@ -76,7 +76,10 @@ export default function OnboardingPage() { - + {/* lazy call invite link API */} + {({ isActive }) => { + return isActive ? : null; + }} diff --git a/src/routes/onboarding/steps/adminAccount.tsx b/src/routes/onboarding/steps/adminAccount.tsx index cf4e768d..9b3638a0 100644 --- a/src/routes/onboarding/steps/adminAccount.tsx +++ b/src/routes/onboarding/steps/adminAccount.tsx @@ -11,6 +11,7 @@ import { } from "../../../app/services/server"; import { useLoginMutation } from "../../../app/services/auth"; import { updateInitialized } from "../../../app/slices/auth.data"; +import { useAppSelector } from "../../../app/store"; const StyledWrapper = styled.div` height: 100%; @@ -67,11 +68,11 @@ type Props = { nextStep: () => void; }; const AdminAccount: FC = ({ serverName, nextStep }) => { + const loggedIn = useAppSelector((store) => !!store.authData.token); const dispatch = useDispatch(); const [createAdmin, { isLoading: isSigningUp, error: signUpError }] = useCreateAdminMutation(); - const [login, { isLoading: isLoggingIn, isSuccess: isLoggedIn, error: loginError }] = - useLoginMutation(); + const [login, { isLoading: isLoggingIn, error: loginError }] = useLoginMutation(); const { data: serverData } = useGetServerQuery(); const [updateServer, { isLoading: isUpdatingServer, isSuccess: isUpdatedServer }] = useUpdateServerMutation(); @@ -92,7 +93,7 @@ const AdminAccount: FC = ({ serverName, nextStep }) => { // After logged in useEffect(() => { - if (isLoggedIn && serverData) { + if (loggedIn && serverData) { dispatch(updateInitialized(true)); // Set server name updateServer({ @@ -100,7 +101,7 @@ const AdminAccount: FC = ({ serverName, nextStep }) => { name: serverName }); } - }, [isLoggedIn]); + }, [loggedIn]); // After updated server useEffect(() => {