fix: onboarding step

This commit is contained in:
Tristan Yang
2022-07-31 22:57:02 +08:00
parent 85ee4d9384
commit 3b35e18150
2 changed files with 9 additions and 5 deletions
+4 -1
View File
@@ -76,7 +76,10 @@ export default function OnboardingPage() {
<WhoCanSignUp {...serverSetup} />
</SwiperSlide>
<SwiperSlide>
<InviteLink {...serverSetup} />
{/* lazy call invite link API */}
{({ isActive }) => {
return isActive ? <InviteLink {...serverSetup} /> : null;
}}
</SwiperSlide>
<SwiperSlide>
<DonePage {...serverSetup} />
+5 -4
View File
@@ -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<Props> = ({ 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<Props> = ({ 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<Props> = ({ serverName, nextStep }) => {
name: serverName
});
}
}, [isLoggedIn]);
}, [loggedIn]);
// After updated server
useEffect(() => {