feat: Control selected account from selectedAccountId prop.

feat: Allow to reset form of manual journal and expense.
This commit is contained in:
Ahmed Bouhuolia
2020-07-02 02:50:57 +02:00
parent 2f2b71d24f
commit 985ac3f235
16 changed files with 366 additions and 279 deletions

View File

@@ -267,7 +267,7 @@ function ExpenseForm({
const handleSubmitClick = useCallback(
(payload) => {
setPayload(payload);
formik.handleSubmit();
formik.resetForm();
},
[setPayload, formik],
);
@@ -290,13 +290,30 @@ function ExpenseForm({
[setDeletedFiles, deletedFiles],
);
// Handle click on add a new line/row.
const handleClickAddNewRow = () => {
formik.setFieldValue(
'categories',
orderingCategoriesIndex([...formik.values.categories, defaultCategory]),
);
};
const handleClearAllLines = () => {
formik.setFieldValue(
'categories',
orderingCategoriesIndex([defaultCategory, defaultCategory, defaultCategory, defaultCategory]),
);
}
return (
<div className={'dashboard__insider--expense-form'}>
<div className={'expense-form'}>
<form onSubmit={formik.handleSubmit}>
<ExpenseFormHeader formik={formik} />
<ExpenseTable
initialValues={initialValues}
categories={formik.values.categories}
onClickAddNewRow={handleClickAddNewRow}
onClickClearAllLines={handleClearAllLines}
formik={formik}
defaultRow={defaultCategory}
/>