File size: 1,288 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import { Col } from 'react-bootstrap';
import toast from 'react-hot-toast';
import './Profile.css'
import userimg from '../../../Assets/user.svg';
import { handleSignOut } from '../../Login/LoginManager';
import { SET_USER, useAppContext } from '../../../context';
const Profile = () => {
    const { state:{user: { name, email, img }}, dispatch} = useAppContext()
    const signOut = () => {
        const loading = toast.loading('Please wait...');
        handleSignOut()
        .then(res => {
            toast.dismiss(loading);
            dispatch({type: SET_USER, payload: res})
            toast.error('Logged Out!');
        })
    }
    return (
        <Col md={5} className="mx-auto">
            <div className="profile">
                <h2>Profile</h2>
                <div className="profileInfo">
                    <img src={img ? img : userimg} alt="" />
                    <h3>
                        {name}
                    </h3>
                    <h5>
                        {email}
                    </h5>
                    <button className="mainBtn mt-3" 
                    onClick={signOut}
                    >Log out</button>
                </div>
            </div>
        </Col>
    );
};

export default Profile;