mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
WIP / Feature & Fix Expense /Customer
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
import React, {useCallback, useMemo} from 'react';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import AccountsSelectList from 'components/AccountsSelectList';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
FormGroup,
|
||||
Classes,
|
||||
Intent,
|
||||
} from '@blueprintjs/core';
|
||||
import { FormGroup, Classes, Intent } from '@blueprintjs/core';
|
||||
|
||||
// Account cell renderer.
|
||||
const AccountCellRenderer = ({
|
||||
@@ -14,31 +10,38 @@ const AccountCellRenderer = ({
|
||||
cell: { value: initialValue },
|
||||
payload: { accounts, updateData, errors },
|
||||
}) => {
|
||||
const handleAccountSelected = useCallback((account) => {
|
||||
updateData(index, id, account.id);
|
||||
}, [updateData, index, id]);
|
||||
const handleAccountSelected = useCallback(
|
||||
(account) => {
|
||||
updateData(index, id, account.id);
|
||||
},
|
||||
[updateData, index, id],
|
||||
);
|
||||
|
||||
const { account_id = false } = (errors[index] || {});
|
||||
const { account_id = false, expense_account_id = false } =
|
||||
errors[index] || {};
|
||||
|
||||
const initialAccount = useMemo(() =>
|
||||
accounts.find(a => a.id === initialValue),
|
||||
[accounts, initialValue]);
|
||||
const initialAccount = useMemo(
|
||||
() => accounts.find((a) => a.id === initialValue),
|
||||
[accounts, initialValue],
|
||||
);
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
intent={account_id ? Intent.DANGER : ''}
|
||||
intent={account_id || expense_account_id ? Intent.DANGER : ''}
|
||||
className={classNames(
|
||||
'form-group--select-list',
|
||||
'form-group--account',
|
||||
Classes.FILL)}
|
||||
>
|
||||
Classes.FILL,
|
||||
)}
|
||||
>
|
||||
<AccountsSelectList
|
||||
accounts={accounts}
|
||||
onAccountSelected={handleAccountSelected}
|
||||
error={account_id}
|
||||
initialAccount={initialAccount} />
|
||||
error={[account_id, expense_account_id]}
|
||||
initialAccount={initialAccount}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
};
|
||||
|
||||
export default AccountCellRenderer;
|
||||
export default AccountCellRenderer;
|
||||
|
||||
Reference in New Issue
Block a user