-
Notifications
You must be signed in to change notification settings - Fork 103
Midnight redeem functions #4423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4b3c142
add function to check if there are collaterals
yushih eb57a64
be able to submit collateral tx
yushih 5a81552
wip
yushih 62a4b10
wip
yushih 70e8c0c
wip
yushih d10dc3c
wip
yushih fc5778a
wip
yushih facefe9
fix
yushih a4411e2
Merge remote-tracking branch 'origin/develop' into feat/YOEXT-2355/mi…
yushih 3f4e053
wip
yushih 6ee4f11
no redemption page
yushih 7b7a5aa
wip
yushih 68e2237
bug fix
yushih 2e84c86
wip
yushih ed169e3
fix types
yushih fe9ec9d
address detail page skeleton
yushih c618102
add vertical seperator
yushih 5cc1b24
fix address card click handling
yushih a19f052
feat: redeem status card
banklesss 716c1de
wip
yushih 1cd6d5b
strong text
yushih 4921727
feat: airdrop details
banklesss ec8657a
feat: airdrop details
banklesss 46923f2
feat: airdrop details
banklesss 28ab9d3
bug fixes
yushih f18573a
format code
yushih 6e6f2a7
Merge branch 'develop' into feat/YOEXT-2355/midnight-redeem-1
Nebyt c3375da
remove explorer links
Nebyt d67ea53
use strings
Nebyt 409a2fa
use correct colors
Nebyt ea559af
use illustration static
Nebyt 8861f74
add type for colors
Nebyt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
152 changes: 152 additions & 0 deletions
152
packages/yoroi-extension/app/UI/features/airdrop/useCases/AddressCard.tsx
This file contains hidden or 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,152 @@ | ||
| import { Box, Typography } from '@mui/material'; | ||
| import { useIntl, defineMessages } from 'react-intl'; | ||
| import { type Status } from '../../../../api/ada/midnightRedemption'; | ||
| import CopyableText from '../../../components/CopyableText'; | ||
| import { IconWrapper, Icons } from '../../../components'; | ||
|
|
||
| const messages = defineMessages({ | ||
| dstAddrs: { | ||
| id: 'airdrop.addrCard.destAddrs', | ||
| defaultMessage: '!!!Destination addresses ({count})', | ||
| }, | ||
| dstAddr: { | ||
| id: 'aidrop.addrCard.destAddr', | ||
| defaultMessage: '!!!Destination address {index}', | ||
| }, | ||
| dstAddrLabel: { | ||
| id: 'airdrop.addrCard.destAddrLabel', | ||
| defaultMessage: '!!!Destination address', | ||
| }, | ||
| status: { | ||
| id: 'aidrop.addrCard.statusLabel', | ||
| defaultMessage: '!!!Status', | ||
| }, | ||
| redeemable: { | ||
| id: 'airdrop.addrCard.redeemableLabel', | ||
| defaultMessage: '!!!Redeemable', | ||
| }, | ||
| total: { | ||
| id: 'airdrop.addrCard.totalLable', | ||
| defaultMessage: '!!!Total', | ||
| }, | ||
| statusReady: { | ||
| id: 'airdrop.addrCard.statusReady', | ||
| defaultMessage: '!!!Ready for redemption', | ||
| }, | ||
| statusNotReady: { | ||
| id: 'airdrop.addrCard.statusNotReady', | ||
| defaultMessage: '!!!Waiting for thawing', | ||
| }, | ||
| }); | ||
|
|
||
| export function AddressesTitle({ count }: { count: number }) { | ||
| const intl = useIntl(); | ||
| return ( | ||
| /* @ts-ignore */ | ||
| <Typography variant="heading-4-regular" sx={{ fontWeight: 500, fontSize: '20px', lineHeight: '28px' }} as="div"> | ||
| {intl.formatMessage(messages.dstAddrs, { count })} | ||
| </Typography> | ||
| ); | ||
| } | ||
|
|
||
| interface Props { | ||
| index: number; | ||
| address: string; | ||
| status: Status; | ||
| redeemable: string; | ||
| total: string; | ||
| isSelected: boolean; | ||
| onSelect: () => void; | ||
| } | ||
|
|
||
| export function AddressCard({ index, address, status, redeemable, total, isSelected, onSelect }: Props) { | ||
| const intl = useIntl(); | ||
| const statusString = intl.formatMessage({ | ||
| ready: messages.statusReady, | ||
| notReady: messages.statusNotReady, | ||
| }[status]); | ||
|
|
||
| const selectedBackground = isSelected ? { 'background': 'linear-gradient(180deg, #93F5E1 0%, #C6F7ED 100%)' } : {}; | ||
| return ( | ||
| <Box | ||
| sx={{ | ||
| width: '315px', | ||
| borderRadius: '8px', | ||
| padding: '16px', | ||
| border: '1px solid var(--grayscale-200, #DCE0E9)', | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| gap: '16px', | ||
| ...selectedBackground, | ||
| cursor: 'pointer', | ||
| }} | ||
| onClick={(event) => { | ||
| //hack: detect that the copy address icon is clicked | ||
| if ((event.target as HTMLElement).tagName === 'svg') { | ||
| return; | ||
| } | ||
| onSelect(); | ||
| }} | ||
| > | ||
| <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> | ||
| {/* @ts-ignore */} | ||
| <Typography variant="body1"> | ||
| {intl.formatMessage(messages.dstAddr, { index })} | ||
| </Typography> | ||
| <IconWrapper icon={Icons.ChevronRight} /> | ||
| </Box> | ||
|
|
||
| <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> | ||
| <Typography variant="body2" color="var(--text-gray-low, #6B7384)"> | ||
| {intl.formatMessage(messages.dstAddrLabel)} | ||
| </Typography> | ||
| {/* @ts-ignore */} | ||
| <CopyableText value={address} copyButtonFollowText> | ||
| <Typography variant="body2"> | ||
| {shortenAddress(address)} | ||
| </Typography> | ||
| </CopyableText> | ||
| </Box> | ||
|
|
||
| <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> | ||
| {/* @ts-ignore */} | ||
| <Typography variant="body2" color="var(--text-gray-low, #6B7384)"> | ||
| {intl.formatMessage(messages.status)} | ||
| </Typography> | ||
|
|
||
| {/* @ts-ignore */} | ||
| <Typography variant="body2"> | ||
| {statusString} | ||
| </Typography> | ||
| </Box> | ||
|
|
||
| <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> | ||
| {/* @ts-ignore */} | ||
| <Typography variant="body2" color="var(--text-gray-low, #6B7384)"> | ||
| {intl.formatMessage(messages.redeemable)} | ||
| </Typography> | ||
|
|
||
| {/* @ts-ignore */} | ||
| <Typography variant="body2"> | ||
| {redeemable} NIGHT | ||
| </Typography> | ||
| </Box> | ||
|
|
||
| <Box sx={{ display: 'flex', justifyContent: 'space-between' }}> | ||
| {/* @ts-ignore */} | ||
| <Typography variant="body2" color="var(--text-gray-low, #6B7384)"> | ||
| {intl.formatMessage(messages.total)} | ||
| </Typography> | ||
|
|
||
| {/* @ts-ignore */} | ||
| <Typography variant="body2"> | ||
| {total} NIGHT | ||
| </Typography> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| function shortenAddress(address: string): string { | ||
| return `${address.slice(0, 8)}...${address.slice(-4)}`; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: SVG click detection only catches parent element clicks
The click handler checks if
event.target.tagName === 'svg'to detect clicks on the copy icon, but this only works when clicking directly on the SVG element itself. Clicking on child elements inside the SVG (likepath,rect, orcircleelements) will have a differenttagName, causing the check to fail andonSelect()to be called unintentionally when users click on parts of the copy icon.