refactor(FE): Show current chick total in recording form

This commit is contained in:
rstubryan
2026-01-14 21:39:38 +07:00
parent 4137683d05
commit b290f7692a
@@ -570,6 +570,33 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
return recordedIds;
}, [existingRecordings, today]);
const currentTotalChickQty = useMemo(() => {
if (!isResponseSuccess(existingRecordings) || !selectedKandang) return null;
let projectFlockKandangId: number | undefined;
if (projectFlockKandangLookup) {
projectFlockKandangId =
projectFlockKandangLookup.project_flock_kandang_id;
} else if (projectFlockKandangDetail) {
projectFlockKandangId = projectFlockKandangDetail.id;
}
if (!projectFlockKandangId) return null;
const recording = existingRecordings.data.find(
(rec) =>
rec.project_flock.project_flock_kandang_id === projectFlockKandangId
);
return recording?.project_flock.total_chick_qty || null;
}, [
existingRecordings,
selectedKandang,
projectFlockKandangLookup,
projectFlockKandangDetail,
]);
const unifiedStockProducts = useMemo(() => {
const options: OptionType[] = [];
if (isResponseSuccess(stockProducts) && selectedKandang) {
@@ -1436,6 +1463,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
? getProjectFlockBadgeAdornment()
: undefined
}
bottomLabel={
currentTotalChickQty
? `Jumlah ayam saat ini: ${formatNumber(
currentTotalChickQty
)}`
: undefined
}
/>
</>
</div>