Reorganize context/states/selectors in dedicated folders (#1205)
* Reorganize context/states/selectors in dedicated folders * linter
This commit is contained in:
@ -10,12 +10,10 @@ import {
|
||||
} from '~/generated/graphql';
|
||||
|
||||
import { currentUserState } from '../states/currentUserState';
|
||||
import { isAuthenticatingState } from '../states/isAuthenticatingState';
|
||||
import { tokenPairState } from '../states/tokenPairState';
|
||||
|
||||
export function useAuth() {
|
||||
const [, setTokenPair] = useRecoilState(tokenPairState);
|
||||
const [, setIsAuthenticating] = useRecoilState(isAuthenticatingState);
|
||||
const [, setCurrentUser] = useRecoilState(currentUserState);
|
||||
|
||||
const [challenge] = useChallengeMutation();
|
||||
@ -65,11 +63,9 @@ export function useAuth() {
|
||||
setCurrentUser(verifyResult.data?.verify.user);
|
||||
setTokenPair(verifyResult.data?.verify.tokens);
|
||||
|
||||
setIsAuthenticating(false);
|
||||
|
||||
return verifyResult.data?.verify;
|
||||
},
|
||||
[setIsAuthenticating, setTokenPair, verify, setCurrentUser],
|
||||
[setTokenPair, verify, setCurrentUser],
|
||||
);
|
||||
|
||||
const handleCrendentialsSignIn = useCallback(
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const authFlowUserEmailState = atom<string>({
|
||||
key: 'authFlowUserEmailState',
|
||||
default: '',
|
||||
});
|
||||
@ -1,11 +0,0 @@
|
||||
import { selector } from 'recoil';
|
||||
|
||||
import { currentUserState } from './currentUserState';
|
||||
|
||||
export const isAuthenticatedState = selector<boolean>({
|
||||
key: 'isAuthenticatedState',
|
||||
get: ({ get }) => {
|
||||
const user = get(currentUserState);
|
||||
return !!user;
|
||||
},
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
import { atom } from 'recoil';
|
||||
|
||||
export const isAuthenticatingState = atom<boolean>({
|
||||
key: 'isAuthenticatingState',
|
||||
default: true,
|
||||
});
|
||||
Reference in New Issue
Block a user