Skip to content

Commit

Permalink
tech(quest-detail): make claimed toast observer
Browse files Browse the repository at this point in the history
  • Loading branch information
eliobricenov committed Nov 8, 2024
1 parent 47f9871 commit 8677e94
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions src/frontend/components/UI/QuestRewardClaimedToast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ import { ToastQuest } from '@hyperplay/ui'
import Draggable from 'react-draggable'
import { useTranslation } from 'react-i18next'
import claimedRewardToastState from 'frontend/state/ClaimedRewardToastState'
import { observer } from 'mobx-react-lite'

type QuestRewardClaimedToastProps = {
draggable?: boolean
className?: string
}

export function QuestRewardClaimedToast({
draggable = true,
className
}: QuestRewardClaimedToastProps) {
const { t } = useTranslation()
export const QuestRewardClaimedToast = observer(
({ draggable = true, className }: QuestRewardClaimedToastProps) => {
const { t } = useTranslation()

if (!claimedRewardToastState.claimedReward) {
return null
}
if (!claimedRewardToastState.claimedReward) {
return null
}

const toast = (
<div className={className}>
<ToastQuest
i18n={{
overlayToggleKey: 'X',
overlayToggleModKey: 'option',
plus: '+',
questAvailable: t('quest.questAvailable', 'Quest available!'),
questComplete: t('quest.questComplete', 'Quest complete!'),
rewardClaimed: t('quest.rewardClaimed', 'Claim successful'),
toClaimReward: t('quest.toClaimReward', 'to claim your reward.'),
toSeeDetails: t('quest.toSeeDetails', 'to see details.'),
youHaveClaimed: t(
'quest.youHaveClaimed',
'You have claimed {{totalRewards}} reward{{plural}}.',
{
totalRewards: 1,
plural: ' '
}
)
}}
onCloseClick={() => claimedRewardToastState.clearReward()}
status="claimed"
/>
</div>
)
const toast = (
<div className={className}>
<ToastQuest
i18n={{
overlayToggleKey: 'X',
overlayToggleModKey: 'option',
plus: '+',
questAvailable: t('quest.questAvailable', 'Quest available!'),
questComplete: t('quest.questComplete', 'Quest complete!'),
rewardClaimed: t('quest.rewardClaimed', 'Claim successful'),
toClaimReward: t('quest.toClaimReward', 'to claim your reward.'),
toSeeDetails: t('quest.toSeeDetails', 'to see details.'),
youHaveClaimed: t(
'quest.youHaveClaimed',
'You have claimed {{totalRewards}} reward{{plural}}.',
{
totalRewards: 1,
plural: ''
}
)
}}
onCloseClick={() => claimedRewardToastState.clearReward()}
status="claimed"
/>
</div>
)

return draggable ? <Draggable>{toast}</Draggable> : toast
}
return draggable ? <Draggable>{toast}</Draggable> : toast
}
)

0 comments on commit 8677e94

Please sign in to comment.