mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
feat(FE-137): implement bulk approval and rejection functionality in RecordingTable with user feedback
This commit is contained in:
@@ -18,7 +18,9 @@ import RowDropdownOptions from '@/components/table/RowDropdownOptions';
|
|||||||
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
import RowCollapseOptions from '@/components/table/RowCollapseOptions';
|
||||||
import { type CellContext } from '@tanstack/react-table';
|
import { type CellContext } from '@tanstack/react-table';
|
||||||
import { type Recording } from '@/types/api/production/recording';
|
import { type Recording } from '@/types/api/production/recording';
|
||||||
|
import { type BaseApiResponse } from '@/types/api/api-general';
|
||||||
import { RecordingApi } from '@/services/api/production';
|
import { RecordingApi } from '@/services/api/production';
|
||||||
|
import { isResponseSuccess, isResponseError } from '@/lib/api-helper';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
const RowOptionsMenu = ({
|
const RowOptionsMenu = ({
|
||||||
@@ -136,22 +138,56 @@ const RecordingTable = () => {
|
|||||||
|
|
||||||
const bulkApproveHandler = async () => {
|
const bulkApproveHandler = async () => {
|
||||||
setIsBulkApproveLoading(true);
|
setIsBulkApproveLoading(true);
|
||||||
console.log('Approved recordings:', selectedRowIds);
|
|
||||||
setTimeout(() => {
|
const approveResponse = await RecordingApi.customRequest<
|
||||||
setIsBulkApproveLoading(false);
|
BaseApiResponse<Recording[]>
|
||||||
|
>('approvals', {
|
||||||
|
method: 'POST',
|
||||||
|
payload: {
|
||||||
|
action: 'APPROVED',
|
||||||
|
approvable_ids: selectedRowIds,
|
||||||
|
notes: 'Bulk Approved',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isResponseSuccess(approveResponse)) {
|
||||||
|
await refreshRecordings();
|
||||||
setRowSelection({});
|
setRowSelection({});
|
||||||
bulkApproveModal.closeModal();
|
bulkApproveModal.closeModal();
|
||||||
}, 1000);
|
toast.success(`Successfully approved ${selectedRowIds.length} recordings!`);
|
||||||
|
}
|
||||||
|
if (isResponseError(approveResponse)) {
|
||||||
|
toast.error(approveResponse?.message as string);
|
||||||
|
bulkApproveModal.closeModal();
|
||||||
|
}
|
||||||
|
setIsBulkApproveLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const bulkRejectHandler = async () => {
|
const bulkRejectHandler = async () => {
|
||||||
setIsBulkRejectLoading(true);
|
setIsBulkRejectLoading(true);
|
||||||
console.log('Rejected recordings:', selectedRowIds);
|
|
||||||
setTimeout(() => {
|
const rejectResponse = await RecordingApi.customRequest<
|
||||||
setIsBulkRejectLoading(false);
|
BaseApiResponse<Recording[]>
|
||||||
|
>('approvals', {
|
||||||
|
method: 'POST',
|
||||||
|
payload: {
|
||||||
|
action: 'REJECTED',
|
||||||
|
approvable_ids: selectedRowIds,
|
||||||
|
notes: 'Bulk Rejected',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isResponseSuccess(rejectResponse)) {
|
||||||
|
refreshRecordings();
|
||||||
setRowSelection({});
|
setRowSelection({});
|
||||||
bulkRejectModal.closeModal();
|
bulkRejectModal.closeModal();
|
||||||
}, 1000);
|
toast.success(`Successfully rejected ${selectedRowIds.length} recordings!`);
|
||||||
|
}
|
||||||
|
if (isResponseError(rejectResponse)) {
|
||||||
|
toast.error(rejectResponse?.message as string);
|
||||||
|
bulkRejectModal.closeModal();
|
||||||
|
}
|
||||||
|
setIsBulkRejectLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const singleDeleteHandler = async () => {
|
const singleDeleteHandler = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user