🔧 fix(authContext.tsx): add import statement for useFlowsManagerStore to fix missing import error

🔧 fix(authContext.tsx): set isLoading to false in useFlowsManagerStore after setLoading to false to fix loading state inconsistency
🔧 fix(typesStore.ts): add null check for response.data to fix potential null reference error
This commit is contained in:
cristhianzl 2024-02-28 10:19:58 -03:00
commit 3377c87449
2 changed files with 3 additions and 1 deletions

View file

@ -7,6 +7,7 @@ import {
requestLogout, requestLogout,
} from "../controllers/API"; } from "../controllers/API";
import useAlertStore from "../stores/alertStore"; import useAlertStore from "../stores/alertStore";
import useFlowsManagerStore from "../stores/flowsManagerStore";
import { Users } from "../types/api"; import { Users } from "../types/api";
import { AuthContextType } from "../types/contexts/auth"; import { AuthContextType } from "../types/contexts/auth";
@ -79,6 +80,7 @@ export function AuthProvider({ children }): React.ReactElement {
getUser(); getUser();
} else { } else {
setLoading(false); setLoading(false);
useFlowsManagerStore.setState({ isLoading: false });
} }
}); });
}, [setUserData, setLoading, autoLogin, setIsAdmin]); }, [setUserData, setLoading, autoLogin, setIsAdmin]);

View file

@ -16,7 +16,7 @@ export const useTypesStore = create<TypesStoreType>((set, get) => ({
setLoading(true); setLoading(true);
getAll() getAll()
.then((response) => { .then((response) => {
const data = response.data; const data = response?.data;
useAlertStore.setState({ loading: false }); useAlertStore.setState({ loading: false });
set((old) => ({ set((old) => ({
types: typesGenerator(data), types: typesGenerator(data),