State.init({ copiedShareUrl: false, hasBeenFlagged: false, }); const accountId = props.accountId || "hack.near"; // todo remove const profile = props.profile || Social.get(`${accountId}/profile/**`, "final") || {}; const profileUrl = `/vfdao.near/widget/ProfilePage?accountId=${accountId}`; if (!accountId) { return ""; } const { Button } = VM.require("old.potlock.near/widget/Components.ui.Button"); const { Volunteer } = VM.require("old.potlock.near/widget/Components.Icons"); // Profile Data: const tags = Object.keys(profile.tags || {}); const viewingOwnAccount = accountId === context.accountId; const accountUrl = `/vfdao.near/widget/ProfilePage?accountId=${accountId}`; const shareUrl = `https://app.vfdao.org${accountUrl}`; // Follower Count: const following = Social.keys(`${accountId}/graph/follow/*`, "final", { return_type: "BlockHeight", values_only: true, }); const followers = Social.keys(`*/graph/follow/${accountId}`, "final", { return_type: "BlockHeight", values_only: true, }); const followingCount = following ? Object.keys(following[accountId].graph.follow || {}).length : null; const followersCount = followers ? Object.keys(followers || {}).length : null; // Account follows you: const accountFollowsYouData = Social.keys( `${accountId}/graph/follow/${context.accountId}`, undefined, { values_only: true, } ); const accountFollowsYou = Object.keys(accountFollowsYouData || {}).length > 0; const contentModerationItem = { type: "social", path: profileUrl, reportedBy: context.accountId, }; const optimisticallyHideItem = (message) => { State.update({ hasBeenFlaggedOptimistic: true, showToast: true, flaggedMessage: message, }); }; const resolveHideItem = (message) => { State.update({ hasBeenFlagged: true, showToast: true, flaggedMessage: message, }); }; const cancelHideItem = () => { State.update({ hasBeenFlaggedOptimistic: false, showToast: false, flaggedMessage: { header: "", detail: "" }, }); }; const [isDonationModalOpen, setDonationModalOpen] = useState(false); const Wrapper = styled.div` display: grid; gap: 34px; position: relative; .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; height: 32px; border-radius: 100px; font-weight: 600; font-size: 14px; line-height: 15px; text-align: center; cursor: pointer; background: white; border: 1px solid #232528; color: #232528 !important; &.button--primary { width: 100%; background: #232528; color: white !important; i { color: white; } .bi-16 { font-size: 16px; } &:hover, &:focus { background: black; text-decoration: none; outline: none; } @media (max-width: 1024px) { width: auto; } } &:hover, &:focus { background: white; text-decoration: none; outline: none; } i { color: #232528; } .bi-16 { font-size: 16px; } } @media (max-width: 900px) { gap: 24px; } `; const Section = styled.div` display: grid; gap: 12px; font-family: sans-serif light `; const Avatar = styled.div` width: 133px; height: 133px; flex-shrink: 0; border: 3px solid #fff; overflow: hidden; border-radius: 100%; box-shadow: 0px 12px 16px rgba(16, 24, 40, 0.08), 0px 4px 6px rgba(16, 24, 40, 0.03); img { object-fit: cover; width: 100%; height: 100%; } @media (max-width: 900px) { width: 80px; height: 80px; } `; const Title = styled.h1` font-weight: 600; font-size: ${(p) => p.size || "25px"}; line-height: 1.2em; color: #11181c; margin: ${(p) => (p.margin ? "0 0 24px" : "0")}; overflow-wrap: anywhere; font-family: sans-serif light `; const Text = styled.p` margin: 0; line-height: 1.5rem; color: ${(p) => (p.bold ? "#11181C" : "#687076")} !important; font-weight: ${(p) => (p.bold ? "600" : "400")}; font-size: ${(p) => (p.small ? "12px" : "14px")}; overflow: ${(p) => (p.ellipsis ? "hidden" : "")}; text-overflow: ${(p) => (p.ellipsis ? "ellipsis" : "")}; white-space: ${(p) => (p.ellipsis ? "nowrap" : "")}; overflow-wrap: anywhere; b { font-weight: 600; color: #11181c; } &[href] { display: inline-flex; gap: 0.25rem; &:hover, &:focus { text-decoration: underline; } } `; const TextLink = styled("Link")` display: block; margin: 0; font-size: 14px; line-height: 20px; color: #11181c !important; font-weight: 400; font-size: 14px; white-space: nowrap; outline: none; overflow-x: hidden; text-overflow: ellipsis; font-family: sans-serif light &:focus, &:hover { text-decoration: underline; } i { color: #7e868c; margin-right: 8px; } `; const TextBadge = styled.p` display: inline-block; margin: 0; font-size: 10px; line-height: 1.1rem; background: #687076; color: #fff; font-weight: 600; white-space: nowrap; padding: 0 6px; border-radius: 3px; font-family: sans-serif light `; const Actions = styled.div` display: flex; gap: 6px; `; const Stats = styled.div` display: flex; gap: 24px; `; const SocialLinks = styled.div` display: grid; gap: 9px; `; const FollowButtonWrapper = styled.div` flex: 1 0 auto; div, button { width: 100%; } @media (max-width: 1024px) { flex: 0 0 auto; div, button { width: auto; } } `; const Verifications = styled.div` padding: 0; `; return ( <Wrapper> <Avatar> <Widget src="mob.near/widget/Image" props={{ image: profile.image, alt: profile.name, fallbackUrl: "https://ipfs.near.social/ipfs/bafkreibiyqabm3kl24gcb2oegb7pmwdi6wwrpui62iwb44l7uomnn3lhbi", }} /> </Avatar> <Section> <div className="d-flex align-items-start justify-content-between position-relative"> <div className="position-absolute top-0 end-0 m-4"> <Button onClick={(e) => { setDonationModalOpen(!isDonationModalOpen); }} variant="primary" > <Volunteer /> Donate </Button> </div> <div> <Title>{profile.name || accountId}</Title> <div className="small text-truncate"> <i className="bi bi-person-fill text-secondary"></i> {accountId} <Widget src="mob.near/widget/CopyButton" props={{ text: accountId, className: "btn btn-sm btn-outline-dark border-0", }} /> </div> {accountFollowsYou && <TextBadge>Follows You</TextBadge>} </div> {accountId !== context.accountId && ( <> {state.showToast && ( <Widget src={`near/widget/DIG.Toast`} props={{ type: "info", title: state.flaggedMessage.header, description: state.flaggedMessage.detail, open: state.showToast, onOpenChange: () => { State.update({ showToast: false }); }, duration: 5000, }} /> )} <Widget src="near/widget/Posts.Menu" props={{ accountId: accountId, parentFunctions: { optimisticallyHideItem, resolveHideItem, cancelHideItem, }, }} /> </> )} </div> {profile.description && ( <div> <Widget src="near/widget/SocialMarkdown" props={{ text: profile.description }} /> </div> )} <Actions> {viewingOwnAccount ? ( <Link className="button button--primary" href="/vfdao.near/widget/ProfileEditor" > <i className="bi bi-pencil"></i> Edit Profile </Link> ) : context.accountId ? ( <> <FollowButtonWrapper> <Widget src="vfdao.near/widget/FollowButton" props={{ accountId, }} /> </FollowButtonWrapper> <Widget src="vfdao.near/widget/PokeButton" props={{ accountId, }} /> </> ) : ( <></> )} <OverlayTrigger placement="top" overlay={<Tooltip>Copy URL to clipboard</Tooltip>} > <button className="button" type="button" onMouseLeave={() => { State.update({ copiedShareUrl: false }); }} onClick={() => { clipboard.writeText(shareUrl).then(() => { State.update({ copiedShareUrl: true }); }); }} > {state.copiedShareUrl ? ( <i className="bi-16 bi bi-check"></i> ) : ( <i className="bi-16 bi-link-45deg"></i> )} Share </button> </OverlayTrigger> </Actions> </Section> <Section> <Stats> <TextLink href={`${accountUrl}&tab=following`}> <b bold as="span"> {followingCount === null ? "--" : followingCount} </b>{" "} Following </TextLink> <TextLink href={`${accountUrl}&tab=followers`}> <b>{followersCount === null ? "--" : followersCount}</b> Followers </TextLink> </Stats> </Section> {tags.length > 0 && ( <Section> <Widget src="near/widget/Tags" props={{ tags, }} /> </Section> )} {profile.linktree && ( <Section> <SocialLinks> <Widget src="vfdao.near/widget/LinkTree" props={{ linktree: profile.linktree }} /> </SocialLinks> </Section> )} {isDonationModalOpen && ( <Widget src={"old.potlock.near/widget/ModalDonation.Main"} props={{ projectId: accountId, isModalOpen: isDonationModalOpen, onClose: () => setDonationModalOpen(false), openDonationModalSuccess: () => setDonationModalOpen(false), }} /> )} </Wrapper> );