Skip to content

Commit adf6453

Browse files
Fix: AuthForm and Dashboard errors
The `AuthForm` component was missing the `signInWithEmail`, `signUpWithEmail`, and `signInWithGoogle` methods from the `AuthContextType`. The `Dashboard` component was missing the import for `auth`. This commit fixes these issues by ensuring the correct methods are available in the context and importing the `auth` object.
1 parent d33e02a commit adf6453

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/components/Dashboard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { DashboardContent } from '@/components/DashboardContent';
88
import { NetworkStatus } from '@/components/NetworkStatus';
99
import { ErrorBoundary } from '@/components/ErrorBoundary';
1010
import { Helmet } from 'react-helmet-async';
11-
import { memo, useCallback, useMemo, useState } from 'react';
11+
import { memo, useCallback, useMemo } from 'react';
1212
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
1313
import { BarChart3, Users, DollarSign, Percent } from 'lucide-react';
14+
import { auth } from '@/lib/firebase';
1415

1516
// Composant de stats simplifié SANS requêtes Firebase lourdes
1617
const SimpleDashboardStats = ({ activeCampaigns, totalCampaigns, totalAffiliates }) => {

src/contexts/AuthContext.tsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11

22
import React, { createContext, useContext, useEffect, useState } from 'react';
3-
import { User, onAuthStateChanged } from 'firebase/auth';
4-
import { auth } from '@/lib/firebase';
3+
import { User, onAuthStateChanged, signInWithEmailAndPassword, createUserWithEmailAndPassword, signInWithPopup } from 'firebase/auth';
4+
import { auth, googleProvider } from '@/lib/firebase';
55

66
interface AuthContextType {
77
user: User | null;
88
loading: boolean;
9+
signInWithEmail: (email: string, password: string) => Promise<any>;
10+
signUpWithEmail: (email: string, password: string) => Promise<any>;
11+
signInWithGoogle: () => Promise<any>;
912
}
1013

1114
const AuthContext = createContext<AuthContextType>({
1215
user: null,
1316
loading: true,
17+
signInWithEmail: async () => {},
18+
signUpWithEmail: async () => {},
19+
signInWithGoogle: async () => {},
1420
});
1521

1622
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
@@ -41,8 +47,26 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
4147
return unsubscribe;
4248
}, []);
4349

50+
const signInWithEmail = async (email: string, password: string) => {
51+
return signInWithEmailAndPassword(auth, email, password);
52+
};
53+
54+
const signUpWithEmail = async (email: string, password: string) => {
55+
return createUserWithEmailAndPassword(auth, email, password);
56+
};
57+
58+
const signInWithGoogle = async () => {
59+
return signInWithPopup(auth, googleProvider);
60+
};
61+
4462
return (
45-
<AuthContext.Provider value={{ user, loading }}>
63+
<AuthContext.Provider value={{
64+
user,
65+
loading,
66+
signInWithEmail,
67+
signUpWithEmail,
68+
signInWithGoogle
69+
}}>
4670
{children}
4771
</AuthContext.Provider>
4872
);

0 commit comments

Comments
 (0)