-
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 #382 from Concordium/p8/suspension-status
P8/suspension status
- Loading branch information
Showing
16 changed files
with
289 additions
and
46 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
File renamed without changes.
File renamed without changes.
70 changes: 70 additions & 0 deletions
70
app/components/Notification/SuspendedValidatorNotification.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,70 @@ | ||
import React from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { AccountInfoType } from '@concordium/web-sdk'; | ||
import { push } from 'connected-react-router'; | ||
|
||
import { NotificationLevel } from '~/features/NotificationSlice'; | ||
import Button from '~/cross-app-components/Button'; | ||
import { accountsInfoSelector, chooseAccount } from '~/features/AccountSlice'; | ||
import routes from '~/constants/routes.json'; | ||
import Notification from './Notification'; | ||
import { displaySplitAddress } from '~/utils/accountHelpers'; | ||
|
||
type Props = { | ||
onClose(): void; | ||
accountAddress: string; | ||
}; | ||
|
||
/** | ||
* A notification to be shown when an account is delegating to a staking pool | ||
* that is going to close in the near future. | ||
*/ | ||
export default function SuspendedValidatorNotification({ | ||
onClose, | ||
accountAddress, | ||
}: Props) { | ||
const dispatch = useDispatch(); | ||
const accountInfo = useSelector(accountsInfoSelector)[accountAddress]; | ||
|
||
const toAccount = () => { | ||
let route: string; | ||
switch (accountInfo.type) { | ||
case AccountInfoType.Baker: { | ||
route = routes.ACCOUNTS_BAKING; | ||
break; | ||
} | ||
case AccountInfoType.Delegator: { | ||
route = routes.ACCOUNTS_DELEGATION; | ||
break; | ||
} | ||
default: { | ||
throw new Error('Expected account to be staking'); | ||
} | ||
} | ||
|
||
dispatch(chooseAccount(accountAddress)); | ||
dispatch(push(route)); | ||
|
||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Notification | ||
className="flexColumn alignCenter" | ||
level={NotificationLevel.Error} | ||
onCloseClick={onClose} | ||
> | ||
<div className="flex alignCenter"> | ||
The target pool of the following account is currently suspended. | ||
</div> | ||
<div className="flex alignCenter mT10 textBreakAll"> | ||
<b>{displaySplitAddress(accountAddress)}</b> | ||
</div> | ||
<div className="inlineFlexColumn mT10"> | ||
<Button className="mT10" size="tiny" onClick={toAccount}> | ||
Go to account | ||
</Button> | ||
</div> | ||
</Notification> | ||
); | ||
} |
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
Oops, something went wrong.