-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from hackdays-io/issue/190
Issue/190
- Loading branch information
Showing
11 changed files
with
382 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
pkgs/frontend/app/components/splits/SplitRecipientsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Box, Flex, Text } from "@chakra-ui/react"; | ||
import { useNamesByAddresses } from "hooks/useENS"; | ||
import { FC, useMemo } from "react"; | ||
import { UserIcon } from "../icon/UserIcon"; | ||
import { ipfs2https } from "utils/ipfs"; | ||
import { abbreviateAddress } from "utils/wallet"; | ||
|
||
interface SplitRecipientsListProps { | ||
recipients: { address: string; percentAllocation: number }[]; | ||
} | ||
|
||
export const SplitRecipientsList: FC<SplitRecipientsListProps> = ({ | ||
recipients, | ||
}) => { | ||
const addresses = useMemo(() => { | ||
return recipients.map((r) => r.address); | ||
}, [recipients]); | ||
const { names } = useNamesByAddresses(addresses); | ||
|
||
const totalAllocation = useMemo(() => { | ||
return recipients.reduce((acc, r) => acc + r.percentAllocation, 0); | ||
}, [recipients]); | ||
|
||
return ( | ||
<> | ||
{recipients.map((recipient) => { | ||
const name = names.find( | ||
(name) => name[0]?.address === recipient.address | ||
)?.[0]; | ||
return ( | ||
<Flex key={recipient.address} my={2} alignItems="center" gap={2}> | ||
<UserIcon | ||
size="40px" | ||
userImageUrl={ipfs2https(name?.text_records?.avatar)} | ||
/> | ||
<Box flexGrow={1}> | ||
<Text textStyle="sm">{name?.name}</Text> | ||
<Text textStyle="sm"> | ||
{abbreviateAddress(name?.address || "")} | ||
</Text> | ||
</Box> | ||
{( | ||
(Number(recipient.percentAllocation) / totalAllocation) * | ||
100 | ||
).toFixed(2)}{" "} | ||
% | ||
</Flex> | ||
); | ||
})} | ||
</> | ||
); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.