/* eslint-disable react/prop-types */ import React, { useEffect, useState } from 'react'; import { Provider } from 'react-redux'; import testData from '../../../../../.storybook/test-data'; import { GAS_INPUT_MODES } from '../../../../ducks/send'; import { updateMetamaskState } from '../../../../store/actions'; import configureStore from '../../../../store/store'; import { calcGasTotal } from '../../send.utils'; import README from './README.mdx'; import SendGasRow from './send-gas-row.component'; const store = configureStore(testData); export default { title: 'Pages/Send/SendContent/SendGasRow', id: __filename, decorators: [(story) => {story()}], parameters: { docs: { page: README, }, }, argTypes: { insufficientBalance: { name: 'Is Insufficient Balance', control: { type: 'boolean' }, defaultValue: false, }, }, }; export const DefaultStory = (args) => { const state = store.getState(); const { metamask } = state; const { send } = metamask; const [sendState, setSendState] = useState(send); useEffect(() => { const newState = Object.assign(metamask, { send: sendState, }); store.dispatch(updateMetamaskState(newState)); }, [sendState, metamask]); const updateGasPrice = ({ gasPrice, gasLimit }) => { let newGasTotal = send.gasTotal; if (send.gasLimit) { newGasTotal = calcGasTotal(gasLimit, gasPrice); } const newState = { ...state.metamask.send, gasPrice, gasTotal: newGasTotal, }; setSendState(newState); }; const updateGasLimit = (limit) => { let newGasTotal = send.gasTotal; if (send.gasPrice) { newGasTotal = calcGasTotal(limit, send.gasPrice); } const newState = { ...state.metamask.send, gasLimit: limit, gasTotal: newGasTotal, }; setSendState(newState); }; return (
); }; DefaultStory.storyName = 'SendGasRow';