Add onboarding screen + token check
This commit is contained in:
parent
b951d0a0bc
commit
f5c59f602a
19 changed files with 433 additions and 279 deletions
31
context/AppProvider.tsx
Normal file
31
context/AppProvider.tsx
Normal file
|
@ -0,0 +1,31 @@
|
|||
import {createContext, PropsWithChildren, useContext} from "react";
|
||||
import {useStorageState} from '@/context/UseStorageState';
|
||||
|
||||
type TokenType = {
|
||||
token: string | null;
|
||||
setToken: (token: string | null) => void;
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
const TokenContext = createContext<TokenType>({
|
||||
setToken: () => {
|
||||
},
|
||||
token: null,
|
||||
isLoading: true,
|
||||
});
|
||||
|
||||
export const useToken = () => useContext(TokenContext);
|
||||
|
||||
export function AppProvider({ children }: PropsWithChildren) {
|
||||
const [[isLoading, token], setSession] = useStorageState('appToken');
|
||||
|
||||
const tokenContext: TokenType = {
|
||||
token,
|
||||
setToken: (token) => {
|
||||
setSession(token);
|
||||
},
|
||||
isLoading,
|
||||
};
|
||||
|
||||
return <TokenContext.Provider value={tokenContext}>{children}</TokenContext.Provider>;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue