Skip to content

Commit d0ef45e

Browse files
committed
feat(hypercerts): update contributor view
changes: - display hypercerts.org specific username and image if it exists - display ENS username and image if it exists and no hypercerts.org specific username and image is set - otherwise show address like it is currently
1 parent c67223e commit d0ef45e

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

components/hypercert/contributors.tsx

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,59 @@ import {
1111
} from "@/components/ui/command";
1212
import { UserCircle2 } from "lucide-react";
1313
import { useState } from "react";
14-
import { isAddress } from "viem";
14+
import { getAddress, isAddress } from "viem";
1515
import { HypercertState } from "@/hypercerts/fragments/hypercert-state.fragment";
16+
import { useGetUser } from "@/users/hooks";
17+
import { UserIcon } from "../user-icon";
18+
import EnsName from "../ens-name";
19+
import { ImageIcon } from "../user-icon/ImageIcon";
20+
import { SvgIcon } from "../user-icon/SvgIcon";
21+
import { Skeleton } from "../ui/skeleton";
1622
const MAX_CONTRIBUTORS_DISPLAYED = 10;
1723

1824
function Contributor({ contributor }: { contributor: string }) {
19-
return isAddress(contributor) ? (
20-
<EthAddress address={contributor} />
25+
const address = isAddress(contributor.trim())
26+
? getAddress(contributor.trim())
27+
: undefined;
28+
29+
const { data: userData, isFetching } = useGetUser({
30+
address: address,
31+
});
32+
33+
if (isFetching) {
34+
return (
35+
<div className="flex flex-row gap-2 items-center">
36+
<Skeleton className="h-8 w-8 rounded-full" />
37+
<Skeleton className="h-8 w-32" />
38+
</div>
39+
);
40+
}
41+
42+
return userData?.user ? (
43+
<div className="flex gap-2">
44+
{userData.user.avatar ? (
45+
<ImageIcon url={userData.user.avatar} size="tiny" />
46+
) : (
47+
<SvgIcon size="tiny" />
48+
)}
49+
<div className="flex flex-col justify-center items-start">
50+
<p>{userData.user.display_name}</p>
51+
<EthAddress address={userData.user.address} />
52+
</div>
53+
</div>
54+
) : address ? (
55+
<div className="flex gap-2">
56+
<UserIcon address={address} size="tiny" />
57+
<div className="flex flex-col justify-center items-start">
58+
<EnsName address={address} />
59+
<EthAddress address={address} />
60+
</div>
61+
</div>
2162
) : (
22-
<div>{contributor}</div>
63+
<div className="flex items-center flex-row">
64+
<UserCircle2 className="mr-2 h-4 w-4" />
65+
{contributor}
66+
</div>
2367
);
2468
}
2569

@@ -58,7 +102,6 @@ export default function Contributors({
58102
<CommandGroup>
59103
{hypercert.metadata?.contributors.map((contributor) => (
60104
<CommandItem key={contributor}>
61-
<UserCircle2 className="mr-2 h-4 w-4" />
62105
<Contributor contributor={contributor} />
63106
</CommandItem>
64107
))}

0 commit comments

Comments
 (0)