Skip to content

Commit

Permalink
add warning dialog for wallets not delegating
Browse files Browse the repository at this point in the history
  • Loading branch information
v-almonacid committed May 4, 2021
1 parent bd6d9ad commit cc53cba
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
49 changes: 44 additions & 5 deletions src/components/Catalyst/Step1.js
Expand Up @@ -4,7 +4,7 @@
* Step 1 for the Catalyst registration - landing
*/

import React, {useEffect} from 'react'
import React, {useEffect, useState} from 'react'
import {
View,
ScrollView,
Expand All @@ -19,12 +19,14 @@ import {connect} from 'react-redux'
import {generateVotingKeys} from '../../actions/voting'
import {fetchUTXOs} from '../../actions/utxo'
import {Text, Button, ProgressStep} from '../UiKit'
import StandardModal from '../Common/StandardModal'
import {withTitle} from '../../utils/renderUtils'
import {CATALYST_ROUTES} from '../../RoutesList'
import globalMessages, {confirmationMessages} from '../../i18n/global-messages'
import AppDownload from '../../assets/img/pic-catalyst-step1.png'
import playstoreBadge from '../../assets/img/google-play-badge.png'
import appstoreBadge from '../../assets/img/app-store-badge.png'
import {isDelegatingSelector} from '../../selectors'

import styles from './styles/Step1.style'

Expand All @@ -39,6 +41,13 @@ const messages = defineMessages({
defaultMessage:
'!!!Before you begin, make sure to download the Catalyst Voting App.',
},
stakingKeyNotRegistered: {
id: 'components.catalyst.step1.stakingKeyNotRegistered',
defaultMessage:
'!!!Catalyst voting rewards are sent to delegation accounts and your ' +
'wallet does not seem to have a registered delegation certificate. If ' +
'you want to receive voting rewards, you need to delegate your funds first.',
},
tip: {
id: 'components.catalyst.step1.tip',
defaultMessage:
Expand All @@ -47,7 +56,21 @@ const messages = defineMessages({
},
})

const Step1 = ({intl, generateVotingKeys, navigation, fetchUTXOs}) => {
const WarningModalBody = ({intl}) => (
<View>
<Text>{intl.formatMessage(messages.stakingKeyNotRegistered)}</Text>
</View>
)

const Step1 = ({
intl,
generateVotingKeys,
navigation,
fetchUTXOs,
isDelegating,
}) => {
const [showModal, setShowModal] = useState<boolean>(!isDelegating)

useEffect(() => {
fetchUTXOs()
generateVotingKeys()
Expand Down Expand Up @@ -98,27 +121,43 @@ const Step1 = ({intl, generateVotingKeys, navigation, fetchUTXOs}) => {
)}
/>
</View>
<StandardModal
visible={showModal}
title={intl.formatMessage(globalMessages.attention)}
children={<WarningModalBody intl={intl} />}
onRequestClose={() => setShowModal(false)}
primaryButton={{
label: intl.formatMessage(
confirmationMessages.commonButtons.iUnderstandButton,
),
onPress: () => setShowModal(false),
}}
showCloseIcon
/>
</SafeAreaView>
)
}

type ExternalProps = {|
type Props = {|
navigation: Navigation,
route: Object, // TODO(navigation): type
intl: IntlShape,
generateVotingKeys: () => void,
fetchUTXOs: () => Promise<void>,
isDelegating: boolean,
|}

export default injectIntl(
connect(
(_state) => ({}),
(state) => ({
isDelegating: isDelegatingSelector(state),
}),
{
generateVotingKeys,
fetchUTXOs,
},
)(
withTitle((Step1: ComponentType<ExternalProps>), ({intl}) =>
withTitle((Step1: ComponentType<Props>), ({intl}) =>
intl.formatMessage(globalMessages.votingTitle),
),
),
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Expand Up @@ -343,6 +343,7 @@
"components.catalyst.banner.name": "Catalyst Voting",
"components.catalyst.insufficientBalance": "Participating requires at least {requiredBalance}, but you only have {currentBalance}. Unwithdrawn rewards are not included in this amount",
"components.catalyst.step1.subTitle": "Before you begin, make sure to download the Catalyst Voting App.",
"components.catalyst.step1.stakingKeyNotRegistered": "Catalyst voting rewards are sent to delegation accounts and your wallet does not seem to have a registered delegation certificate. If you want to receive voting rewards, you need to delegate your funds first.",
"components.catalyst.step1.tip": "Tip: Make sure you know how to take a screenshot with your device, so that you can backup your catalyst QR code.",
"components.catalyst.step2.subTitle": "Write Down PIN",
"components.catalyst.step2.description": "Please write down this PIN as you will need it every time you want to access the Catalyst Voting app",
Expand Down

0 comments on commit cc53cba

Please sign in to comment.