mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: Edit make journal entries.
This commit is contained in:
@@ -1,29 +1,23 @@
|
||||
import React, {useMemo, useCallback, useState} from 'react';
|
||||
import {omit} from 'lodash';
|
||||
import React, {useCallback, useState} from 'react';
|
||||
import {
|
||||
MenuItem,
|
||||
FormGroup,
|
||||
Button,
|
||||
Intent,
|
||||
} from '@blueprintjs/core';
|
||||
import {Select} from '@blueprintjs/select';
|
||||
// import MultiSelect from 'components/MultiSelect';
|
||||
|
||||
export default function AccountsMultiSelect({
|
||||
accounts,
|
||||
onAccountSelected,
|
||||
error,
|
||||
initialAccount,
|
||||
}) {
|
||||
const [selectedAccount, setSelectedAccount] = useState(null);
|
||||
|
||||
const [selectedAccount, setSelectedAccount] = useState(
|
||||
initialAccount || null
|
||||
);
|
||||
// Account item of select accounts field.
|
||||
const accountItem = useCallback((item, { handleClick, modifiers, query }) => {
|
||||
return (
|
||||
<MenuItem
|
||||
text={item.name}
|
||||
label={item.code}
|
||||
key={item.id}
|
||||
onClick={handleClick} />
|
||||
<MenuItem text={item.name} label={item.code} key={item.id} onClick={handleClick} />
|
||||
);
|
||||
}, []);
|
||||
|
||||
@@ -33,20 +27,17 @@ export default function AccountsMultiSelect({
|
||||
}, [setSelectedAccount, onAccountSelected]);
|
||||
|
||||
return (
|
||||
|
||||
<Select
|
||||
items={accounts}
|
||||
noResults={<MenuItem disabled={true} text='No results.' />}
|
||||
itemRenderer={accountItem}
|
||||
popoverProps={{ minimal: true }}
|
||||
filterable={true}
|
||||
onItemSelect={onAccountSelect}
|
||||
>
|
||||
onItemSelect={onAccountSelect}>
|
||||
<Button
|
||||
rightIcon='caret-down'
|
||||
text={selectedAccount ? selectedAccount.name : 'Select account'}
|
||||
/>
|
||||
</Select>
|
||||
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {useCallback} from 'react';
|
||||
import React, {useCallback, useMemo} from 'react';
|
||||
import AccountsSelectList from 'components/AccountsSelectList';
|
||||
import classNames from 'classnames';
|
||||
import {
|
||||
@@ -20,6 +20,10 @@ const AccountCellRenderer = ({
|
||||
|
||||
const { account_id = false } = (errors[index] || {});
|
||||
|
||||
const initialAccount = useMemo(() =>
|
||||
accounts.find(a => a.id === initialValue),
|
||||
[accounts, initialValue]);
|
||||
|
||||
return (
|
||||
<FormGroup
|
||||
intent={account_id ? Intent.DANGER : ''}
|
||||
@@ -31,7 +35,8 @@ const AccountCellRenderer = ({
|
||||
<AccountsSelectList
|
||||
accounts={accounts}
|
||||
onAccountSelected={handleAccountSelected}
|
||||
error={account_id} />
|
||||
error={account_id}
|
||||
initialAccount={initialAccount} />
|
||||
</FormGroup>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -64,7 +64,9 @@ export default function MoneyFieldGroup({
|
||||
|
||||
const options = useMemo(() => ({
|
||||
prefix, suffix, thousands, decimal, precision,
|
||||
}), []);
|
||||
}), [
|
||||
prefix, suffix, thousands, decimal, precision,
|
||||
]);
|
||||
|
||||
const handleChange = useCallback((event) => {
|
||||
const formatted = formatter(event.target.value, options);
|
||||
@@ -72,12 +74,12 @@ export default function MoneyFieldGroup({
|
||||
|
||||
setState(formatted);
|
||||
onChange && onChange(event, value);
|
||||
}, []);
|
||||
}, [onChange, options]);
|
||||
|
||||
useEffect(() => {
|
||||
const formatted = formatter(value, options);
|
||||
setState(formatted)
|
||||
}, []);
|
||||
}, [value, options, setState]);
|
||||
|
||||
return (
|
||||
<InputGroup
|
||||
|
||||
Reference in New Issue
Block a user