mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE): Improve transition and laying state handling in
RecordingForm
This commit is contained in:
@@ -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
@@ -75,6 +75,7 @@ export type ProjectFlockKandangLookup = {
|
||||
population: number;
|
||||
chick_in_date: string;
|
||||
is_transition: boolean;
|
||||
is_laying: boolean;
|
||||
};
|
||||
|
||||
export type ProjectFlockAvailableQuantity = {
|
||||
|
||||
Reference in New Issue
Block a user