mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
added storybook controls for confirm send ether component (#15235)
* added storybook controls for confirm send ether component * fixed lint errors * corrected the argTypes for send-ether-storybook component
This commit is contained in:
parent
f1ca3e56e7
commit
132c1818df
@ -1,59 +1,25 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { select } from '@storybook/addon-knobs';
|
|
||||||
import { store } from '../../../.storybook/preview';
|
|
||||||
import { updateTransactionParams } from '../../store/actions';
|
|
||||||
import ConfirmSendEther from '.';
|
import ConfirmSendEther from '.';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Pages/ConfirmSendEther',
|
title: 'Pages/ConfirmSendEther',
|
||||||
id: __filename,
|
id: __filename,
|
||||||
|
component: ConfirmSendEther,
|
||||||
|
argTypes: {
|
||||||
|
editTransaction: {
|
||||||
|
action: 'editTransaction',
|
||||||
|
},
|
||||||
|
history: {
|
||||||
|
control: 'object',
|
||||||
|
},
|
||||||
|
txParams: {
|
||||||
|
control: 'object',
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// transaction id for redux dispatcher
|
export const DefaultStory = (args) => {
|
||||||
const id = 3111025347726181;
|
return <ConfirmSendEther {...args} />;
|
||||||
|
|
||||||
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>
|
|
||||||
<ConfirmSendEther />
|
|
||||||
</PageSet>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DefaultStory.storyName = 'Default';
|
DefaultStory.storyName = 'Default';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user