import React from 'react'; import { connect } from 'react-redux'; import { Route, Switch } from 'react-router-dom'; import Component from '@reactions/component'; import { createLocation } from 'history'; import { bindActionCreators } from 'redux'; import * as actions from 'loot-core/src/client/actions'; import { send, listen, unlisten } from 'loot-core/src/platform/client/fetch'; import CloseAccount from 'loot-design/src/components/modals/CloseAccount'; import ConfigureLinkedAccounts from 'loot-design/src/components/modals/ConfigureLinkedAccounts'; import CreateLocalAccount from 'loot-design/src/components/modals/CreateLocalAccount'; import EditField from 'loot-design/src/components/modals/EditField'; import ImportTransactions from 'loot-design/src/components/modals/ImportTransactions'; import LoadBackup from 'loot-design/src/components/modals/LoadBackup'; import PlaidExternalMsg from 'loot-design/src/components/modals/PlaidExternalMsg'; import SelectLinkedAccounts from 'loot-design/src/components/modals/SelectLinkedAccounts'; import ConfirmCategoryDelete from './modals/ConfirmCategoryDelete'; import CreateAccount from './modals/CreateAccount'; import CreateEncryptionKey from './modals/CreateEncryptionKey'; import EditRule from './modals/EditRule'; import FixEncryptionKey from './modals/FixEncryptionKey'; import ManageRules from './modals/ManageRules'; import MergeUnusedPayees from './modals/MergeUnusedPayees'; import WelcomeScreen from './modals/WelcomeScreen'; import ManagePayeesWithData from './payees/ManagePayeesWithData'; function Modals({ history, modalStack, isHidden, accounts, categoryGroups, categories, payees, budgetId, actions }) { return modalStack.map(({ name, options = {} }, idx) => { const modalProps = { onClose: actions.popModal, onBack: actions.popModal, showBack: idx > 0, isCurrent: idx === modalStack.length - 1, isHidden, stackIndex: idx }; let location = createLocation('/' + name); return ( acct.closed === 0)} categoryGroups={categoryGroups} actions={actions} /> { const { category, group, onDelete } = options; return ( c.id === category)} group={categoryGroups.find(g => g.id === group)} categoryGroups={categoryGroups} onDelete={onDelete} /> ); }} /> { return ( { setState({ backups: await send('backups-get', { id: budgetId }) }); listen('backups-updated', backups => { setState({ backups }); }); }} willUnmount={() => { unlisten('backups-updated'); }} > {({ state }) => ( )} ); }} /> { return ( ); }} /> { return ( ); }} /> { return ( ); }} /> { return ( ); }} /> { return ( { options.onClose && options.onClose(); send('poll-web-token-stop'); }} onSuccess={options.onSuccess} /> ); }} /> { return ( ); }} /> { return ( ); }} /> { return ( ); }} /> ); }); } export default connect( state => ({ modalStack: state.modals.modalStack, isHidden: state.modals.isHidden, accounts: state.queries.accounts, categoryGroups: state.queries.categories.grouped, categories: state.queries.categories.list, payees: state.queries.payees, budgetId: state.prefs.local && state.prefs.local.id }), dispatch => ({ actions: bindActionCreators(actions, dispatch) }) )(Modals);