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,13 +0,0 @@
|
||||
import jwt from 'jwt-decode';
|
||||
|
||||
import { AuthTokenPair, useGetCurrentUserQuery } from '~/generated/graphql';
|
||||
|
||||
export function useFetchCurrentUser(tokenPair: AuthTokenPair | null) {
|
||||
const userId = tokenPair?.accessToken.token
|
||||
? jwt<{ sub: string }>(tokenPair.accessToken.token).sub
|
||||
: null;
|
||||
const { data } = useGetCurrentUserQuery({
|
||||
variables: { uuid: userId },
|
||||
});
|
||||
return data?.users?.[0];
|
||||
}
|
||||
20
front/src/modules/auth/hooks/useOnboardingStatus.ts
Normal file
20
front/src/modules/auth/hooks/useOnboardingStatus.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { useIsLogged } from '../hooks/useIsLogged';
|
||||
import { currentUserState } from '../states/currentUserState';
|
||||
import {
|
||||
getOnboardingStatus,
|
||||
OnboardingStatus,
|
||||
} from '../utils/getOnboardingStatus';
|
||||
|
||||
export function useOnboardingStatus(): OnboardingStatus {
|
||||
const [currentUser] = useRecoilState(currentUserState);
|
||||
const isLoggedIn = useIsLogged();
|
||||
const onboardingStatus = useMemo(
|
||||
() => getOnboardingStatus(isLoggedIn, currentUser),
|
||||
[currentUser, isLoggedIn],
|
||||
);
|
||||
|
||||
return onboardingStatus;
|
||||
}
|
||||
Reference in New Issue
Block a user