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 deleteModal = useModal();
|
||||
|
||||
const isRecordingApproved = useCallback((recording?: Recording) => {
|
||||
return (
|
||||
recording?.approval?.action === 'APPROVED' &&
|
||||
recording?.approval?.step_name === 'Disetujui' &&
|
||||
recording?.approval?.step_number === 3
|
||||
);
|
||||
}, []);
|
||||
|
||||
// ===== FORM HANDLERS =====
|
||||
const createRecordingHandler = useCallback(
|
||||
async (
|
||||
@@ -1281,7 +1289,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
Kembali
|
||||
</Button>
|
||||
|
||||
{type === 'detail' && (
|
||||
{type === 'detail' && !isRecordingApproved(initialValues) && (
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Button
|
||||
variant='outline'
|
||||
@@ -2406,7 +2414,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
{/* Action buttons */}
|
||||
<div className='flex flex-row justify-between gap-2 flex-wrap'>
|
||||
{/* Left side - Detail & Edit actions */}
|
||||
{type !== 'add' && (
|
||||
{type !== 'add' && !isRecordingApproved(initialValues) && (
|
||||
<div className='flex flex-row justify-start gap-2'>
|
||||
{type === 'detail' && deleteRecordingClickHandler && (
|
||||
<Button
|
||||
@@ -2561,7 +2569,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
</section>
|
||||
|
||||
{/* ===== MODALS ===== */}
|
||||
{type !== 'add' && (
|
||||
{type !== 'add' && !isRecordingApproved(initialValues) && (
|
||||
<>
|
||||
<ConfirmationModal
|
||||
ref={deleteModal.ref}
|
||||
@@ -2579,40 +2587,42 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
/>
|
||||
|
||||
{/* Approve Confirmation Modal */}
|
||||
{(type as 'add' | 'edit' | 'detail') === 'detail' && (
|
||||
<ConfirmationModal
|
||||
ref={approveModal.ref}
|
||||
type='success'
|
||||
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'success',
|
||||
isLoading: isApproveLoading,
|
||||
onClick: approveHandler,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
|
||||
!isRecordingApproved(initialValues) && (
|
||||
<ConfirmationModal
|
||||
ref={approveModal.ref}
|
||||
type='success'
|
||||
text='Apakah anda yakin ingin menyetujui data Recording ini?'
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'success',
|
||||
isLoading: isApproveLoading,
|
||||
onClick: approveHandler,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Reject Confirmation Modal */}
|
||||
{(type as 'add' | 'edit' | 'detail') === 'detail' && (
|
||||
<ConfirmationModal
|
||||
ref={rejectModal.ref}
|
||||
type='error'
|
||||
text='Apakah anda yakin ingin menolak data Recording ini?'
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'error',
|
||||
isLoading: isRejectLoading,
|
||||
onClick: rejectHandler,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
|
||||
!isRecordingApproved(initialValues) && (
|
||||
<ConfirmationModal
|
||||
ref={rejectModal.ref}
|
||||
type='error'
|
||||
text='Apakah anda yakin ingin menolak data Recording ini?'
|
||||
secondaryButton={{
|
||||
text: 'Tidak',
|
||||
}}
|
||||
primaryButton={{
|
||||
text: 'Ya',
|
||||
color: 'error',
|
||||
isLoading: isRejectLoading,
|
||||
onClick: rejectHandler,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user