mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE): Parse recordingId and hide actions for rejected
This commit is contained in:
@@ -14,7 +14,7 @@ const RecordingEdit = () => {
|
||||
|
||||
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
||||
recordingId,
|
||||
(id: number) => RecordingApi.getSingle(id) // Gunakan RecordingApi
|
||||
(id: string) => RecordingApi.getSingle(parseInt(id))
|
||||
);
|
||||
|
||||
if (!recordingId) {
|
||||
|
||||
@@ -14,7 +14,7 @@ const RecordingDetail = () => {
|
||||
|
||||
const { data: recording, isLoading: isLoadingRecording } = useSWR(
|
||||
recordingId,
|
||||
(id: number) => RecordingApi.getSingle(id)
|
||||
(id: string) => RecordingApi.getSingle(parseInt(id))
|
||||
);
|
||||
|
||||
if (!recordingId) {
|
||||
|
||||
@@ -50,7 +50,12 @@ const RowOptionsMenu = ({
|
||||
);
|
||||
};
|
||||
|
||||
const isRecordingRejected = (recording: Recording) => {
|
||||
return recording.approval?.action === 'REJECTED';
|
||||
};
|
||||
|
||||
const isApproved = isRecordingApproved(props.row.original);
|
||||
const isRejected = isRecordingRejected(props.row.original);
|
||||
|
||||
return (
|
||||
<RowOptionsMenuWrapper type={type}>
|
||||
@@ -72,7 +77,7 @@ const RowOptionsMenu = ({
|
||||
<Icon icon='mdi:pencil-outline' width={16} height={16} />
|
||||
Edit
|
||||
</Button>
|
||||
{!isApproved && (
|
||||
{!isApproved && !isRejected && (
|
||||
<Button
|
||||
onClick={approveClickHandler}
|
||||
variant='ghost'
|
||||
@@ -83,7 +88,7 @@ const RowOptionsMenu = ({
|
||||
Approve
|
||||
</Button>
|
||||
)}
|
||||
{!isApproved && (
|
||||
{!isApproved && !isRejected && (
|
||||
<Button
|
||||
onClick={rejectClickHandler}
|
||||
variant='ghost'
|
||||
|
||||
@@ -112,6 +112,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
);
|
||||
}, []);
|
||||
|
||||
const isRecordingRejected = useCallback((recording?: Recording) => {
|
||||
return recording?.approval?.action === 'REJECTED';
|
||||
}, []);
|
||||
|
||||
// ===== PAYLOAD CREATION HELPERS =====
|
||||
const createGrowingPayload = useCallback(
|
||||
(values: RecordingGrowingFormValues) => {
|
||||
@@ -1483,7 +1487,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
Kembali
|
||||
</Button>
|
||||
|
||||
{type === 'detail' && !isRecordingApproved(initialValues) && (
|
||||
{type === 'detail' &&
|
||||
initialValues?.approval &&
|
||||
!isRecordingApproved(initialValues) &&
|
||||
!isRecordingRejected(initialValues) && (
|
||||
<div className='flex flex-row gap-2'>
|
||||
<Button
|
||||
variant='outline'
|
||||
@@ -1495,7 +1502,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
isLoading={isApproveLoading}
|
||||
className='w-full sm:w-fit'
|
||||
>
|
||||
<Icon icon='material-symbols:check' width={24} height={24} />
|
||||
<Icon
|
||||
icon='material-symbols:check'
|
||||
width={24}
|
||||
height={24}
|
||||
/>
|
||||
Approve
|
||||
</Button>
|
||||
|
||||
@@ -1509,7 +1520,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
isLoading={isRejectLoading}
|
||||
className='w-full sm:w-fit'
|
||||
>
|
||||
<Icon icon='material-symbols:close' width={24} height={24} />
|
||||
<Icon
|
||||
icon='material-symbols:close'
|
||||
width={24}
|
||||
height={24}
|
||||
/>
|
||||
Reject
|
||||
</Button>
|
||||
</div>
|
||||
@@ -2803,7 +2818,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
|
||||
{/* Approve Confirmation Modal */}
|
||||
{(type as 'add' | 'edit' | 'detail') === 'detail' &&
|
||||
!isRecordingApproved(initialValues) && (
|
||||
!isRecordingApproved(initialValues) &&
|
||||
!isRecordingRejected(initialValues) && (
|
||||
<ConfirmationModalWithNotes
|
||||
ref={approveModal.ref}
|
||||
type='success'
|
||||
|
||||
Reference in New Issue
Block a user