diff --git a/src/components/Accounts/AccountsSelectList.tsx b/src/components/Accounts/AccountsSelectList.tsx index e8eb37a4a..8ec02d8e4 100644 --- a/src/components/Accounts/AccountsSelectList.tsx +++ b/src/components/Accounts/AccountsSelectList.tsx @@ -8,7 +8,9 @@ import * as R from 'ramda'; import { MenuItemNestedText, FormattedMessage as T } from '@/components'; import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils'; + import { CLASSES } from '@/constants/classes'; +import { DialogsName } from '@/constants/dialogs'; import withDialogActions from '@/containers/Dialog/withDialogActions'; @@ -129,7 +131,7 @@ function AccountsSelectListRoot({ setSelectedAccount({ ...account }); onAccountSelected && onAccountSelected(account); } else { - openDialog('account-form'); + openDialog(DialogsName.AccountForm); } }, [setSelectedAccount, onAccountSelected, openDialog], diff --git a/src/components/Accounts/AccountsSuggestField.tsx b/src/components/Accounts/AccountsSuggestField.tsx index 4afac2784..4680d150a 100644 --- a/src/components/Accounts/AccountsSuggestField.tsx +++ b/src/components/Accounts/AccountsSuggestField.tsx @@ -7,6 +7,8 @@ import { MenuItem } from '@blueprintjs/core'; import { Suggest } from '@blueprintjs/select'; import { CLASSES } from '@/constants/classes'; +import { DialogsName } from '@/constants/dialogs'; + import { MenuItemNestedText, FormattedMessage as T } from '@/components'; import { nestedArrayToflatten, filterAccountsByQuery } from '@/utils'; @@ -134,7 +136,7 @@ function AccountsSuggestFieldRoot({ setSelectedAccount({ ...account }); onAccountSelected && onAccountSelected(account); } else { - openDialog('account-form'); + openDialog(DialogsName.AccountForm); } }, [setSelectedAccount, onAccountSelected, openDialog], diff --git a/src/containers/Accounts/AccountsActionsBar.tsx b/src/containers/Accounts/AccountsActionsBar.tsx index 435e64935..38d7a8214 100644 --- a/src/containers/Accounts/AccountsActionsBar.tsx +++ b/src/containers/Accounts/AccountsActionsBar.tsx @@ -24,8 +24,11 @@ import { } from '@/components'; import { AccountAction, AbilitySubject } from '@/constants/abilityOption'; +import { DialogsName } from '@/constants/dialogs'; + import { useRefreshAccounts } from '@/hooks/query/accounts'; import { useAccountsChartContext } from './AccountsChartProvider'; + import withAccounts from './withAccounts'; import withAccountsTableActions from './withAccountsTableActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; @@ -65,7 +68,7 @@ function AccountsActionsBar({ const { resourceViews, fields } = useAccountsChartContext(); const onClickNewAccount = () => { - openDialog('account-form', {}); + openDialog(DialogsName.AccountForm, {}); }; // Accounts refresh action. diff --git a/src/containers/Accounts/AccountsDataTable.tsx b/src/containers/Accounts/AccountsDataTable.tsx index 440b2c6de..2c5270c34 100644 --- a/src/containers/Accounts/AccountsDataTable.tsx +++ b/src/containers/Accounts/AccountsDataTable.tsx @@ -8,13 +8,15 @@ import { TableSkeletonHeader, TableVirtualizedListRows, } from '@/components'; -import { TABLES } from '@/constants/tables'; import { useAccountsTableColumns, rowClassNames } from './utils'; import { ActionsMenu } from './components'; +import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils'; import { useAccountsChartContext } from './AccountsChartProvider'; import { useMemorizedColumnsWidths } from '@/hooks'; -import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils'; + +import { TABLES } from '@/constants/tables'; +import { DialogsName } from '@/constants/dialogs'; import withSettings from '@/containers/Settings/withSettings'; import withAlertsActions from '@/containers/Alert/withAlertActions'; @@ -61,9 +63,9 @@ function AccountsDataTable({ // Handle edit account action. const handleEditAccount = (account) => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.Edit, - id: account.id, + accountId: account.id, }); }; @@ -74,7 +76,7 @@ function AccountsDataTable({ // Handle new child button click. const handleNewChildAccount = (account) => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.NewChild, parentAccountId: account.id, accountType: account.account_type, diff --git a/src/containers/CashFlow/CashFlowAccounts/CashFlowAccountsActionsBar.tsx b/src/containers/CashFlow/CashFlowAccounts/CashFlowAccountsActionsBar.tsx index faa61dfbc..4c5c2d4c8 100644 --- a/src/containers/CashFlow/CashFlowAccounts/CashFlowAccountsActionsBar.tsx +++ b/src/containers/CashFlow/CashFlowAccounts/CashFlowAccountsActionsBar.tsx @@ -21,7 +21,9 @@ import withDialogActions from '@/containers/Dialog/withDialogActions'; import withCashflowAccountsTableActions from '../AccountTransactions/withCashflowAccountsTableActions'; import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils'; + import { ACCOUNT_TYPE } from '@/constants'; +import { DialogsName } from '@/constants/dialogs'; import { compose } from '@/utils'; @@ -43,14 +45,14 @@ function CashFlowAccountsActionsBar({ }; // Handle add bank account. const handleAddBankAccount = () => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.NewDefinedType, accountType: ACCOUNT_TYPE.CASH, }); }; // Handle add cash account. const handleAddCashAccount = () => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.NewDefinedType, accountType: ACCOUNT_TYPE.BANK, }); diff --git a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.tsx b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.tsx index b28e871e1..a5abe5482 100644 --- a/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.tsx +++ b/src/containers/CashFlow/CashFlowAccounts/CashflowAccountsGrid.tsx @@ -8,13 +8,15 @@ import { Link } from 'react-router-dom'; import { ContextMenu2 } from '@blueprintjs/popover2'; import { Menu, MenuItem, MenuDivider, Intent } from '@blueprintjs/core'; -import { BankAccountsList, BankAccount, If, Icon, T, Can } from '@/components'; import { AccountAction, CashflowAction, AbilitySubject, } from '@/constants/abilityOption'; +import { DialogsName } from '@/constants/dialogs'; +import { addMoneyIn, addMoneyOut } from '@/constants/cashflowOptions'; +import { BankAccountsList, BankAccount, If, Icon, T, Can } from '@/components'; import { useCashFlowAccountsContext } from './CashFlowAccountsProvider'; import withDrawerActions from '@/containers/Drawer/withDrawerActions'; @@ -22,7 +24,7 @@ import withAlertsActions from '@/containers/Alert/withAlertActions'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import { safeCallback } from '@/utils'; -import { addMoneyIn, addMoneyOut } from '@/constants/cashflowOptions'; +import { AccountDialogAction } from '@/containers/Dialogs/AccountDialog/utils'; const CASHFLOW_SKELETON_N = 4; @@ -74,7 +76,10 @@ function CashflowBankAccount({ }; // Handle edit account action. const handleEditAccount = () => { - openDialog('account-form', { action: 'edit', id: account.id }); + openDialog(DialogsName.AccountForm, { + action: AccountDialogAction.Edit, + id: account.id, + }); }; // Handle money in menu item actions. const handleMoneyInClick = (transactionType) => { diff --git a/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.tsx b/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.tsx index b0e702cb8..fe2e67644 100644 --- a/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.tsx +++ b/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.tsx @@ -13,7 +13,9 @@ import { Can, FormattedMessage as T, } from '@/components'; + import { AccountAction, AbilitySubject } from '@/constants/abilityOption'; +import { DialogsName } from '@/constants/dialogs'; import withDialogActions from '@/containers/Dialog/withDialogActions'; import withAlertsActions from '@/containers/Alert/withAlertActions'; @@ -37,7 +39,7 @@ function AccountDrawerActionBar({ // Handle new child button click. const onNewChildAccount = () => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.NewChild, parentAccountId: account.id, accountType: account.account_type, @@ -45,9 +47,9 @@ function AccountDrawerActionBar({ }; // Handle edit account action. const onEditAccount = () => { - openDialog('account-form', { + openDialog(DialogsName.AccountForm, { action: AccountDialogAction.Edit, - id: account.id, + accountId: account.id, }); }; // Handle delete action account.