From 4454eac8afc304001d8ee555cbd2eaaa1eef6000 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Wed, 5 Nov 2025 10:01:07 +0700 Subject: [PATCH] feat(FE-170,175): implement multi-select approval and rejection for recordings in RecordingTable --- .../production/recording/RecordingTable.tsx | 169 +++++++++--------- 1 file changed, 86 insertions(+), 83 deletions(-) diff --git a/src/components/pages/production/recording/RecordingTable.tsx b/src/components/pages/production/recording/RecordingTable.tsx index d84db50e..15fbd2cd 100644 --- a/src/components/pages/production/recording/RecordingTable.tsx +++ b/src/components/pages/production/recording/RecordingTable.tsx @@ -8,7 +8,7 @@ import { cn, formatDate } from '@/lib/helper'; import { useModal } from '@/components/Modal'; import Button from '@/components/Button'; import ConfirmationModal from '@/components/modal/ConfirmationModal'; -import { OptionType } from '@/components/input/SelectInput'; +import { OptionType, useSelect } from '@/components/input/SelectInput'; import SelectInput from '@/components/input/SelectInput'; import DebouncedTextInput from '@/components/input/DebouncedTextInput'; import { ROWS_OPTIONS } from '@/config/constant'; @@ -27,6 +27,9 @@ import toast from 'react-hot-toast'; import Badge from '@/components/Badge'; import CheckboxInput from '@/components/input/CheckboxInput'; import TextArea from '@/components/input/TextArea'; +import { Area } from '@/types/api/master-data/area'; +import { Location } from '@/types/api/master-data/location'; +import { Kandang } from '@/types/api/master-data/kandang'; const RowOptionsMenu = ({ type = 'dropdown', @@ -65,28 +68,18 @@ const RowOptionsMenu = ({ onClick={approveClickHandler} variant='ghost' color='success' - className='justify-start text-sm text-success focus-visible:text-success-content hover:text-success-content' + className='justify-start text-sm' > - + Approve + + {selectedRowIds.length > 0 && ( + <> + + + + + )} { { @@ -346,7 +343,7 @@ const RecordingTable = () => { { @@ -371,7 +368,7 @@ const RecordingTable = () => { { @@ -521,13 +518,17 @@ const RecordingTable = () => { }; const approveClickHandler = () => { - setSelectedRecording(props.row.original); + setRowSelection({ + [String(props.row.original.id)]: true, + }); setApprovalNotes(''); approveModal.openModal(); }; const rejectClickHandler = () => { - setSelectedRecording(props.row.original); + setRowSelection({ + [String(props.row.original.id)]: true, + }); setApprovalNotes(''); rejectModal.openModal(); }; @@ -571,6 +572,8 @@ const RecordingTable = () => { isLoading={isLoading} sorting={sorting} setSorting={setSorting} + rowSelection={rowSelection} + setRowSelection={setRowSelection} className={{ containerClassName: cn({ 'mb-20': @@ -605,13 +608,13 @@ const RecordingTable = () => { setApprovalNotes(''), }} primaryButton={{ - text: 'Ya, Setujui', + text: 'Ya', color: 'success', isLoading: isApproveLoading, onClick: approveHandler, @@ -629,13 +632,13 @@ const RecordingTable = () => { setApprovalNotes(''), }} primaryButton={{ - text: 'Ya, Tolak', + text: 'Ya', color: 'error', isLoading: isRejectLoading, onClick: rejectHandler,