From a094eb94a5ea0ac31a796ccb35fccfb9eb1b499b Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 18:16:34 +0700 Subject: [PATCH 1/7] chore: render see more button conditionally --- src/components/helper/ApprovalStepsV2.tsx | 38 ++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/components/helper/ApprovalStepsV2.tsx b/src/components/helper/ApprovalStepsV2.tsx index 6b731a72..dc21453e 100644 --- a/src/components/helper/ApprovalStepsV2.tsx +++ b/src/components/helper/ApprovalStepsV2.tsx @@ -176,24 +176,26 @@ const ApprovalStepsV2 = ({ })} - + {formattedApprovals.length > maxVisibleSteps && ( + + )} ); }; From 68ccb66e5c40f45c90568ca449de5ac667786c30 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 18:16:41 +0700 Subject: [PATCH 2/7] chore: update TextInput styling --- src/components/input/TextInput.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/input/TextInput.tsx b/src/components/input/TextInput.tsx index da0d4325..2365d73d 100644 --- a/src/components/input/TextInput.tsx +++ b/src/components/input/TextInput.tsx @@ -118,7 +118,7 @@ const TextInput = ({
Date: Tue, 27 Jan 2026 18:17:13 +0700 Subject: [PATCH 3/7] fix: get real max quantity in target project flock kandang --- .../TransferToLayingFormModal.tsx | 64 +++++++++++++++---- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx index 9f71fdc5..3ade0946 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingFormModal.tsx @@ -288,6 +288,48 @@ const TransferToLayingFormModal = () => { return { available: countAvailable, unavailable: countUnavailable }; }, [mappedFlockSourceKandangsAvailability]); + const { + data: flockDestinationKandangsMaxTargetQty, + isLoading: isLoadingFlockDestinationKandangsMaxTargetQty, + } = useSWR( + formik.values.flockDestination + ? [ + 'transfer-to-laying', + 'max-target-qty', + String(formik.values.flockDestination.value), + ] + : undefined, + ([, , id]: string[]) => + TransferToLayingApi.getMappedFlockKandangsMaxTargetQty(Number(id)) + ); + + const mappedFlockDestinationKandangsMaxTargetQty: { + kandang_name: string; + max_target_qty: number; + project_flock_kandang_id: number; + }[] = useMemo(() => { + if ( + !flockDestinationKandangsMaxTargetQty || + !selectedFlockDestinationRawData + ) + return []; + + return selectedFlockDestinationRawData + ? selectedFlockDestinationRawData.kandangs.map((kandang) => { + const maxQty = + flockDestinationKandangsMaxTargetQty[ + kandang.project_flock_kandang_id + ]?.max_target_qty; + + return { + kandang_name: kandang.name, + max_target_qty: maxQty, + project_flock_kandang_id: kandang.project_flock_kandang_id, + }; + }) + : []; + }, [flockDestinationKandangsMaxTargetQty, selectedFlockDestinationRawData]); + const mappedFlockDestinationKandangsAvailabilityInfo: { available: number; unavailable: number; @@ -298,9 +340,8 @@ const TransferToLayingFormModal = () => { let countAvailable = 0; let countUnavailable = 0; - selectedFlockDestinationRawData?.kandangs.forEach((item) => { - // TODO: change this to real available quota later - if (item.capacity > 0) { + mappedFlockDestinationKandangsMaxTargetQty.forEach((item) => { + if (item.max_target_qty > 0) { countAvailable += 1; } else { countUnavailable += 1; @@ -308,7 +349,7 @@ const TransferToLayingFormModal = () => { }); return { available: countAvailable, unavailable: countUnavailable }; - }, [selectedFlockDestinationRawData]); + }, [mappedFlockDestinationKandangsMaxTargetQty]); const totalEnteredChickenForTransfer = formik.values.flockSourceKandangs.reduce( @@ -648,10 +689,9 @@ const TransferToLayingFormModal = () => {
- {selectedFlockDestinationRawData?.kandangs.map( + {mappedFlockDestinationKandangsMaxTargetQty.map( (item, itemIdx) => { - // TODO: change this to real available quota later - const isAvailable = item.capacity > 0; + const isAvailable = item.max_target_qty > 0; const isChecked = formik.values.flockDestinationKandangs.some( (k) => @@ -669,11 +709,10 @@ const TransferToLayingFormModal = () => { { kandang: { value: item.project_flock_kandang_id, - label: item.name, + label: item.kandang_name, }, quantity: '', - // TODO: change this to real available quota later - maxQuantity: item.capacity, + maxQuantity: item.max_target_qty, }, ]); } else { @@ -718,9 +757,8 @@ const TransferToLayingFormModal = () => { 'cursor-not-allowed': !isAvailable, })} > - {item.name}{' '} - {/* TODO: change this to real available quota later */} - {`(Max: ${item.capacity})`} + {item.kandang_name}{' '} + {`(Max: ${item.max_target_qty})`}
From 19a90c90457387e2f7eeb45e467a4e116ce5e98a Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 27 Jan 2026 18:17:34 +0700 Subject: [PATCH 4/7] feat: add search input --- .../TransferToLayingsTable.tsx | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx index f38a932f..7817c427 100644 --- a/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx +++ b/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx @@ -1,6 +1,6 @@ 'use client'; -import { useEffect, useMemo, useState } from 'react'; +import { ChangeEventHandler, useEffect, useMemo, useState } from 'react'; import useSWR from 'swr'; import { CellContext, @@ -33,6 +33,7 @@ import { cn, formatDate, formatNumber } from '@/lib/helper'; import { isResponseError, isResponseSuccess } from '@/lib/api-helper'; import { useTableFilter } from '@/services/hooks/useTableFilter'; import { Color } from '@/types/theme'; +import DebouncedTextInput from '@/components/input/DebouncedTextInput'; const RowOptionsMenu = ({ props, @@ -432,6 +433,10 @@ const TransferToLayingsTable = () => { setIsRejectLoading(false); }; + const searchChangeHandler: ChangeEventHandler = (e) => { + updateFilter('search', e.target.value); + }; + const filterSubmitHandler = (values: TransferToLayingFilter) => { updateFilter('startDate', values.startDate); updateFilter('endDate', values.endDate); @@ -527,7 +532,27 @@ const TransferToLayingsTable = () => { )} -
+
+ + } + className={{ + wrapper: 'w-full min-w-24 max-w-3xs', + inputWrapper: 'rounded-xl! shadow-button-soft', + input: + 'placeholder:font-semibold placeholder:text-base-content/50', + }} + /> +