before killhouses options

This commit is contained in:
2026-02-09 09:22:19 +03:30
parent d39b75200c
commit 7326bf96b0
7 changed files with 236 additions and 322 deletions

View File

@@ -87,7 +87,7 @@ const getInitialValues = (page) => {
return { ...INITIAL_VALUES_BASE, nationalId: "" };
}
if (page === PAGE_ADMIN) {
return { ...INITIAL_VALUES_BASE, role_key: "", type: "" };
return { ...INITIAL_VALUES_BASE, steward_keys: [], kill_house_keys: [] };
}
return { ...INITIAL_VALUES_BASE };
};
@@ -169,19 +169,16 @@ export const StewardAddBuyer = ({
});
}, [formik.values.province, dispatch]);
// Admin: load stewards or kill houses by type
// Admin: load both stewards and kill houses
useEffect(() => {
if (page !== PAGE_ADMIN) return;
if (formik.values.type === "KillHouse") {
dispatch(inspectorGetKillHousesService());
} else {
dispatch(slaughterGetStewardsForAllocateService({ free: true })).then(
(r) => {
setStewards(r.payload?.data ?? []);
}
);
}
}, [page, formik.values.type, dispatch]);
dispatch(inspectorGetKillHousesService());
dispatch(slaughterGetStewardsForAllocateService({ free: true })).then(
(r) => {
setStewards(r.payload?.data ?? []);
}
);
}, [page, dispatch]);
const handleSubmit = useCallback(() => {
if (page === PAGE_STEWARD) {
@@ -315,6 +312,7 @@ export const StewardAddBuyer = ({
isRealPerson={isRealPerson}
killHouses={killHouses}
stewards={stewards}
editData={isEdit ? data : null}
/>
);
}