feat: fix stories which needs prop instead of redux

This commit is contained in:
RadoslavDimchev 2023-09-28 20:54:52 +03:00
parent ecf7dff530
commit b56e2b4527
5 changed files with 23 additions and 13 deletions

View File

@ -50,7 +50,11 @@ const Deposit = () => {
{isTransactionConfirmation && <ConnectedWallet />} {isTransactionConfirmation && <ConnectedWallet />}
<DividerLine style={{ marginTop: isTransactionConfirmation ? '0px' : '15px' }} /> <DividerLine style={{ marginTop: isTransactionConfirmation ? '0px' : '15px' }} />
{Array.from({ length: validatorCount }).map((_, index) => ( {Array.from({ length: validatorCount }).map((_, index) => (
<ValidatorRequest key={index} number={index + 1} /> <ValidatorRequest
key={index}
number={index + 1}
isTransactionConfirmation={isTransactionConfirmation}
/>
))} ))}
{isInfoBoxVisible && !isTransactionConfirmation && ( {isInfoBoxVisible && !isTransactionConfirmation && (
<InformationBox <InformationBox

View File

@ -17,23 +17,27 @@ type Story = StoryObj<typeof meta>
export const Default: Story = { export const Default: Story = {
args: { args: {
transactionStatus: '', transactionStatus: '',
isTransactionConfirmation: false,
}, },
} }
export const Complete: Story = { export const Complete: Story = {
args: { args: {
transactionStatus: 'Complete', transactionStatus: 'Complete',
isTransactionConfirmation: true,
}, },
} }
export const Pending: Story = { export const Pending: Story = {
args: { args: {
transactionStatus: 'Pending', transactionStatus: 'Pending',
isTransactionConfirmation: true,
}, },
} }
export const Fail: Story = { export const Fail: Story = {
args: { args: {
transactionStatus: 'Fail', transactionStatus: 'Fail',
isTransactionConfirmation: true,
}, },
} }

View File

@ -1,17 +1,16 @@
import { Text } from '@status-im/components' import { Text } from '@status-im/components'
import { FullscreenMacOsIcon, MinimizeMacOsIcon, CloseMacOsIcon } from '@status-im/icons' import { FullscreenMacOsIcon, MinimizeMacOsIcon, CloseMacOsIcon } from '@status-im/icons'
import { XStack } from 'tamagui' import { XStack } from 'tamagui'
import { useSelector } from 'react-redux'
import { RootState } from '../../../../redux/store'
type VTransactionStatusProps = { type VTransactionStatusProps = {
transactionStatus: string transactionStatus: string
isTransactionConfirmation?: boolean
} }
const TransactionStatus = ({ transactionStatus }: VTransactionStatusProps) => { const TransactionStatus = ({
const { isTransactionConfirmation } = useSelector((state: RootState) => state.deposit) transactionStatus,
isTransactionConfirmation,
}: VTransactionStatusProps) => {
const isTransactionCompleted = transactionStatus === 'Complete' const isTransactionCompleted = transactionStatus === 'Complete'
return ( return (

View File

@ -17,17 +17,20 @@ type Story = StoryObj<typeof meta>
export const Default: Story = { export const Default: Story = {
args: { args: {
number: 1, number: 1,
isTransactionConfirmation: false,
}, },
} }
export const TransactionConfirmation: Story = { export const TransactionConfirmation: Story = {
args: { args: {
number: 1, number: 1,
isTransactionConfirmation: true,
}, },
} }
export const BigNumber: Story = { export const BigNumber: Story = {
args: { args: {
number: 123456789, number: 123456789,
isTransactionConfirmation: false,
}, },
} }

View File

@ -1,18 +1,15 @@
import { Avatar, DividerLine, Text } from '@status-im/components' import { Avatar, DividerLine, Text } from '@status-im/components'
import { XStack, YStack } from 'tamagui' import { XStack, YStack } from 'tamagui'
import { useSelector } from 'react-redux'
import { getFormattedValidatorAddress } from '../../../../utilities' import { getFormattedValidatorAddress } from '../../../../utilities'
import TransactionStatus from './TransactionStatus' import TransactionStatus from './TransactionStatus'
import { RootState } from '../../../../redux/store'
type ValidatorRequestProps = { type ValidatorRequestProps = {
number: number number: number
isTransactionConfirmation?: boolean
} }
const ValidatorRequest = ({ number }: ValidatorRequestProps) => { const ValidatorRequest = ({ number, isTransactionConfirmation }: ValidatorRequestProps) => {
const { isTransactionConfirmation } = useSelector((state: RootState) => state.deposit)
let transactionStatus = 'Complete' let transactionStatus = 'Complete'
const isTransactionCompleted = transactionStatus === 'Complete' const isTransactionCompleted = transactionStatus === 'Complete'
@ -57,7 +54,10 @@ const ValidatorRequest = ({ number }: ValidatorRequestProps) => {
{isTransactionCompleted ? 32 : 0} ETH {isTransactionCompleted ? 32 : 0} ETH
</Text> </Text>
)} )}
<TransactionStatus transactionStatus={transactionStatus} /> <TransactionStatus
transactionStatus={transactionStatus}
isTransactionConfirmation={isTransactionConfirmation}
/>
</XStack> </XStack>
</XStack> </XStack>
<DividerLine /> <DividerLine />