before killhouses options
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user