@@ -13,22 +13,14 @@ import { auth, provider } from '@/firebase';
1313interface AuthContextType {
1414 user : User | null ;
1515 loading : boolean ;
16- // TODO: Remove once there is a toast
1716 error : string | null ;
1817 signInWithGoogle : ( ) => Promise < void > ;
1918 signOut : ( ) => Promise < void > ;
2019}
2120
22- interface FirebaseAuthError {
23- code : string ;
24- message : string ;
25- name : string ;
26- }
27-
2821const AuthContext = createContext < AuthContextType > ( {
2922 user : null ,
3023 loading : true ,
31- // TODO: Remove once there is a toast
3224 error : null ,
3325 signInWithGoogle : async ( ) => { } ,
3426 signOut : async ( ) => { } ,
@@ -45,15 +37,13 @@ export const useAuth = () => {
4537export const AuthProvider = ( { children } : { children : ReactNode } ) => {
4638 const [ user , setUser ] = useState < User | null > ( null ) ;
4739 const [ loading , setLoading ] = useState < boolean > ( true ) ;
48- // TODO: Remove once there is a toast
4940 const [ error , setError ] = useState < string | null > ( null ) ;
5041 const router = useRouter ( ) ;
5142
5243 const signInWithGoogle = async ( ) => {
5344 setError ( null ) ;
5445 await signInWithPopup ( auth , provider ) . catch ( ( error ) => {
55- // TODO: Add toast to tell user there is an error
56- setError ( ( error as FirebaseAuthError ) . message ) ;
46+ setError ( ( error as Error ) . message ) ;
5747 } ) ;
5848 } ;
5949
@@ -65,8 +55,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
6555 await fetch ( '/api/logout' ) ;
6656 } )
6757 . catch ( ( error ) => {
68- // TODO: Add toast to tell user there is an error
69- setError ( ( error as FirebaseAuthError ) . message ) ;
58+ setError ( ( error as Error ) . message ) ;
7059 } ) ;
7160 } ;
7261
@@ -100,7 +89,6 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
10089
10190 setUser ( currentUser ) ;
10291 } catch ( error ) {
103- // TODO: Add toast to tell user there is an error
10492 setError ( JSON . parse ( ( error as Error ) . message ) . message ) ;
10593 setUser ( null ) ;
10694 } finally {
@@ -111,10 +99,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
11199 } ) ;
112100
113101 return (
114- < AuthContext . Provider
115- // TODO: Remove once there is a toast
116- value = { { user, loading, error, signInWithGoogle, signOut } }
117- >
102+ < AuthContext . Provider value = { { user, loading, error, signInWithGoogle, signOut } } >
118103 { children }
119104 </ AuthContext . Provider >
120105 ) ;
0 commit comments