feat: onboarding & profile edition (#507)
* feat: wip onboarding * fix: generate graphql front * wip: onboarding * feat: login/register and edit profile * fix: unused import * fix: test * Use DEBUG_MODE instead of STAGE and mute typescript depth exceed errors * Fix seeds * Fix onboarding when coming from google * Fix * Fix lint * Fix ci * Fix tests --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,19 +1,11 @@
|
||||
import { ApolloProvider as ApolloProviderBase } from '@apollo/client';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { useApolloFactory } from '@/apollo/hooks/useApolloFactory';
|
||||
import useApolloMocked from '@/apollo/hooks/useApolloMocked';
|
||||
import { isMockModeState } from '@/auth/states/isMockModeState';
|
||||
|
||||
export function ApolloProvider({ children }: React.PropsWithChildren) {
|
||||
const apolloClient = useApolloFactory();
|
||||
const mockedClient = useApolloMocked();
|
||||
|
||||
const [isMockMode] = useRecoilState(isMockModeState);
|
||||
|
||||
return (
|
||||
<ApolloProviderBase client={isMockMode ? mockedClient : apolloClient}>
|
||||
{children}
|
||||
</ApolloProviderBase>
|
||||
<ApolloProviderBase client={apolloClient}>{children}</ApolloProviderBase>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,20 +1,18 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { useFetchCurrentUser } from '@/auth/hooks/useFetchCurrentUser';
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { tokenPairState } from '@/auth/states/tokenPairState';
|
||||
import { useGetCurrentUserQuery } from '~/generated/graphql';
|
||||
|
||||
export function UserProvider({ children }: React.PropsWithChildren) {
|
||||
const [, setCurrentUser] = useRecoilState(currentUserState);
|
||||
const [tokenPair] = useRecoilState(tokenPairState);
|
||||
const user = useFetchCurrentUser(tokenPair);
|
||||
const { data, loading } = useGetCurrentUserQuery();
|
||||
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
setCurrentUser(user);
|
||||
if (data?.currentUser) {
|
||||
setCurrentUser(data?.currentUser);
|
||||
}
|
||||
}, [setCurrentUser, user]);
|
||||
}, [setCurrentUser, data]);
|
||||
|
||||
return <>{children}</>;
|
||||
return loading ? <></> : <>{children}</>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user