@@ -8,26 +8,68 @@ import {
88 CommandItem ,
99 CommandList ,
1010} from "@/components/ui/command" ;
11- import { truncateEthereumAddress } from "@/lib/utils" ;
12- import { UserCircle2 } from "lucide-react" ;
1311import { useState } from "react" ;
1412import { FormattedUnits } from "../formatted-units" ;
1513import { HypercertState } from "@/hypercerts/fragments/hypercert-state.fragment" ;
16-
14+ import { getAddress , isAddress } from "viem" ;
15+ import { useGetUser } from "@/users/hooks" ;
16+ import { Skeleton } from "../ui/skeleton" ;
17+ import { UserIcon } from "../user-icon" ;
18+ import { ImageIcon } from "../user-icon/ImageIcon" ;
19+ import { SvgIcon } from "../user-icon/SvgIcon" ;
20+ import EthAddress from "../eth-address" ;
21+ import { UserName } from "../user-name" ;
1722const MAX_FRACTIONS_DISPLAYED = 5 ;
1823
1924function Fraction ( {
2025 ownerAddress,
26+ totalUnits,
2127 units,
2228} : {
23- ownerAddress : string | null ;
24- units : unknown ;
29+ ownerAddress : string ;
30+ totalUnits : string | null | undefined ;
31+ units : string | null | undefined ;
2532} ) {
33+ const address = isAddress ( ownerAddress . trim ( ) )
34+ ? getAddress ( ownerAddress . trim ( ) )
35+ : undefined ;
36+
37+ const { data : userData , isFetching } = useGetUser ( {
38+ address : address ,
39+ } ) ;
40+
41+ if ( isFetching ) {
42+ return (
43+ < div className = "flex flex-row gap-2 items-center" >
44+ < Skeleton className = "h-8 w-8 rounded-full" />
45+ < Skeleton className = "h-8 w-32" />
46+ </ div >
47+ ) ;
48+ }
2649 return (
27- < div className = "flex flex-col w-full" >
28- { truncateEthereumAddress ( ownerAddress as `0x${string } `) } —{ " " }
29- < FormattedUnits > { units as string } </ FormattedUnits >
30- </ div >
50+ < >
51+ { userData ?. user ? (
52+ < div className = "flex flex-row gap-2" >
53+ { userData ?. user ?. avatar ? (
54+ < ImageIcon url = { userData . user . avatar } size = "tiny" />
55+ ) : (
56+ < SvgIcon size = "tiny" />
57+ ) }
58+ < div className = "flex justify-center items-start" >
59+ < UserName
60+ address = { userData . user . address }
61+ userName = { userData . user . display_name }
62+ />
63+ </ div >
64+ </ div >
65+ ) : (
66+ < div className = "flex flex-row items-center gap-2" >
67+ < UserIcon address = { address } size = "tiny" />
68+ < EthAddress address = { address } showEnsName = { true } />
69+ </ div >
70+ ) }
71+ — < FormattedUnits > { units as string } </ FormattedUnits >
72+ </ >
3173 ) ;
3274}
3375
@@ -77,10 +119,9 @@ export default function Fractions({
77119 key = { fraction . fraction_id }
78120 title = { fraction . owner_address || "" }
79121 >
80- < UserCircle2 className = "mr-2 h-4 w-4" />
81- < span className = "hidden" > { fraction . owner_address } </ span >
82122 < Fraction
83- ownerAddress = { fraction . owner_address }
123+ ownerAddress = { fraction . owner_address as string }
124+ totalUnits = { hypercert . units }
84125 units = { fraction . units }
85126 />
86127 </ CommandItem >
0 commit comments