Updated auth to use generated keys

This commit is contained in:
Benjamin Sherriff
2024-01-29 21:24:10 -05:00
parent f2acb585c0
commit 4609be84a8
19 changed files with 213 additions and 87 deletions

View File

@@ -1,7 +1,24 @@
import { User } from '@/api/auth.types';
import { atom } from 'recoil';
import { atom, selector } from 'recoil';
export const userState = atom({
key: 'userState',
default: undefined as User | undefined
});
export const hasUserState = selector({
key: 'hasUserState',
get: ({ get }) => {
const user = get(userState);
return user !== undefined;
}
});
export const isAdminState = selector({
key: 'isAdminState',
get: ({ get }) => {
const user = get(userState);
return user?.role === 'admin';
}
});