1- //Firebase
21import { auth } from '../../Firebase/firebase' ;
32
3+ //React Hooks
4+ import { useState , useEffect } from 'react' ;
45
56//Components
67import { Button } from '../../Components' ;
@@ -9,62 +10,38 @@ import { Button } from '../../Components';
910import { toast , ToastContainer } from "react-toastify" ;
1011import 'react-toastify/dist/ReactToastify.css' ;
1112
12-
13- // const contacts = ['Contact 1', 'Contact 2', 'Contact 3', 'Contact 4', 'Contact 5', 'Contact 6'];
14-
15-
1613const Dashboard = ( ) => {
1714
18-
1915 const handleSignout = ( ) => {
2016 auth . signOut ( )
21- toast . error ( ( 'Signing Out!' ) , {
17+ toast . error ( 'Signing Out!' , {
2218 position : 'top-right'
23- } )
19+ } ) ;
2420 setTimeout ( ( ) => {
25- window . location . href = 'login'
26- } , 2000 )
27- }
21+ window . location . href = '/ login' ;
22+ } , 2000 ) ;
23+ } ;
2824
29- return (
30- // <div className="min-h-screen flex bg-gray-100">
31- // {/* Sidebar */}
32- // <aside className="bg-white bg-opacity-10 backdrop-blur-md h-screen w-64 p-5 shadow-lg flex flex-col justify-between">
33- // <nav className="space-y-6 text-xl text-gray-800 flex flex-col gap-y-[20px]">
34- // <button className="hover:text-gray-600">Chats</button>
35- // <button className="hover:text-gray-600">Contacts</button>
36- // <button className="hover:text-gray-600">Settings</button>
37- // </nav>
38- // <button className="w-full py-3 bg-red-500 hover:bg-red-600 text-white text-lg rounded-lg">Logout</button>
39- // </aside>
40-
41- // {/* Main Section */}
42- // <main className="flex-1 flex p-6 justify-center items-center">
43- // {/* Contact List */}
44- // <section className="w-1/3 bg-white bg-opacity-10 backdrop-blur-md rounded-lg shadow-lg p-4 overflow-y-auto h-[80vh]">
45- // <h2 className="text-lg font-bold mb-4 text-center">Contacts</h2>
46- // <div className="space-y-4">
47- // {contacts.map((contact, index) => (
48- // <button key={index} className="w-full p-3 bg-white bg-opacity-20 hover:bg-opacity-30 rounded-lg text-gray-800">
49- // {contact}
50- // </button>
51- // ))}
52- // </div>
53- // </section>
25+ const [ currentUser , setCurrentUser ] = useState ( '' ) ;
5426
55- // {/* Scrollable Chat Section */}
56- // <section className="flex-1 ml-6 bg-white bg-opacity-10 backdrop-blur-md rounded-lg shadow-lg p-4 h-[80vh]">
57- // <div className="overflow-y-auto h-full">
58- // <p className="text-center text-lg text-gray-600">Scrollbar content</p>
59- // </div>
60- // </section>
61- // </main>
62- // </div>
27+ useEffect ( ( ) => {
28+ const user = auth . currentUser ;
29+ if ( user ) {
30+ setCurrentUser ( user . displayName ) ;
31+ } else {
32+ setCurrentUser ( '' ) ;
33+ }
34+ } , [ ] ) ;
6335
36+ return (
6437 < >
6538 < div className = 'w-full h-full min-h-screen flex flex-col justify-center items-center' >
66- < p > Welcome { auth . currentUser . displayName } </ p >
67- < Button name = "Signout" customClass = 'bg-red-500 hover:bg-red-400 max-w-[350px] w-full mx-[30px]' onCLick = { handleSignout } />
39+ < p > Welcome { currentUser || 'User' } </ p >
40+ < Button
41+ name = "Signout"
42+ customClass = 'bg-red-500 hover:bg-red-400 max-w-[350px] w-full mx-[30px]'
43+ onClick = { handleSignout }
44+ />
6845 </ div >
6946 < ToastContainer />
7047 </ >
0 commit comments