fix: remove setAuthData after login
This commit is contained in:
@@ -6,12 +6,11 @@ import StyledInput from "../../../common/component/styled/Input";
|
|||||||
import StyledButton from "../../../common/component/styled/Button";
|
import StyledButton from "../../../common/component/styled/Button";
|
||||||
import {
|
import {
|
||||||
useCreateAdminMutation,
|
useCreateAdminMutation,
|
||||||
useGetInitializedQuery,
|
|
||||||
useGetServerQuery,
|
useGetServerQuery,
|
||||||
useUpdateServerMutation
|
useUpdateServerMutation
|
||||||
} from "../../../app/services/server";
|
} from "../../../app/services/server";
|
||||||
import { useLoginMutation } from "../../../app/services/auth";
|
import { useLoginMutation } from "../../../app/services/auth";
|
||||||
import { setAuthData } from "../../../app/slices/auth.data";
|
import { updateInitialized } from "../../../app/slices/auth.data";
|
||||||
|
|
||||||
const StyledAdminCredentialsStep = styled.div`
|
const StyledAdminCredentialsStep = styled.div`
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -33,11 +32,8 @@ export default function AdminCredentialsStep({ data, setStep }) {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const [createAdmin, { isLoading: isSigningUp, error: signUpError }] = useCreateAdminMutation();
|
const [createAdmin, { isLoading: isSigningUp, error: signUpError }] = useCreateAdminMutation();
|
||||||
const [
|
const [login, { isLoading: isLoggingIn, isSuccess: isLoggedIn, error: loginError }] =
|
||||||
login,
|
useLoginMutation();
|
||||||
{ isLoading: isLoggingIn, isSuccess: isLoggedIn, error: loginError, data: loginData }
|
|
||||||
] = useLoginMutation();
|
|
||||||
const { refetch: refetchInitialized } = useGetInitializedQuery();
|
|
||||||
const { data: serverData } = useGetServerQuery();
|
const { data: serverData } = useGetServerQuery();
|
||||||
const [updateServer, { isLoading: isUpdatingServer, isSuccess: isUpdatedServer }] =
|
const [updateServer, { isLoading: isUpdatingServer, isSuccess: isUpdatedServer }] =
|
||||||
useUpdateServerMutation();
|
useUpdateServerMutation();
|
||||||
@@ -58,18 +54,17 @@ export default function AdminCredentialsStep({ data, setStep }) {
|
|||||||
|
|
||||||
// After logged in
|
// After logged in
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isLoggedIn && loginData) {
|
if (isLoggedIn) {
|
||||||
// Update local auth data
|
dispatch(updateInitialized(true));
|
||||||
dispatch(setAuthData(loginData));
|
setTimeout(() => {
|
||||||
// Update initialized state
|
|
||||||
refetchInitialized();
|
|
||||||
// Set server name
|
// Set server name
|
||||||
updateServer({
|
updateServer({
|
||||||
...serverData,
|
...serverData,
|
||||||
name: data.serverName
|
name: data.serverName
|
||||||
});
|
});
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}, [isLoggedIn, loginData]);
|
}, [isLoggedIn]);
|
||||||
|
|
||||||
// After updated server
|
// After updated server
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user