mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 22:05:45 +00:00
fix(FE-88): fix project flock data types
This commit is contained in:
@@ -58,7 +58,7 @@ const ProjectFlockForm = ({
|
||||
const [optionsLocation, setOptionsLocation] = useState<OptionType[]>([]);
|
||||
|
||||
const [openSelectKandangs, setOpenSelectKandangs] = useState(
|
||||
initialValues?.kandangs?.length > 0
|
||||
initialValues?.kandangs && initialValues?.kandangs?.length > 0
|
||||
);
|
||||
const [optionsKandang, setOptionsKandang] = useState<Kandang[]>(
|
||||
initialValues?.kandangs ?? []
|
||||
@@ -329,11 +329,11 @@ const ProjectFlockForm = ({
|
||||
: null,
|
||||
flock_id: initialValues?.flock?.id ?? 0,
|
||||
area_id: initialValues?.area?.id ?? 0,
|
||||
category: initialValues?.category,
|
||||
category: initialValues?.category as (NonNullable<"GROWING" | "LAYING" | undefined>),
|
||||
fcr_id: initialValues?.fcr?.id ?? 0,
|
||||
location_id: initialValues?.location?.id ?? 0,
|
||||
period: initialValues?.period ?? '',
|
||||
kandang_ids: initialValues?.kandangs?.map((k: Kandang) => k.id),
|
||||
period: initialValues?.period ?? 0,
|
||||
kandang_ids: initialValues?.kandangs?.map((k: Kandang) => k.id) as (number | undefined)[],
|
||||
};
|
||||
}, [initialValues]);
|
||||
|
||||
@@ -376,13 +376,15 @@ const ProjectFlockForm = ({
|
||||
useEffect(() => {
|
||||
if (formType == 'detail') {
|
||||
formik.setFieldValue('area', {
|
||||
value: initialValues.area.id,
|
||||
label: initialValues.area.name,
|
||||
value: initialValues?.area.id,
|
||||
label: initialValues?.area.name,
|
||||
});
|
||||
formik.setFieldValue('area_id', initialValues.area_id);
|
||||
setSelectedArea(initialValues.area?.id);
|
||||
formik.setFieldValue('area_id', initialValues?.area_id);
|
||||
if(initialValues?.area_id){
|
||||
setSelectedArea(initialValues?.area_id.toString() as string);
|
||||
}
|
||||
|
||||
formik.setFieldValue('period', initialValues.period);
|
||||
formik.setFieldValue('period', initialValues?.period);
|
||||
}
|
||||
}, [initialValues, setSelectedArea, formType]);
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user