refactor(FE): Improve transition and laying state handling in

RecordingForm
This commit is contained in:
rstubryan
2026-03-09 15:03:42 +07:00
parent ace6633f79
commit 0929461ec5
2 changed files with 17 additions and 9 deletions
@@ -469,17 +469,24 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
// ===== TRANSITION RESTRICTION LOGIC =====
const isTransitionPeriod = useMemo(() => {
return initialValues?.is_transition ?? false;
}, [initialValues]);
return (
initialValues?.is_transition ??
projectFlockKandangLookup?.is_transition ??
false
);
}, [initialValues, projectFlockKandangLookup]);
const recordingRestriction = useMemo(() => {
const isLaying =
initialValues?.is_laying ??
(projectFlockKandangLookup?.project_flock?.category === 'LAYING' ||
projectFlockKandangDetail?.project_flock?.category === 'LAYING' ||
false);
projectFlockKandangLookup?.is_laying ??
projectFlockKandangDetail?.project_flock?.category === 'LAYING' ||
false;
const isTransition = initialValues?.is_transition ?? false;
const isTransition =
initialValues?.is_transition ??
projectFlockKandangLookup?.is_transition ??
false;
const currentIsLaying =
projectFlockKandangDetail?.project_flock?.category === 'LAYING';
@@ -625,9 +632,9 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
const isLayingCategory =
initialValues?.is_laying ??
(projectFlockKandangLookup?.project_flock?.category === 'LAYING' ||
projectFlockKandangDetail?.project_flock?.category === 'LAYING' ||
false);
projectFlockKandangLookup?.is_laying ??
projectFlockKandangDetail?.project_flock?.category === 'LAYING' ||
false;
const isGrowingCategory = !isLayingCategory;
+1
View File
@@ -75,6 +75,7 @@ export type ProjectFlockKandangLookup = {
population: number;
chick_in_date: string;
is_transition: boolean;
is_laying: boolean;
};
export type ProjectFlockAvailableQuantity = {