-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass of claim all modal (#8072)
- Loading branch information
Showing
7 changed files
with
213 additions
and
19 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
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
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
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
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
93 changes: 93 additions & 0 deletions
93
...pages/audio-rewards-page/components/modals/ChallengeRewardsModal/ClaimAllRewardsModal.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,93 @@ | ||
import { | ||
formatAudioMatchingChallengesForCooldownSchedule, | ||
usePendingChallengeSchedule | ||
} from '@audius/common/hooks' | ||
import { challengesSelectors } from '@audius/common/store' | ||
import { formatNumberCommas } from '@audius/common/utils' | ||
import { Button, Flex, ModalContent, Text } from '@audius/harmony' | ||
import { useSelector } from 'react-redux' | ||
|
||
import { useModalState } from 'common/hooks/useModalState' | ||
import { SummaryTable } from 'components/summary-table' | ||
import { useWithMobileStyle } from 'hooks/useWithMobileStyle' | ||
|
||
import ModalDrawer from '../ModalDrawer' | ||
|
||
import styles from './styles.module.css' | ||
|
||
const { getOptimisticUserChallenges } = challengesSelectors | ||
|
||
const messages = { | ||
upcomingRewards: 'Upcoming Rewards', | ||
claimAudio: (amount: string) => `Claim ${amount} $AUDIO`, | ||
readyToClaim: 'Ready to Claim', | ||
rewards: 'Rewards', | ||
audio: '$AUDIO', | ||
description: 'You can check and claim all your upcoming rewards here.', | ||
done: 'Done' | ||
} | ||
|
||
export const ClaimAllRewardsModal = () => { | ||
const [isOpen, setOpen] = useModalState('ClaimAllRewards') | ||
const [isHCaptchaModalOpen] = useModalState('HCaptcha') | ||
const wm = useWithMobileStyle(styles.mobile) | ||
const userChallenges = useSelector(getOptimisticUserChallenges) | ||
|
||
const undisbursedChallenges = usePendingChallengeSchedule().cooldownChallenges | ||
// TODO merge conflicting dates | ||
const totalClaimableAmount = Object.values(userChallenges).reduce( | ||
(sum, challenge) => sum + challenge.claimableAmount, | ||
0 | ||
) | ||
const claimInProgress = false | ||
const onClaimRewardClicked = () => {} | ||
return ( | ||
<ModalDrawer | ||
title={messages.rewards} | ||
showTitleHeader | ||
isOpen={isOpen} | ||
onClose={() => setOpen(false)} | ||
isFullscreen={true} | ||
useGradientTitle={false} | ||
titleClassName={wm(styles.title)} | ||
headerContainerClassName={styles.header} | ||
showDismissButton={!isHCaptchaModalOpen} | ||
dismissOnClickOutside={!isHCaptchaModalOpen} | ||
> | ||
<ModalContent> | ||
<Flex direction='column' gap='2xl' mt='s'> | ||
<Text variant='body' textAlign='left'> | ||
{messages.description} | ||
</Text> | ||
<SummaryTable | ||
title={messages.upcomingRewards} | ||
items={formatAudioMatchingChallengesForCooldownSchedule( | ||
undisbursedChallenges | ||
)} | ||
summaryItem={{ | ||
id: messages.readyToClaim, | ||
label: messages.readyToClaim, | ||
value: totalClaimableAmount | ||
}} | ||
secondaryTitle={messages.audio} | ||
summaryLabelColor='accent' | ||
summaryValueColor='default' | ||
/> | ||
{totalClaimableAmount > 0 ? ( | ||
<Button | ||
fullWidth | ||
isLoading={claimInProgress} | ||
onClick={onClaimRewardClicked} | ||
> | ||
{messages.claimAudio(formatNumberCommas(totalClaimableAmount))} | ||
</Button> | ||
) : ( | ||
<Button variant='secondary' fullWidth> | ||
{messages.done} | ||
</Button> | ||
)} | ||
</Flex> | ||
</ModalContent> | ||
</ModalDrawer> | ||
) | ||
} |
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