-
Notifications
You must be signed in to change notification settings - Fork 438
Expand file tree
/
Copy pathProfileHeroSection.tsx
More file actions
101 lines (95 loc) · 3.43 KB
/
ProfileHeroSection.tsx
File metadata and controls
101 lines (95 loc) · 3.43 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
'use client';
import React, { useState } from 'react';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import { Pencil, Settings, User } from 'lucide-react';
import SheetWrapper from './sheets/SheetWrapper';
import EditProfileForm from './forms/EditProfileForm';
import { SHEETS } from '@/lib/constant/profile.constant';
import AccountSeetingForm from './forms/AccountSeetingForm';
import { useSession } from 'next-auth/react';
import { UserType } from '@/types/user.types';
import ProfileSocials from './ProfileSocials';
import { ProfileShareDialog } from './ProfileShare';
const ProfileHeroSection = ({ userdetails }: { userdetails: UserType }) => {
const [isSheetOpen, setIsSheetOpen] = useState<boolean>(false);
const [isAccountOpen, setIsAccountOpen] = useState<boolean>(false);
const { status, data } = useSession();
const handleClose = () => {
setIsSheetOpen(false);
setIsAccountOpen(false);
};
const handleOpen = () => {
setIsSheetOpen(true);
};
return (
<>
<div className="border rounded-2xl min-h-72 overflow-hidden">
<div className="w-full h-32 bg-gradient-to-r from-blue-500 to-indigo-500"></div>
<div className="p-6 relative flex-col flex gap-y-3">
<Avatar className="h-32 w-32 absolute -top-16 bg-slate-100 dark:bg-slate-900">
{userdetails.avatar && (
<AvatarImage src={userdetails.avatar} alt="@shadcn" />
)}
<AvatarFallback>
<User
width={32}
height={32}
className="dark:text-slate-400 text-slate-500"
/>
</AvatarFallback>
</Avatar>
<div className="w-full flex justify-end gap-2 h-10">
{status === 'authenticated' && data.user.id === userdetails.id && (
<>
<Button
variant={'outline'}
className="px-3 py-2 rounded-xs"
onClick={handleOpen}
>
<Pencil height={16} width={16} />
</Button>
<Button
onClick={() => setIsAccountOpen(true)}
variant={'outline'}
className="px-3 py-2 rounded-xs"
>
<Settings height={16} width={16} />
</Button>
</>
)}
<ProfileShareDialog />
</div>
<div>
<h2 className="text-4xl font-bold">{userdetails.name}</h2>
</div>
<ProfileSocials userdetails={userdetails} />
</div>
</div>
{status === 'authenticated' && data.user.id === userdetails.id && (
<>
<SheetWrapper
isOpen={isSheetOpen}
handleClose={handleClose}
title={SHEETS.editProfile.title}
description={SHEETS.editProfile.description}
>
<EditProfileForm
userdetails={userdetails}
handleClose={handleClose}
/>
</SheetWrapper>
<SheetWrapper
isOpen={isAccountOpen}
handleClose={handleClose}
title={SHEETS.accountSetting.title}
description={SHEETS.accountSetting.description}
>
<AccountSeetingForm handleClose={handleClose} />
</SheetWrapper>
</>
)}
</>
);
};
export default ProfileHeroSection;