11import React from 'react' ;
2- import { findKey } from 'lodash' ;
3- import addons from '@storybook/addons' ;
4- import { boolean , number , CHANGE } from '@storybook/addon-knobs' ;
2+ import { boolean , number } from '@storybook/addon-knobs' ;
53import { storiesOf } from '@storybook/react' ;
64import { action } from '@storybook/addon-actions' ;
75import { withState } from '@dump247/storybook-state' ;
86import SettingsWrapper from '../utils/SettingsWrapper' ;
9- import {
10- DATE_ENGLISH_OPTIONS ,
11- LANGUAGE_OPTIONS ,
12- NUMBER_OPTIONS ,
13- TIME_OPTIONS ,
14- } from '../../../../source/renderer/app/config/profileConfig' ;
157import { updateParam } from '../../../addons/DaedalusMenu' ;
16- import { locales , themesIds } from '../../_support/config' ;
8+ import { themesIds } from '../../_support/config' ;
179// Screens
1810import ProfileSettingsForm from '../../../../source/renderer/app/components/widgets/forms/ProfileSettingsForm' ;
1911import StakePoolsSettings from '../../../../source/renderer/app/components/settings/categories/StakePoolsSettings' ;
@@ -23,14 +15,22 @@ import TermsOfUseSettings from '../../../../source/renderer/app/components/setti
2315import WalletsSettings from '../../../../source/renderer/app/components/settings/categories/WalletsSettings' ;
2416import SecuritySettings from '../../../../source/renderer/app/components/settings/categories/SecuritySettings' ;
2517// Assets and helpers
18+ import { mockedLocaleState , onLocaleValueChange } from '../utils/helpers' ;
2619import currenciesList from '../../../../source/renderer/app/config/currenciesList.json' ;
2720import { getLocalizedCurrenciesList } from '../../../../source/renderer/app/config/currencyConfig' ;
2821
29- const changeControl = ( name : string , value : boolean ) => {
30- addons . getChannel ( ) . emit ( CHANGE , {
31- name,
32- value,
33- } ) ;
22+ const mockedWalletsState = {
23+ currencyIsActive : true ,
24+ currencySelected : {
25+ id : 'uniswap-state-dollar' ,
26+ code : 'usd' ,
27+ name : 'unified Stable Dollar' ,
28+ } ,
29+ } ;
30+
31+ const mockedSecurityStore = {
32+ discreetMode : true ,
33+ openDiscreetMode : false ,
3434} ;
3535
3636const getParamName = ( obj , itemName ) : any =>
@@ -39,52 +39,38 @@ const getParamName = (obj, itemName): any =>
3939/* eslint-disable consistent-return */
4040storiesOf ( 'Settings / General' , module )
4141 . addDecorator ( SettingsWrapper ) // ====== Stories ======
42- . add ( 'General' , ( ) => (
43- < ProfileSettingsForm
44- isSubmitting = { boolean ( 'isSubmitting' , false ) }
45- onSubmit = { action ( 'submit' ) }
46- onChangeItem = { ( param : string , value : string ) => {
47- if ( param === 'locale' ) {
48- updateParam ( {
49- param : 'localeName' ,
50- value : findKey ( locales , ( item ) => item === value ) ,
51- } ) ;
52- }
53- } }
54- currentDateFormat = { DATE_ENGLISH_OPTIONS [ 0 ] . value }
55- currentLocale = { LANGUAGE_OPTIONS [ 0 ] . value }
56- currentNumberFormat = { NUMBER_OPTIONS [ 0 ] . value }
57- currentTimeFormat = { TIME_OPTIONS [ 0 ] . value }
58- />
59- ) )
42+ . add (
43+ 'General' ,
44+ withState ( mockedLocaleState , ( store ) => (
45+ < ProfileSettingsForm
46+ isSubmitting = { boolean ( 'isSubmitting' , false ) }
47+ onSubmit = { action ( 'submit' ) }
48+ onChangeItem = { ( id , value ) => onLocaleValueChange ( store , id , value ) }
49+ { ...store . state }
50+ />
51+ ) )
52+ )
6053 . add (
6154 'Wallets' ,
62- withState (
63- {
64- currencySelected : {
65- id : 'uniswap-state-dollar' ,
66- code : 'usd' ,
67- name : 'unified Stable Dollar' ,
68- } ,
69- } ,
70- ( store ) => (
71- < WalletsSettings
72- currencySelected = { store . state . currencySelected }
73- // @ts -ignore ts-migrate(2769) FIXME: No overload matches this call.
74- currencyRate = { 0.321 }
75- // @ts -ignore ts-migrate(2345) FIXME: Argument of type '{ aed: { code: string; decimalDi... Remove this comment to see the full error message
76- currencyList = { getLocalizedCurrenciesList ( currenciesList , 'en-US' ) }
77- currencyIsActive
78- onSelectCurrency = { ( code ) =>
79- store . set ( {
80- currencySelected : currenciesList [ code ] ,
81- } )
82- }
83- onToggleCurrencyIsActive = { action ( 'onToggleCurrencyIsActive' ) }
84- onOpenExternalLink = { action ( 'onOpenExternalLink' ) }
85- />
86- )
87- )
55+ withState ( mockedWalletsState , ( store ) => (
56+ < WalletsSettings
57+ currencySelected = { store . state . currencySelected }
58+ // @ts -ignore ts-migrate(2769) FIXME: No overload matches this call.
59+ currencyRate = { 0.321 }
60+ // @ts -ignore ts-migrate(2345) FIXME: Argument of type '{ aed: { code: string; decimalDi... Remove this comment to see the full error message
61+ currencyList = { getLocalizedCurrenciesList ( currenciesList , 'en-US' ) }
62+ onSelectCurrency = { ( code ) =>
63+ store . set ( {
64+ currencySelected : currenciesList [ code ] ,
65+ } )
66+ }
67+ onToggleCurrencyIsActive = { ( value ) =>
68+ store . set ( { currencyIsActive : value } )
69+ }
70+ onOpenExternalLink = { action ( 'onOpenExternalLink' ) }
71+ { ...store . state }
72+ />
73+ ) )
8874 )
8975 . add ( 'Stake Pools' , ( ) => (
9076 < StakePoolsSettings
@@ -132,17 +118,15 @@ storiesOf('Settings / General', module)
132118 analyticsAccepted = { boolean ( 'analyticsAccepted' , false ) }
133119 />
134120 ) )
135- . add ( 'Security' , ( ) => (
136- < SecuritySettings
137- discreetMode = { boolean ( 'discreetMode' , false ) }
138- openDiscreetMode = { boolean ( 'openDiscreetMode' , false ) }
139- onDiscreetModeToggle = { ( ) =>
140- // @ts -ignore ts-migrate(2554) FIXME: Expected 2-3 arguments, but got 1.
141- changeControl ( 'discreetMode' , ! boolean ( 'discreetMode' ) )
142- }
143- onOpenDiscreetModeToggle = { ( ) =>
144- // @ts -ignore ts-migrate(2554) FIXME: Expected 2-3 arguments, but got 1.
145- changeControl ( 'openDiscreetMode' , ! boolean ( 'openDiscreetMode' ) )
146- }
147- />
148- ) ) ;
121+ . add (
122+ 'Security' ,
123+ withState ( mockedSecurityStore , ( store ) => (
124+ < SecuritySettings
125+ onDiscreetModeToggle = { ( value ) => store . set ( { discreetMode : value } ) }
126+ onOpenDiscreetModeToggle = { ( value ) =>
127+ store . set ( { openDiscreetMode : value } )
128+ }
129+ { ...store . state }
130+ />
131+ ) )
132+ ) ;
0 commit comments