mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-170,174): refine RecordingTable approval logic and remove unused tooltips
This commit is contained in:
@@ -28,7 +28,6 @@ import Badge from '@/components/Badge';
|
||||
import CheckboxInput from '@/components/input/CheckboxInput';
|
||||
import TextArea from '@/components/input/TextArea';
|
||||
import { BaseApproval, BaseApiResponse } from '@/types/api/api-general';
|
||||
import { router } from 'next/client';
|
||||
|
||||
const RowOptionsMenu = ({
|
||||
type = 'dropdown',
|
||||
@@ -59,15 +58,6 @@ const RowOptionsMenu = ({
|
||||
const isApproved = isRecordingApproved(props.row.original);
|
||||
const isGradingDone = isGradingCompleted(props.row.original);
|
||||
|
||||
const getApprovalTooltip = () => {
|
||||
if (isLayingCategory && !isGradingDone) {
|
||||
return 'Recording LAYING belum bisa disetujui/ditolak karena grading telur belum selesai';
|
||||
}
|
||||
return isGradingDone
|
||||
? 'Recording bisa disetujui karena sudah grading'
|
||||
: 'Recording bisa disetujui';
|
||||
};
|
||||
|
||||
return (
|
||||
<RowOptionsMenuWrapper type={type}>
|
||||
<Button
|
||||
@@ -94,7 +84,6 @@ const RowOptionsMenu = ({
|
||||
color='info'
|
||||
className={`justify-start text-sm`}
|
||||
href={`/production/recording/grading/add?recording_id=${props.row.original.id}`}
|
||||
title={'Lanjut ke proses grading untuk telur konsumsi baik'}
|
||||
>
|
||||
<Icon icon='material-symbols:egg' width={16} height={16} />
|
||||
Grading
|
||||
@@ -106,7 +95,6 @@ const RowOptionsMenu = ({
|
||||
variant='ghost'
|
||||
color='success'
|
||||
className='justify-start text-sm'
|
||||
title={getApprovalTooltip()}
|
||||
>
|
||||
<Icon icon='material-symbols:check' width={16} height={16} />
|
||||
Approve
|
||||
@@ -118,7 +106,6 @@ const RowOptionsMenu = ({
|
||||
variant='ghost'
|
||||
color='error'
|
||||
className='justify-start text-sm'
|
||||
title={getApprovalTooltip()}
|
||||
>
|
||||
<Icon icon='material-symbols:close' width={16} height={16} />
|
||||
Reject
|
||||
@@ -332,10 +319,7 @@ const ApprovalHistoryModal = ({
|
||||
</Badge>
|
||||
</td>
|
||||
<td className='max-w-xs'>
|
||||
<div
|
||||
className='truncate'
|
||||
title={approval.notes || '-'}
|
||||
>
|
||||
<div className='truncate'>
|
||||
{approval.notes || '-'}
|
||||
</div>
|
||||
</td>
|
||||
@@ -541,13 +525,17 @@ const RecordingTable = () => {
|
||||
const recording = recordings.data.find((r) => r.id === id);
|
||||
if (!recording || isRecordingApproved(recording)) return false;
|
||||
|
||||
if (recording.project_flock_category === 'LAYING') {
|
||||
return false;
|
||||
if (recording.project_flock_category === 'GROWING') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return recording.project_flock_category === 'GROWING';
|
||||
if (recording.project_flock_category === 'LAYING') {
|
||||
return isGradingCompleted(recording);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}, [selectedRowIds, recordings, isRecordingApproved]);
|
||||
}, [selectedRowIds, recordings, isRecordingApproved, isGradingCompleted]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isResponseSuccess(recordings) && recordings.data) {
|
||||
@@ -558,12 +546,15 @@ const RecordingTable = () => {
|
||||
const recording = recordings.data.find(
|
||||
(r) => r.id === parseInt(rowId)
|
||||
);
|
||||
if (
|
||||
recording &&
|
||||
recording.project_flock_category === 'GROWING' &&
|
||||
!isRecordingApproved(recording)
|
||||
) {
|
||||
newSelection[rowId] = true;
|
||||
if (recording && !isRecordingApproved(recording)) {
|
||||
if (recording.project_flock_category === 'GROWING') {
|
||||
newSelection[rowId] = true;
|
||||
} else if (
|
||||
recording.project_flock_category === 'LAYING' &&
|
||||
isGradingCompleted(recording)
|
||||
) {
|
||||
newSelection[rowId] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -574,7 +565,13 @@ const RecordingTable = () => {
|
||||
setRowSelection(newSelection);
|
||||
}
|
||||
}
|
||||
}, [recordings, rowSelection, isRecordingApproved, setRowSelection]);
|
||||
}, [
|
||||
recordings,
|
||||
rowSelection,
|
||||
isRecordingApproved,
|
||||
isGradingCompleted,
|
||||
setRowSelection,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className='w-full p-0 sm:p-4'>
|
||||
@@ -604,11 +601,6 @@ const RecordingTable = () => {
|
||||
selectedRowIds.length === 0 || eligibleRowIds.length === 0
|
||||
}
|
||||
className='w-full sm:w-fit'
|
||||
title={
|
||||
eligibleRowIds.length === 0
|
||||
? 'Hanya recording GROWING yang bisa disetujui'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
<Icon icon='material-symbols:check' width={24} height={24} />
|
||||
Approve
|
||||
@@ -625,11 +617,6 @@ const RecordingTable = () => {
|
||||
selectedRowIds.length === 0 || eligibleRowIds.length === 0
|
||||
}
|
||||
className='w-full sm:w-fit'
|
||||
title={
|
||||
eligibleRowIds.length === 0
|
||||
? 'Hanya recording GROWING yang bisa ditolak'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
<Icon icon='material-symbols:close' width={24} height={24} />
|
||||
Reject
|
||||
@@ -717,11 +704,6 @@ const RecordingTable = () => {
|
||||
}
|
||||
onChange={handleSelectAllGrowing}
|
||||
disabled={hasNoSelectableGrowing}
|
||||
title={
|
||||
hasNoSelectableGrowing
|
||||
? 'Tidak ada recording GROWING yang bisa dipilih'
|
||||
: 'Pilih semua recording GROWING'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -736,11 +718,6 @@ const RecordingTable = () => {
|
||||
}
|
||||
|
||||
const isDisabled = !row.getCanSelect() || isApproved;
|
||||
let tooltip = '';
|
||||
|
||||
if (isApproved) {
|
||||
tooltip = 'Recording sudah disetujui final';
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
@@ -750,7 +727,6 @@ const RecordingTable = () => {
|
||||
disabled={isDisabled}
|
||||
indeterminate={row.getIsSomeSelected()}
|
||||
onChange={row.getToggleSelectedHandler()}
|
||||
title={tooltip}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -840,7 +816,6 @@ const RecordingTable = () => {
|
||||
'cursor-pointer hover:opacity-80 transition-opacity whitespace-nowrap',
|
||||
}}
|
||||
onClick={openApprovalHistory}
|
||||
title='Klik untuk lihat riwayat approval'
|
||||
>
|
||||
{getStatusText(approval.action)}
|
||||
</Badge>
|
||||
@@ -854,7 +829,7 @@ const RecordingTable = () => {
|
||||
if (!approval?.notes) return '-';
|
||||
|
||||
return (
|
||||
<div className='max-w-xs' title={approval.notes}>
|
||||
<div className='max-w-xs'>
|
||||
<p className='text-sm truncate'>{approval.notes}</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user