mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
feat(FE-170,175): enhance approval logic and tooltips for LAYING category recordings in RecordingTable
This commit is contained in:
@@ -64,6 +64,15 @@ 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
|
||||
@@ -95,33 +104,25 @@ const RowOptionsMenu = ({
|
||||
Grading
|
||||
</Button>
|
||||
)}
|
||||
{!isApproved && (
|
||||
{!isApproved && !(isLayingCategory && !isGradingDone) && (
|
||||
<Button
|
||||
onClick={approveClickHandler}
|
||||
variant='ghost'
|
||||
color='success'
|
||||
className='justify-start text-sm'
|
||||
title={
|
||||
isGradingDone
|
||||
? 'Recording bisa disetujui karena sudah grading'
|
||||
: 'Recording bisa disetujui'
|
||||
}
|
||||
title={getApprovalTooltip()}
|
||||
>
|
||||
<Icon icon='material-symbols:check' width={16} height={16} />
|
||||
Approve
|
||||
</Button>
|
||||
)}
|
||||
{!isApproved && (
|
||||
{!isApproved && !(isLayingCategory && !isGradingDone) && (
|
||||
<Button
|
||||
onClick={rejectClickHandler}
|
||||
variant='ghost'
|
||||
color='error'
|
||||
className='justify-start text-sm'
|
||||
title={
|
||||
isGradingDone
|
||||
? 'Recording bisa ditolak karena sudah grading'
|
||||
: 'Recording bisa ditolak'
|
||||
}
|
||||
title={getApprovalTooltip()}
|
||||
>
|
||||
<Icon icon='material-symbols:close' width={16} height={16} />
|
||||
Reject
|
||||
@@ -449,7 +450,7 @@ const RecordingTable = () => {
|
||||
return (
|
||||
recording.approval?.action === 'APPROVED' &&
|
||||
recording.approval?.step_name === 'Disetujui' &&
|
||||
recording.approval?.step_number === 3
|
||||
Number(recording.approval?.step_number) === 3
|
||||
);
|
||||
},
|
||||
[]
|
||||
@@ -463,10 +464,11 @@ const RecordingTable = () => {
|
||||
);
|
||||
|
||||
const isGradingCompleted = useCallback((recording: Recording): boolean => {
|
||||
return !!(
|
||||
recording.egg_grading_status === 'COMPLETED' ||
|
||||
(recording.approval?.step_number && recording.approval.step_number >= 1)
|
||||
);
|
||||
if (recording.project_flock_category !== 'LAYING') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return recording.egg_grading_status === 'COMPLETED';
|
||||
}, []);
|
||||
|
||||
const searchChangeHandler = useCallback(
|
||||
@@ -565,9 +567,15 @@ const RecordingTable = () => {
|
||||
if (!isResponseSuccess(recordings) || !recordings.data) return [];
|
||||
return selectedRowIds.filter((id) => {
|
||||
const recording = recordings.data.find((r) => r.id === id);
|
||||
return recording && !isRecordingApproved(recording);
|
||||
if (!recording || isRecordingApproved(recording)) return false;
|
||||
|
||||
if (recording.project_flock_category === 'LAYING') {
|
||||
return isGradingCompleted(recording);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}, [selectedRowIds, recordings, isRecordingApproved]);
|
||||
}, [selectedRowIds, recordings, isRecordingApproved, isGradingCompleted]);
|
||||
|
||||
return (
|
||||
<div className='w-full p-0 sm:p-4'>
|
||||
@@ -599,7 +607,7 @@ const RecordingTable = () => {
|
||||
className='w-full sm:w-fit'
|
||||
title={
|
||||
eligibleRowIds.length === 0
|
||||
? 'Tidak ada Recording yang bisa disetujui (sudah disetujui final)'
|
||||
? 'Tidak ada Recording yang bisa disetujui (sudah disetujui final atau belum grading untuk kategori LAYING)'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
@@ -620,7 +628,7 @@ const RecordingTable = () => {
|
||||
className='w-full sm:w-fit'
|
||||
title={
|
||||
eligibleRowIds.length === 0
|
||||
? 'Tidak ada Recording yang bisa ditolak (sudah disetujui final)'
|
||||
? 'Tidak ada Recording yang bisa ditolak (sudah disetujui final atau belum grading untuk kategori LAYING)'
|
||||
: ''
|
||||
}
|
||||
>
|
||||
@@ -739,7 +747,13 @@ const RecordingTable = () => {
|
||||
const allRows = table.getRowModel().rows;
|
||||
const selectableRows = allRows.filter((row) => {
|
||||
const recording = row.original;
|
||||
return !isRecordingApproved(recording);
|
||||
if (isRecordingApproved(recording)) return false;
|
||||
|
||||
if (recording.project_flock_category === 'LAYING') {
|
||||
return isGradingCompleted(recording);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
const hasOnlyUnselectableRows = selectableRows.length === 0;
|
||||
|
||||
@@ -753,7 +767,7 @@ const RecordingTable = () => {
|
||||
disabled={hasOnlyUnselectableRows}
|
||||
title={
|
||||
hasOnlyUnselectableRows
|
||||
? 'Tidak ada Recording yang bisa dipilih (sudah disetujui final)'
|
||||
? 'Tidak ada Recording yang bisa dipilih (sudah disetujui final atau belum grading untuk kategori LAYING)'
|
||||
: ''
|
||||
}
|
||||
/>
|
||||
@@ -762,9 +776,22 @@ const RecordingTable = () => {
|
||||
},
|
||||
cell: ({ row }) => {
|
||||
const isApproved = isRecordingApproved(row.original);
|
||||
const isDisabled = !row.getCanSelect() || isApproved;
|
||||
const isGradingDone = isGradingCompleted(row.original);
|
||||
const isLayingCategory =
|
||||
row.original.project_flock_category === 'LAYING';
|
||||
|
||||
const isDisabled =
|
||||
!row.getCanSelect() ||
|
||||
isApproved ||
|
||||
(isLayingCategory && !isGradingDone);
|
||||
let tooltip = '';
|
||||
if (isApproved) tooltip = 'Recording sudah disetujui final';
|
||||
|
||||
if (isApproved) {
|
||||
tooltip = 'Recording sudah disetujui final';
|
||||
} else if (isLayingCategory && !isGradingDone) {
|
||||
tooltip =
|
||||
'Recording LAYING belum bisa dipilih karena grading telur belum selesai';
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user