@@ -32,6 +32,7 @@ export const Layout: React.FC = ({ const { data: sessionData } = useSession() const appState = useAppSelector((state) => state) const dispatch = useAppDispatch() + const [isLoading, setIsLoading] = useState(false) const desktop = device === 'desktop' @@ -39,13 +40,20 @@ export const Layout: React.FC = ({ useTheme() - const { data, status } = useSession() + const { data } = useSession() const router = useRouter() + async function getUserData(access: string) { + setIsLoading(true) + await dispatch(getUserBalance(access)) + await dispatch(getAllInfo(access)) + setIsLoading(false) + } + React.useEffect(() => { - dispatch(getUserBalance(data?.access)) - dispatch(getAllInfo(data?.access)) + if (!data) return + getUserData(data.access) }, [data]) React.useEffect(() => { @@ -84,14 +92,6 @@ export const Layout: React.FC = ({ } }, [appState.settings.state]) - if (status === 'loading' || isLoader) { - return ( - - - - ) - } - return ( <> @@ -102,43 +102,50 @@ export const Layout: React.FC = ({ - + {isLoading || isLoader ? ( + + + + ) : ( - {desktop ? ( - - - - - - {children} + + {desktop ? ( + + + + + + {children} + - - ) : ( - - - {children} - - )} + ) : ( + + + {children} + + )} + - + )} ) }