-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathuseprofile.js
110 lines (102 loc) · 3.11 KB
/
useprofile.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* eslint-disable react/button-has-type */
/* eslint-disable jsx-a11y/anchor-is-valid */
/* eslint-disable max-len */
/* eslint-disable import/order */
/* eslint-disable jsx-a11y/alt-text */
/* eslint-disable react/self-closing-comp */
/* eslint-disable no-unused-vars */
import React, { useEffect, useState } from 'react';
import { useQuery, useMutation } from '@apollo/client';
import GET_USER from '../../../graphql/queries/GET_USER';
import Logout from './Logout';
import { SectionLayout } from '../../marginals';
import { Container } from 'react-bootstrap';
import LOGOUT from '../../../graphql/mutation/LOGOUT';
import { useHistory } from 'react-router';
import {
HeadingContainer,
Heading,
Card,
Title,
ButtonLogout,
P,
H1,
H4,
CTXH4,
ProfileGridContainer,
ProfileImageContainer,
ProfileImageCircle,
ProfileCTXText,
ProfileCtxBadge,
ProfileCtxUser,
ProfileDetailsWrapper,
ProfileDetails,
ProfileGridInnerContainer,
} from './styles';
import { FormInputBtn } from '../styles';
function Profile() {
const { data } = useQuery(GET_USER);
const [logout, { data1, error }] = useMutation(LOGOUT);
const [user, setUser] = useState('');
const history = useHistory();
useEffect(() => {
if (data) {
setUser(data.getCurrentUser);
}
}, [setUser, data]);
const handlelogout = async (event) => {
logout({});
history.push('/signup');
};
return (
<SectionLayout>
<Container>
<HeadingContainer>
<Heading style={{ textAlign: 'center' }}>User Profile</Heading>
</HeadingContainer>
<ProfileGridContainer>
<Card>
<ProfileImageContainer>
<ProfileImageCircle></ProfileImageCircle>
</ProfileImageContainer>
<ProfileCTXText>
<ProfileCtxUser>
<CTXH4>Mary Jane (spidergirl)</CTXH4>
</ProfileCtxUser>
<ProfileCtxBadge>
<span>New Member</span>
</ProfileCtxBadge>
</ProfileCTXText>
{/* Additional Information About This User */}
<ProfileDetailsWrapper>
<ProfileDetails>
<P>Username</P>
<H4>{user.username} JaneMar23 </H4>
</ProfileDetails>
<ProfileDetails>
<P>Role</P>
<H4>{user.role} Front-End Engineer </H4>
</ProfileDetails>
<ProfileDetails>
<P>Email</P>
<H4>{user.email} [email protected]</H4>
</ProfileDetails>
<ProfileDetails>
<P>Gender</P>
<H4>Female</H4>
</ProfileDetails>
<ProfileDetails>
<P>About</P>
<H4>Swimming, Dancing and Coding </H4>
</ProfileDetails>
{/* LogOut Button */}
<FormInputBtn onClick={handlelogout}>Logout</FormInputBtn>
</ProfileDetailsWrapper>
{/* Additional information section Ends here */}
</Card>
</ProfileGridContainer>
</Container>
</SectionLayout>
);
}
export default Profile;