mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +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;
|
return recordedIds;
|
||||||
}, [existingRecordings, today]);
|
}, [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 unifiedStockProducts = useMemo(() => {
|
||||||
const options: OptionType[] = [];
|
const options: OptionType[] = [];
|
||||||
if (isResponseSuccess(stockProducts) && selectedKandang) {
|
if (isResponseSuccess(stockProducts) && selectedKandang) {
|
||||||
@@ -1436,6 +1463,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
? getProjectFlockBadgeAdornment()
|
? getProjectFlockBadgeAdornment()
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
bottomLabel={
|
||||||
|
currentTotalChickQty
|
||||||
|
? `Jumlah ayam saat ini: ${formatNumber(
|
||||||
|
currentTotalChickQty
|
||||||
|
)}`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user