added storybook controls for confirm deploy contract component (#15236)
* added storybook controls for confirm deploy contract component * fixed args in confirm-deploy-contract-storybook Co-authored-by: David Walsh <davidwalsh83@gmail.com>feature/default_network_editable
parent
e6931e3f5d
commit
c85af877bd
@ -1,60 +1,22 @@ |
||||
/* eslint-disable react/prop-types */ |
||||
import React, { useEffect } from 'react'; |
||||
|
||||
import { select } from '@storybook/addon-knobs'; |
||||
import { store } from '../../../.storybook/preview'; |
||||
import { updateTransactionParams } from '../../store/actions'; |
||||
import React from 'react'; |
||||
import ConfirmDeployContract from '.'; |
||||
|
||||
export default { |
||||
title: 'Pages/ConfirmDeployContract', |
||||
id: __filename, |
||||
component: ConfirmDeployContract, |
||||
argTypes: { |
||||
txData: { |
||||
control: { |
||||
type: 'object', |
||||
}, |
||||
}, |
||||
}, |
||||
}; |
||||
|
||||
// transaction ID
|
||||
const id = 3111025347726181; |
||||
|
||||
const PageSet = ({ children }) => { |
||||
const options = []; |
||||
const receiverOptions = { |
||||
'Address 1': '0xaD6D458402F60fD3Bd25163575031ACDce07538D', |
||||
'Address 2': '0x55e0bfb2d400e9be8cf9b114e38a40969a02f69a', |
||||
}; |
||||
const state = store.getState(); |
||||
const { identities } = state.metamask; |
||||
Object.keys(identities).forEach(function (key) { |
||||
options.push({ |
||||
label: identities[key].name, |
||||
address: key, |
||||
}); |
||||
}); |
||||
const sender = select('Sender', options, options[0]); |
||||
const receiver = select( |
||||
'Receiver', |
||||
receiverOptions, |
||||
'0xaD6D458402F60fD3Bd25163575031ACDce07538D', |
||||
); |
||||
|
||||
const confirmTransactionState = state.confirmTransaction.txData.txParams; |
||||
|
||||
useEffect(() => { |
||||
confirmTransactionState.from = sender.address; |
||||
store.dispatch(updateTransactionParams(id, confirmTransactionState)); |
||||
}, [sender, confirmTransactionState]); |
||||
|
||||
useEffect(() => { |
||||
confirmTransactionState.to = receiver; |
||||
store.dispatch(updateTransactionParams(id, confirmTransactionState)); |
||||
}, [receiver, confirmTransactionState]); |
||||
return children; |
||||
}; |
||||
|
||||
export const DefaultStory = () => { |
||||
return ( |
||||
<PageSet> |
||||
<ConfirmDeployContract /> |
||||
</PageSet> |
||||
); |
||||
export const DefaultStory = (args) => { |
||||
return <ConfirmDeployContract {...args} />; |
||||
}; |
||||
|
||||
DefaultStory.storyName = 'Default'; |
||||
|
Loading…
Reference in new issue