mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
Merge branch 'hotfix/transfer-to-laying' into 'development'
[HOTFIX/FE] Transfer to Laying See merge request mbugroup/lti-web-client!492
This commit is contained in:
@@ -233,13 +233,8 @@ const TransferToLayingFormModal = () => {
|
|||||||
|
|
||||||
const [maxSourceQuantity, setMaxSourceQuantity] = useState<number>(0);
|
const [maxSourceQuantity, setMaxSourceQuantity] = useState<number>(0);
|
||||||
|
|
||||||
const selectedFlockDestinationRawData = isResponseSuccess(
|
const [selectedFlockDestinationRawData, setSelectedFlockDestinationRawData] =
|
||||||
flockDestinationRawData
|
useState<ProjectFlock | undefined>(undefined);
|
||||||
)
|
|
||||||
? flockDestinationRawData.data.find(
|
|
||||||
(item) => item.id === formik.values.flockDestination?.value
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const { data: flockSourceKandangsAvailability } = useSWR(
|
const { data: flockSourceKandangsAvailability } = useSWR(
|
||||||
formik.values.flockSource
|
formik.values.flockSource
|
||||||
@@ -456,15 +451,37 @@ const TransferToLayingFormModal = () => {
|
|||||||
}, [transferToLayingId, transferToLaying]);
|
}, [transferToLayingId, transferToLaying]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!formik.values.flockSource) {
|
||||||
|
setSelectedFlockSourceRawData(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isResponseSuccess(flockSourceRawData)) {
|
if (isResponseSuccess(flockSourceRawData)) {
|
||||||
const currentSelectedFlockSourceRawData = flockSourceRawData.data.find(
|
const found = flockSourceRawData.data.find(
|
||||||
(item) => item.id === formik.values.flockSource?.value
|
(item) => item.id === formik.values.flockSource?.value
|
||||||
);
|
);
|
||||||
|
if (found) {
|
||||||
setSelectedFlockSourceRawData(currentSelectedFlockSourceRawData);
|
setSelectedFlockSourceRawData(found);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [flockSourceRawData, formikFlockSource]);
|
}, [flockSourceRawData, formikFlockSource]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!formik.values.flockDestination) {
|
||||||
|
setSelectedFlockDestinationRawData(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isResponseSuccess(flockDestinationRawData)) {
|
||||||
|
const found = flockDestinationRawData.data.find(
|
||||||
|
(item) => item.id === formik.values.flockDestination?.value
|
||||||
|
);
|
||||||
|
if (found) {
|
||||||
|
setSelectedFlockDestinationRawData(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [flockDestinationRawData, formik.values.flockDestination]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formik.setFieldValue('totalQuantity', totalTransferedChicken);
|
formik.setFieldValue('totalQuantity', totalTransferedChicken);
|
||||||
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
||||||
|
|||||||
Reference in New Issue
Block a user