2021-08-17 07:33:46 +02:00
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
2021-10-04 15:46:18 +02:00
|
|
|
import { store, getNewState } from '../../../.storybook/preview';
|
2021-08-17 07:33:46 +02:00
|
|
|
import { tokens } from '../../../.storybook/initial-states/approval-screens/add-token';
|
|
|
|
import { updateMetamaskState } from '../../store/actions';
|
|
|
|
import ConfirmAddToken from '.';
|
|
|
|
|
|
|
|
export default {
|
2021-12-01 20:27:57 +01:00
|
|
|
title: 'Pages/ConfirmImportToken',
|
2021-09-15 20:55:48 +02:00
|
|
|
id: __filename,
|
2022-02-16 19:03:54 +01:00
|
|
|
|
|
|
|
argTypes: {
|
|
|
|
pendingTokens: {
|
|
|
|
control: 'object',
|
|
|
|
table: { category: 'Data' },
|
|
|
|
},
|
|
|
|
},
|
2021-08-17 07:33:46 +02:00
|
|
|
};
|
|
|
|
|
2022-02-16 19:03:54 +01:00
|
|
|
const PageSet = ({ children, pendingTokens }) => {
|
|
|
|
const { metamask: state } = store.getState();
|
2021-08-17 07:33:46 +02:00
|
|
|
|
|
|
|
useEffect(() => {
|
2021-10-04 15:46:18 +02:00
|
|
|
store.dispatch(
|
|
|
|
updateMetamaskState(
|
2022-02-16 19:03:54 +01:00
|
|
|
getNewState(state, {
|
2021-10-04 15:46:18 +02:00
|
|
|
pendingTokens,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
2022-02-16 19:03:54 +01:00
|
|
|
}, [state, pendingTokens]);
|
2021-08-17 07:33:46 +02:00
|
|
|
|
|
|
|
return children;
|
|
|
|
};
|
|
|
|
|
2022-02-16 19:03:54 +01:00
|
|
|
export const DefaultStory = ({ pendingTokens }) => {
|
2021-08-17 07:33:46 +02:00
|
|
|
return (
|
2022-02-16 19:03:54 +01:00
|
|
|
<PageSet pendingTokens={pendingTokens}>
|
|
|
|
<ConfirmAddToken />
|
2021-08-17 07:33:46 +02:00
|
|
|
</PageSet>
|
|
|
|
);
|
|
|
|
};
|
2022-02-16 19:03:54 +01:00
|
|
|
DefaultStory.args = {
|
|
|
|
pendingTokens: { ...tokens },
|
|
|
|
};
|
2021-12-01 20:27:57 +01:00
|
|
|
DefaultStory.storyName = 'Default';
|