1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +01:00
metamask-extension/ui/pages/confirm-encryption-public-key/confirm-encryption-public-key.stories.js
George Marshall 854fc71ae7
Organizing storybook to echo app folder structure (#12796)
* Organizing storybook to echo app folder structure

* Updating new stories to follow new convention from develop
2021-12-01 11:27:57 -08:00

50 lines
1.2 KiB
JavaScript

import React, { useEffect } from 'react';
import { select } from '@storybook/addon-knobs';
import { store, getNewState } from '../../../.storybook/preview';
import { updateMetamaskState } from '../../store/actions';
import ConfirmEncryptionPublicKey from '.';
export default {
title: 'Pages/ConfirmEncryptionPublicKey',
id: __filename,
};
const PageSet = ({ children }) => {
const state = store.getState();
const options = [];
const { identities, unapprovedEncryptionPublicKeyMsgs } = state.metamask;
Object.keys(identities).forEach(function (key) {
options.push({
label: identities[key].name,
name: identities[key].name,
address: key,
});
});
const account = select('Account', options, options[0]);
useEffect(() => {
unapprovedEncryptionPublicKeyMsgs['7786962153682822'].msgParams =
account.address;
store.dispatch(
updateMetamaskState(
getNewState(state.metamask, {
unapprovedEncryptionPublicKeyMsgs,
}),
),
);
}, [account, unapprovedEncryptionPublicKeyMsgs, state.metamask]);
return children;
};
export const DefaultStory = () => {
return (
<PageSet>
<ConfirmEncryptionPublicKey />
</PageSet>
);
};
DefaultStory.storyName = 'Default';