-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathProfileBanner.tsx
126 lines (111 loc) · 3.78 KB
/
ProfileBanner.tsx
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
"use client";
import { useEffect, useState } from "react";
import Image from "next/image";
import { NEARSocialUserProfile } from "@/common/contracts/social";
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/common/ui/components/avatar";
import { Skeleton } from "@/common/ui/components/skeleton";
import useIsHuman from "@/modules/core/hooks/useIsHuman";
import useRegistration from "@/modules/core/hooks/useRegistration";
import { fetchSocialImages } from "@/modules/core/services/socialImages";
import { projectStatusIcons } from "@/modules/project/components/ProjectStatusIcons";
import FollowStats from "./FollowStats";
type Props = {
accountId: string; // near address (donor | proejct)
isProject: boolean;
profile?: NEARSocialUserProfile;
imageStyle?: any;
backgroundStyle?: any;
containerStyle?: any;
};
const ProfileBanner = (props: Props) => {
const { isProject, accountId, profile } = props;
const [profileImages, setProfileImages] = useState({
image: "",
backgroundImage: "",
});
useEffect(() => {
(async () => {
const imagesData = await fetchSocialImages({
socialData: profile,
accountId,
});
setProfileImages({
image: imagesData.image,
backgroundImage: imagesData.backgroundImage,
});
})();
}, [profile, accountId]);
// get nadabot status on the donor page
let nadaBotVerified = false;
const isHuman = useIsHuman(accountId);
if (!isHuman.loading && !isProject) {
nadaBotVerified = isHuman.nadaBotVerified;
}
// get registration if it is on project page
const { registration } = useRegistration(accountId);
return (
<div className="relative">
{/* profile Background */}
<div className="relative h-[318px] w-full">
{profileImages.backgroundImage ? (
<Image
fill
className="object-cover"
alt="background-image"
src={profileImages.backgroundImage}
/>
) : (
<Skeleton className="h-full w-full" />
)}
</div>
{/* profile image */}
<div className="relative z-[6] flex -translate-y-2/4 items-end pl-2 md:pl-16">
{/* image */}
<div className="relative h-[120px] w-[120px] rounded-full bg-white p-1.5">
{profileImages.image ? (
<Avatar className="h-full w-full">
<AvatarImage src={profileImages.image} alt="profile-image" />
<AvatarFallback>PO</AvatarFallback>
</Avatar>
) : (
<Skeleton className="h-full w-full rounded-full" />
)}
</div>
{/* Status */}
<div className="relative z-[1] flex -translate-y-5 translate-x-[-25px] items-center gap-6">
{registration.id ? (
<div className="flex items-center gap-1 overflow-hidden rounded-[20px] bg-white p-[3px] text-[11px] uppercase tracking-[0.88px] opacity-100">
{projectStatusIcons[registration.status].icon}
<div
style={{
color: projectStatusIcons[registration.status].color,
}}
>
{registration.status}
</div>
</div>
) : nadaBotVerified ? (
<div className="flex items-center gap-1 overflow-hidden rounded-[20px] bg-white p-[3px] text-[11px] uppercase tracking-[0.88px] opacity-100">
{projectStatusIcons.Approved.icon}
<div style={{ color: projectStatusIcons.Approved.color }}>
Verified
</div>
</div>
) : (
<div
style={{
width: "10px",
}}
/>
)}
<FollowStats accountId={accountId} />
</div>
</div>
</div>
);
};
export default ProfileBanner;