mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 06:45:46 +00:00
refactor(FE-435,436): Allow optional kandang and location expenses
This commit is contained in:
@@ -153,7 +153,9 @@ const ExpenseRealizationForm = ({
|
||||
formik.setFieldValue('realizations', []);
|
||||
};
|
||||
|
||||
const kandangsChangeHandler = (kandangs: { id: number; name: string }[]) => {
|
||||
const kandangsChangeHandler = (
|
||||
kandangs: { id?: number; name?: string }[]
|
||||
) => {
|
||||
formik.setFieldTouched('kandangs', true);
|
||||
formik.setFieldValue('kandangs', kandangs);
|
||||
|
||||
@@ -161,6 +163,8 @@ const ExpenseRealizationForm = ({
|
||||
|
||||
// add new realizations
|
||||
kandangs.forEach((kandangItem) => {
|
||||
if (!kandangItem.id) return;
|
||||
|
||||
const isKandangExistInRealization = newRealizations.find(
|
||||
(realizationItem) => realizationItem.kandang_id === kandangItem.id
|
||||
);
|
||||
@@ -181,7 +185,11 @@ const ExpenseRealizationForm = ({
|
||||
});
|
||||
|
||||
// prune realizations
|
||||
const kandangIds = new Set(kandangs.map((kandang) => kandang.id));
|
||||
const kandangIds = new Set(
|
||||
kandangs
|
||||
.map((kandang) => kandang.id)
|
||||
.filter((id): id is number => id !== undefined)
|
||||
);
|
||||
const deletedRealizationsIdx: number[] = [];
|
||||
|
||||
newRealizations.forEach((realization, idx) => {
|
||||
|
||||
Reference in New Issue
Block a user