|
1 | | -import { LoadingOverlay } from '@mantine/core'; |
2 | 1 | import { auth } from '@notes/database'; |
| 2 | +import { TContextAuth } from '@notes/types'; |
3 | 3 | import { |
4 | 4 | signInWithEmailAndPassword, |
5 | 5 | User, |
6 | | - UserCredential, |
7 | 6 | createUserWithEmailAndPassword, |
8 | 7 | updateProfile, |
9 | 8 | signOut |
10 | 9 | } from 'firebase/auth'; |
11 | 10 | import { createContext, useEffect, useState } from 'react'; |
12 | 11 |
|
13 | | -type ContextAuth = { |
14 | | - user: User | undefined; |
15 | | - signIn: (email: string, password: string) => Promise<UserCredential>; |
16 | | - signUp: (email: string, password: string, displayName: string) => Promise<UserCredential>; |
17 | | - loading: boolean; |
18 | | - setLoadingState: (loading: boolean) => void; |
19 | | - signUserOut: () => Promise<void>; |
20 | | -}; |
21 | | - |
22 | | -export const AuthContext = createContext<ContextAuth | undefined>(undefined); |
| 12 | +export const AuthContext = createContext<TContextAuth | undefined>(undefined); |
23 | 13 |
|
24 | 14 | export function AuthProvider({ children }) { |
25 | 15 | const [user, setUser] = useState<User>(); |
@@ -59,7 +49,7 @@ export function AuthProvider({ children }) { |
59 | 49 | return unsubscribe; |
60 | 50 | }, []); |
61 | 51 |
|
62 | | - const value: ContextAuth = { user, signIn, signUp, signUserOut, loading, setLoadingState }; |
| 52 | + const value: TContextAuth = { user, signIn, signUp, signUserOut, loading, setLoadingState }; |
63 | 53 |
|
64 | 54 | return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>; |
65 | 55 | } |
0 commit comments