update: add function for update status after click button finish on file index lazy
This commit is contained in:
parent
666ef86756
commit
408033e4db
|
|
@ -14,6 +14,7 @@ import {
|
|||
} from "@mantine/core";
|
||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||
import {
|
||||
submitAssessmentMutationOptions,
|
||||
uploadFileMutationOptions,
|
||||
submitValidationMutationOptions,
|
||||
submitOptionMutationOptions,
|
||||
|
|
@ -130,13 +131,23 @@ export default function AssessmentPage() {
|
|||
}
|
||||
}, [aspectsQuery.data, selectedSubAspectId, data?.data]);
|
||||
|
||||
const handleConfirmFinish = () => {
|
||||
if (assessmentId) {
|
||||
// Menggunakan history.pushState untuk mengubah URL tanpa reload
|
||||
const handleConfirmFinish = async (assessmentId: string) => {
|
||||
try {
|
||||
// Memanggil mutation untuk mengubah status asesmen menjadi 'selesai' di backend
|
||||
const mutation = submitAssessmentMutationOptions(assessmentId);
|
||||
|
||||
const response = await mutation.mutationFn();
|
||||
|
||||
// Setelah status diubah, navigasikan ke halaman hasil asesmen
|
||||
const newUrl = `/assessmentResult?id=${assessmentId}`;
|
||||
window.history.pushState({}, "", newUrl);
|
||||
// Setelah mengubah URL, Anda bisa menjalankan logika lain jika diperlukan
|
||||
console.log("Navigated to:", newUrl);
|
||||
console.log(response.message);
|
||||
} catch (error) {
|
||||
console.error("Error finishing assessment:", error);
|
||||
} finally {
|
||||
setModalOpen(false); // Menutup modal setelah selesai
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user