mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
refactor(FE): Show current chick total in recording form
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user