refactor(FE): Allow null for select fields and track id fields

This commit is contained in:
rstubryan
2026-01-12 14:12:12 +07:00
parent 8516929056
commit bf834cf79b
3 changed files with 90 additions and 38 deletions
@@ -25,7 +25,7 @@ interface ExpenseRequestKandangDetailExpenseProps {
location?: {
value: number;
label: string;
};
} | null;
className?: {
wrapper?: string;
};
@@ -59,13 +59,20 @@ const ExpenseRequestKandangDetailExpense: React.FC<
`expense_nonstocks[${kandangExpenseIdx}].cost_items[${expenseIdx}].nonstock`,
val
);
const nonstockId = Array.isArray(val) ? val[0]?.value : val?.value;
formik.setFieldValue(
`expense_nonstocks[${kandangExpenseIdx}].cost_items[${expenseIdx}].nonstock_id`,
nonstockId ?? 0
);
};
const addExpenseItemHandler = (kandangExpenseIdx: number) => {
const newExpensesValue = [
...formik.values.expense_nonstocks[kandangExpenseIdx].cost_items,
{
nonstock: undefined,
nonstock: null,
nonstock_id: 0,
price: undefined,
quantity: undefined,
notes: '',