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 && (
+
+ )}
);
};
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 = ({
{
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})`}
diff --git a/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx b/src/components/pages/production/transfer-to-laying/TransferToLayingsTable.tsx
index f38a932f..438c529c 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,
@@ -182,6 +183,9 @@ const TransferToLayingsTable = () => {
const isFilterActive = filterCount > 0;
+ const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] =
+ useState(false);
+
// Modal hooks
const filterModal = useModal();
const deleteModal = useModal();
@@ -432,6 +436,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);
@@ -448,9 +456,12 @@ const TransferToLayingsTable = () => {
updateFilter('status', '');
};
- // TODO: add export to excel functionality
- const exportToExcelHandler = () => {
- toast.error('Not implemented yet');
+ const exportToExcelHandler = async () => {
+ setIsLoadingExportingToExcel(true);
+
+ await TransferToLayingApi.exportToExcel(getTableFilterQueryString());
+
+ setIsLoadingExportingToExcel(false);
};
useEffect(() => {
@@ -527,7 +538,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',
+ }}
+ />
+