mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
refactoring: customers landing list. refactoring: vendors landing list. refactoring: manual journals landing list.
37 lines
1.1 KiB
JavaScript
37 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import { FastField } from 'formik';
|
|
import classNames from 'classnames';
|
|
import { CLASSES } from 'common/classes';
|
|
import MakeJournalEntriesTable from './MakeJournalEntriesTable';
|
|
import { orderingLinesIndexes, repeatValue } from 'utils';
|
|
|
|
export default function MakeJournalEntriesField({
|
|
defaultRow,
|
|
linesNumber = 4,
|
|
}) {
|
|
return (
|
|
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
|
<FastField name={'entries'}>
|
|
{({ form, field: { value }, meta: { error, touched } }) => (
|
|
<MakeJournalEntriesTable
|
|
onChange={(entries) => {
|
|
form.setFieldValue('entries', entries);
|
|
}}
|
|
entries={value}
|
|
error={error}
|
|
onClickAddNewRow={() => {
|
|
form.setFieldValue('entries', [...value, defaultRow]);
|
|
}}
|
|
onClickClearAllLines={() => {
|
|
form.setFieldValue(
|
|
'entries',
|
|
orderingLinesIndexes([...repeatValue(defaultRow, linesNumber)])
|
|
);
|
|
}}
|
|
/>
|
|
)}
|
|
</FastField>
|
|
</div>
|
|
);
|
|
}
|