refactor(FE): Treat kandang_id as optional and use expense id

This commit is contained in:
rstubryan
2026-01-28 12:19:36 +07:00
parent 15dc04bb95
commit 8671f37ada
2 changed files with 20 additions and 3 deletions
@@ -73,7 +73,14 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema<ExpenseRealizationFo
realizations: Yup.array()
.of(
Yup.object({
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').optional(),
kandang_id: Yup.number()
.optional()
.test('valid-kandang-id', 'Wajib memilih kandang!', (value) => {
if (value === undefined || value === null || value === 0) {
return true;
}
return value >= 1;
}),
cost_items: Yup.array()
.of(
Yup.object({
@@ -175,7 +182,7 @@ export const getExpenseRealizationFormInitialValues = (
: [];
return {
kandang_id: kandangExpense.kandang_id,
kandang_id: kandangExpense.id,
cost_items: costItemsInitialValue,
};
})