Uniformize folder structure (#693)

* Uniformize folder structure

* Fix icons

* Fix icons

* Fix tests

* Fix tests
This commit is contained in:
Charles Bochet
2023-07-16 14:29:28 -07:00
committed by GitHub
parent 900ec5572f
commit 6ced8434bd
462 changed files with 931 additions and 960 deletions
@@ -0,0 +1,28 @@
import { useEffect, useState } from 'react';
import { useRecoilState } from 'recoil';
import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { currentUserState } from '@/auth/states/currentUserState';
import { useGetCurrentUserQuery } from '~/generated/graphql';
export function UserProvider({ children }: React.PropsWithChildren) {
const [, setCurrentUser] = useRecoilState(currentUserState);
const [isLoading, setIsLoading] = useState(true);
const isLogged = useIsLogged();
const { data, loading } = useGetCurrentUserQuery({
skip: !isLogged,
});
useEffect(() => {
if (!loading) {
setIsLoading(false);
}
if (data?.currentUser) {
setCurrentUser(data?.currentUser);
}
}, [setCurrentUser, data, isLoading, loading]);
return isLoading ? <></> : <>{children}</>;
}