mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +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 isApproved = isRecordingApproved(props.row.original);
|
||||||
const isGradingDone = isGradingCompleted(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 (
|
return (
|
||||||
<RowOptionsMenuWrapper type={type}>
|
<RowOptionsMenuWrapper type={type}>
|
||||||
<Button
|
<Button
|
||||||
@@ -95,33 +104,25 @@ const RowOptionsMenu = ({
|
|||||||
Grading
|
Grading
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!isApproved && (
|
{!isApproved && !(isLayingCategory && !isGradingDone) && (
|
||||||
<Button
|
<Button
|
||||||
onClick={approveClickHandler}
|
onClick={approveClickHandler}
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
color='success'
|
color='success'
|
||||||
className='justify-start text-sm'
|
className='justify-start text-sm'
|
||||||
title={
|
title={getApprovalTooltip()}
|
||||||
isGradingDone
|
|
||||||
? 'Recording bisa disetujui karena sudah grading'
|
|
||||||
: 'Recording bisa disetujui'
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:check' width={16} height={16} />
|
<Icon icon='material-symbols:check' width={16} height={16} />
|
||||||
Approve
|
Approve
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
{!isApproved && (
|
{!isApproved && !(isLayingCategory && !isGradingDone) && (
|
||||||
<Button
|
<Button
|
||||||
onClick={rejectClickHandler}
|
onClick={rejectClickHandler}
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
color='error'
|
color='error'
|
||||||
className='justify-start text-sm'
|
className='justify-start text-sm'
|
||||||
title={
|
title={getApprovalTooltip()}
|
||||||
isGradingDone
|
|
||||||
? 'Recording bisa ditolak karena sudah grading'
|
|
||||||
: 'Recording bisa ditolak'
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Icon icon='material-symbols:close' width={16} height={16} />
|
<Icon icon='material-symbols:close' width={16} height={16} />
|
||||||
Reject
|
Reject
|
||||||
@@ -449,7 +450,7 @@ const RecordingTable = () => {
|
|||||||
return (
|
return (
|
||||||
recording.approval?.action === 'APPROVED' &&
|
recording.approval?.action === 'APPROVED' &&
|
||||||
recording.approval?.step_name === 'Disetujui' &&
|
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 => {
|
const isGradingCompleted = useCallback((recording: Recording): boolean => {
|
||||||
return !!(
|
if (recording.project_flock_category !== 'LAYING') {
|
||||||
recording.egg_grading_status === 'COMPLETED' ||
|
return true;
|
||||||
(recording.approval?.step_number && recording.approval.step_number >= 1)
|
}
|
||||||
);
|
|
||||||
|
return recording.egg_grading_status === 'COMPLETED';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const searchChangeHandler = useCallback(
|
const searchChangeHandler = useCallback(
|
||||||
@@ -565,9 +567,15 @@ const RecordingTable = () => {
|
|||||||
if (!isResponseSuccess(recordings) || !recordings.data) return [];
|
if (!isResponseSuccess(recordings) || !recordings.data) return [];
|
||||||
return selectedRowIds.filter((id) => {
|
return selectedRowIds.filter((id) => {
|
||||||
const recording = recordings.data.find((r) => r.id === 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 (
|
return (
|
||||||
<div className='w-full p-0 sm:p-4'>
|
<div className='w-full p-0 sm:p-4'>
|
||||||
@@ -599,7 +607,7 @@ const RecordingTable = () => {
|
|||||||
className='w-full sm:w-fit'
|
className='w-full sm:w-fit'
|
||||||
title={
|
title={
|
||||||
eligibleRowIds.length === 0
|
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'
|
className='w-full sm:w-fit'
|
||||||
title={
|
title={
|
||||||
eligibleRowIds.length === 0
|
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 allRows = table.getRowModel().rows;
|
||||||
const selectableRows = allRows.filter((row) => {
|
const selectableRows = allRows.filter((row) => {
|
||||||
const recording = row.original;
|
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;
|
const hasOnlyUnselectableRows = selectableRows.length === 0;
|
||||||
|
|
||||||
@@ -753,7 +767,7 @@ const RecordingTable = () => {
|
|||||||
disabled={hasOnlyUnselectableRows}
|
disabled={hasOnlyUnselectableRows}
|
||||||
title={
|
title={
|
||||||
hasOnlyUnselectableRows
|
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 }) => {
|
cell: ({ row }) => {
|
||||||
const isApproved = isRecordingApproved(row.original);
|
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 = '';
|
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 (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user