mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-170): add approval logic to RecordingForm for detail view actions
This commit is contained in:
@@ -94,6 +94,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
const rejectModal = useModal();
|
const rejectModal = useModal();
|
||||||
const deleteModal = useModal();
|
const deleteModal = useModal();
|
||||||
|
|
||||||
|
const isRecordingApproved = useCallback((recording?: Recording) => {
|
||||||
|
return (
|
||||||
|
recording?.approval?.action === 'APPROVED' &&
|
||||||
|
recording?.approval?.step_name === 'Disetujui' &&
|
||||||
|
recording?.approval?.step_number === 3
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// ===== FORM HANDLERS =====
|
// ===== FORM HANDLERS =====
|
||||||
const createRecordingHandler = useCallback(
|
const createRecordingHandler = useCallback(
|
||||||
async (
|
async (
|
||||||
@@ -1281,7 +1289,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
Kembali
|
Kembali
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{type === 'detail' && (
|
{type === 'detail' && !isRecordingApproved(initialValues) && (
|
||||||
<div className='flex flex-row gap-2'>
|
<div className='flex flex-row gap-2'>
|
||||||
<Button
|
<Button
|
||||||
variant='outline'
|
variant='outline'
|
||||||
@@ -2406,7 +2414,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
{/* Action buttons */}
|
{/* Action buttons */}
|
||||||
<div className='flex flex-row justify-between gap-2 flex-wrap'>
|
<div className='flex flex-row justify-between gap-2 flex-wrap'>
|
||||||
{/* Left side - Detail & Edit actions */}
|
{/* Left side - Detail & Edit actions */}
|
||||||
{type !== 'add' && (
|
{type !== 'add' && !isRecordingApproved(initialValues) && (
|
||||||
<div className='flex flex-row justify-start gap-2'>
|
<div className='flex flex-row justify-start gap-2'>
|
||||||
{type === 'detail' && deleteRecordingClickHandler && (
|
{type === 'detail' && deleteRecordingClickHandler && (
|
||||||
<Button
|
<Button
|
||||||
@@ -2561,7 +2569,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
{/* ===== MODALS ===== */}
|
{/* ===== MODALS ===== */}
|
||||||
{type !== 'add' && (
|
{type !== 'add' && !isRecordingApproved(initialValues) && (
|
||||||
<>
|
<>
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
ref={deleteModal.ref}
|
ref={deleteModal.ref}
|
||||||
@@ -2579,40 +2587,42 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Approve Confirmation Modal */}
|
{/* Approve Confirmation Modal */}
|
||||||
{(type as 'add' | 'edit' | 'detail') === 'detail' && (
|
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
|
||||||
<ConfirmationModal
|
!isRecordingApproved(initialValues) && (
|
||||||
ref={approveModal.ref}
|
<ConfirmationModal
|
||||||
type='success'
|
ref={approveModal.ref}
|
||||||
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
type='success'
|
||||||
secondaryButton={{
|
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
||||||
text: 'Tidak',
|
secondaryButton={{
|
||||||
}}
|
text: 'Tidak',
|
||||||
primaryButton={{
|
}}
|
||||||
text: 'Ya',
|
primaryButton={{
|
||||||
color: 'success',
|
text: 'Ya',
|
||||||
isLoading: isApproveLoading,
|
color: 'success',
|
||||||
onClick: approveHandler,
|
isLoading: isApproveLoading,
|
||||||
}}
|
onClick: approveHandler,
|
||||||
/>
|
}}
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Reject Confirmation Modal */}
|
{/* Reject Confirmation Modal */}
|
||||||
{(type as 'add' | 'edit' | 'detail') === 'detail' && (
|
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
|
||||||
<ConfirmationModal
|
!isRecordingApproved(initialValues) && (
|
||||||
ref={rejectModal.ref}
|
<ConfirmationModal
|
||||||
type='error'
|
ref={rejectModal.ref}
|
||||||
text='Apakah anda yakin ingin menolak data Recording ini?'
|
type='error'
|
||||||
secondaryButton={{
|
text='Apakah anda yakin ingin menolak data Recording ini?'
|
||||||
text: 'Tidak',
|
secondaryButton={{
|
||||||
}}
|
text: 'Tidak',
|
||||||
primaryButton={{
|
}}
|
||||||
text: 'Ya',
|
primaryButton={{
|
||||||
color: 'error',
|
text: 'Ya',
|
||||||
isLoading: isRejectLoading,
|
color: 'error',
|
||||||
onClick: rejectHandler,
|
isLoading: isRejectLoading,
|
||||||
}}
|
onClick: rejectHandler,
|
||||||
/>
|
}}
|
||||||
)}
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user