-
Notifications
You must be signed in to change notification settings - Fork 97
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 #5392 from LiskHQ/5377-staking-visual-interaction-…
…bugs Fixed claim rewards visual bugs
- Loading branch information
Showing
8 changed files
with
139 additions
and
73 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
39 changes: 39 additions & 0 deletions
39
src/modules/common/components/notification/rewardsNotification/index.js
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,39 @@ | ||
import React, { useEffect, useContext } from 'react'; | ||
import { toast } from 'react-toastify'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ApplicationBootstrapContext } from '@setup/react/app/ApplicationBootstrap'; | ||
import DialogLink from '@theme/dialog/link'; | ||
import styles from './styles.css'; | ||
|
||
const RewardsNotification = () => { | ||
const { t } = useTranslation(); | ||
const { | ||
appEvents: { | ||
transactions: { rewards }, | ||
}, | ||
} = useContext(ApplicationBootstrapContext); | ||
const notification = rewards.length && BigInt(rewards[0]?.reward || 0) > BigInt(0); | ||
|
||
useEffect(() => { | ||
if (notification) { | ||
toast.info( | ||
<div className={styles.rewardInfo}> | ||
<p>{t('You have an unclaimed reward for your stakes.')}</p> | ||
<DialogLink component="claimRewardsView" className={styles.rewardLink}> | ||
{t('Claim rewards')} | ||
</DialogLink> | ||
</div>, | ||
{ | ||
autoClose: false, | ||
draggable: false, | ||
closeButton: <span className={`${styles.closeBtn} dialog-close-button`} />, | ||
toastId: 'claimRewards', | ||
} | ||
); | ||
} | ||
}, [rewards]); | ||
|
||
return null; | ||
}; | ||
|
||
export default RewardsNotification; |
42 changes: 42 additions & 0 deletions
42
src/modules/common/components/notification/rewardsNotification/index.test.js
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,42 @@ | ||
import React from 'react'; | ||
import { screen, waitFor } from '@testing-library/react'; | ||
import { ToastContainer } from 'react-toastify'; | ||
import { ApplicationBootstrapContext } from '@setup/react/app/ApplicationBootstrap'; | ||
import { smartRender } from 'src/utils/testHelpers'; | ||
import RewardsNotification from '.'; | ||
|
||
describe('RewardsNotification', () => { | ||
it('renders properly', async () => { | ||
const Component = (props) => ( | ||
<ApplicationBootstrapContext.Provider | ||
value={{ appEvents: { transactions: { rewards: [{ reward: 10000 }] } } }} | ||
> | ||
<ToastContainer /> | ||
<RewardsNotification {...props} /> | ||
</ApplicationBootstrapContext.Provider> | ||
); | ||
smartRender(Component); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('You have an unclaimed reward for your stakes.')).toBeVisible(); | ||
}); | ||
}); | ||
|
||
it('does not render if there are no rewards', async () => { | ||
const Component = (props) => ( | ||
<ApplicationBootstrapContext.Provider | ||
value={{ appEvents: { transactions: { rewards: [] } } }} | ||
> | ||
<ToastContainer /> | ||
<RewardsNotification {...props} /> | ||
</ApplicationBootstrapContext.Provider> | ||
); | ||
smartRender(Component); | ||
|
||
await waitFor(() => { | ||
expect( | ||
screen.queryByText('You have an unclaimed reward for your stakes.') | ||
).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
src/modules/common/components/notification/rewardsNotification/styles.css
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,51 @@ | ||
.rewardInfo { | ||
& p { | ||
margin-top: 8px; | ||
margin-bottom: 0; | ||
font-size: 16px; | ||
font-weight: var(--font-weight-normal); | ||
line-height: 20px; | ||
} | ||
|
||
.rewardLink { | ||
margin-top: 11px; | ||
margin-bottom: 0; | ||
color: var(--color-ultramarine-blue); | ||
font-size: 15px; | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.closeBtn { | ||
align-items: center; | ||
box-sizing: border-box; | ||
color: var(--color-ultramarine-blue); | ||
cursor: pointer; | ||
display: flex; | ||
height: 12px; | ||
width: 12px; | ||
justify-content: center; | ||
position: absolute; | ||
top: 12px; | ||
right: 12px; | ||
z-index: 4; | ||
|
||
&::before, | ||
&::after { | ||
background-color: currentColor; | ||
color: inherit; | ||
content: ''; | ||
height: 19px; | ||
position: absolute; | ||
width: 3px; | ||
border-radius: 3px; | ||
} | ||
|
||
&::before { | ||
transform: rotate(45deg); | ||
} | ||
|
||
&::after { | ||
transform: rotate(-45deg); | ||
} | ||
} |
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
51 changes: 0 additions & 51 deletions
51
src/modules/pos/validator/components/ValidatorsMonitorView/Validators.css
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