-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProfile.tsx
More file actions
242 lines (225 loc) · 7.2 KB
/
Profile.tsx
File metadata and controls
242 lines (225 loc) · 7.2 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import { Button, Flex, Text, Tooltip } from '@mantine/core';
import { modals } from '@mantine/modals';
import { notifications } from '@mantine/notifications';
import { useState } from 'react';
import { BiUserVoice } from 'react-icons/bi';
import { BsPersonBadge, BsPersonVideo3 } from 'react-icons/bs';
import { FiUserCheck, FiUserPlus, FiUserX, FiUsers } from 'react-icons/fi';
import { IoImagesOutline } from 'react-icons/io5';
import { MdOutlineAudiotrack } from 'react-icons/md';
import { RiQuillPenLine } from 'react-icons/ri';
import { TbTimelineEventText } from 'react-icons/tb';
import { VscFeedback } from 'react-icons/vsc';
import { useParams } from 'react-router-dom';
import InfoBanner from '../../common/InfoBanner';
import Taps from '../../common/Taps';
import { cover } from '../../constants/default';
import { formateNumber } from '../../helpers/millify';
import useHelmet from '../../hooks/useHelmet';
function Profile() {
useHelmet('profile'); // TODO: improve SEO
const { profileId = '' } = useParams();
const isFriend = false; // TODO: find suitable algorithm
const isFollow = false; // TODO: find suitable algorithm
const [isLoading, setIsLoading] = useState({
friend: false,
follow: false,
});
const onAddFriendBtnClick = () => {
setIsLoading((prev) => ({ ...prev, friend: true }));
setTimeout(() => {
setIsLoading((prev) => ({ ...prev, friend: false }));
notifications.show({
title: 'Successfully Friend request send',
message: 'Hey there, an request had been send to mohammed!',
loading: false,
withCloseButton: true,
autoClose: true,
});
}, 2000);
};
const onFollowBtnClick = () => {
setIsLoading((prev) => ({ ...prev, follow: true }));
setTimeout(() => {
setIsLoading((prev) => ({ ...prev, follow: false }));
notifications.show({
title: 'Successfully follow',
message: 'Hey there, Successfully follow mohammed!',
loading: false,
withCloseButton: true,
autoClose: true,
});
}, 2000);
};
const onUnFollowBtnClick = () => {
setIsLoading((prev) => ({ ...prev, follow: true }));
setTimeout(() => {
setIsLoading((prev) => ({ ...prev, follow: false }));
notifications.show({
title: 'Successfully un follow',
message: 'Hey there, Successfully un follow mohammed!',
loading: false,
withCloseButton: true,
autoClose: true,
});
}, 2000);
};
const onUnfriendBtnClick = () => {
modals.openConfirmModal({
title: 'Please confirm your action',
children: (
<Text size='sm'>
This action is so important that you are required to confirm it. Are
you sure to unfriend <strong>Aurora Light</strong>
</Text>
),
labels: { confirm: 'Yes, Leave', cancel: 'Cancel' },
onConfirm: onUnfriendConfirmBtnClick,
});
};
const onUnfriendConfirmBtnClick = () => {
setIsLoading((prev) => ({ ...prev, friend: true }));
setTimeout(() => {
setIsLoading((prev) => ({ ...prev, friend: false }));
notifications.show({
title: 'Successfully unfriend',
message: 'Hey there, you successfully unfriend mohammed',
loading: false,
withCloseButton: true,
autoClose: true,
});
}, 2000);
};
const TAPS = [
{
label: 'Timeline',
path: `/profile/${profileId}`,
icon: TbTimelineEventText,
},
{
label: 'About',
path: `/profile/${profileId}/about`,
icon: RiQuillPenLine,
},
{
label: 'Friends',
path: `/profile/${profileId}/friends`,
icon: FiUsers,
},
{
label: 'Photos',
path: `/profile/${profileId}/photos`,
icon: IoImagesOutline,
},
{
label: 'Audio',
path: `/profile/${profileId}/audio`,
icon: MdOutlineAudiotrack,
},
{
label: 'Videos',
path: `/profile/${profileId}/videos`,
icon: BsPersonVideo3,
},
{
label: 'Badges',
path: `/profile/${profileId}/badges`,
icon: BsPersonBadge,
},
];
return (
<div className='profile-page'>
<InfoBanner
avatar={
'https://www.radiustheme.com/demo/wordpress/themes/cirkle/wp-content/uploads/avatars/1/60af1abf04a6b-bpthumb.jpg'
}
cover={cover}
username='aurora-light'
name='Aurora Light'
verified
extraInfo={
<Flex
justify='space-between'
wrap='wrap'
rowGap={2}
direction={{ sm: 'row', base: 'column' }}
>
<div className='flex items-center justify-center md:justify-start gap-4'>
<Tooltip label='Friends' withArrow>
<div className='flex items-center gap-1'>
<FiUsers />
<span className='text-sm'>{formateNumber(1412)}</span>
</div>
</Tooltip>
<Tooltip label='Posts' withArrow>
<div className='flex items-center gap-1'>
<VscFeedback />
<span className='text-sm'>{formateNumber(124411)}</span>
</div>
</Tooltip>
<Tooltip label='Followers' withArrow>
<div className='flex items-center gap-1'>
<BiUserVoice />
<span className='text-sm'>{formateNumber(30302202)}</span>
</div>
</Tooltip>
<Tooltip label='Following' withArrow>
<div className='flex items-center gap-1'>
<FiUserPlus />
<span className='text-sm'>{formateNumber(10243)}</span>
</div>
</Tooltip>
</div>
<Flex
gap={10}
className='mt-4 md:mt-0 justify-center md:justify-start'
>
{isFriend ? (
<Button
size='xs'
loading={isLoading.friend}
onClick={onAddFriendBtnClick}
leftIcon={<FiUserPlus className='text-lg' />}
>
Add Friend
</Button>
) : (
<Button
variant='default'
size='xs'
loading={isLoading.friend}
onClick={onUnfriendBtnClick}
leftIcon={<FiUserX className='text-lg' />}
>
Unfriend
</Button>
)}
{isFollow ? (
<Button
size='xs'
loading={isLoading.follow}
onClick={onFollowBtnClick}
leftIcon={<FiUserCheck className='text-lg' />}
>
Follow
</Button>
) : (
<Button
size='xs'
variant='default'
loading={isLoading.follow}
onClick={onUnFollowBtnClick}
leftIcon={<FiUserX className='text-lg' />}
>
Un follow
</Button>
)}
</Flex>
</Flex>
}
/>
<Taps taps={TAPS} />
</div>
);
}
export default Profile;