diff --git a/src/components/ModalSurat.tsx b/src/components/ModalSurat.tsx index 84284c4..d64d4b9 100644 --- a/src/components/ModalSurat.tsx +++ b/src/components/ModalSurat.tsx @@ -1,5 +1,5 @@ import apiFetch from "@/lib/apiFetch"; -import { Flex, Loader, Modal, Text } from "@mantine/core"; +import { Flex, Modal, Progress, Stack, Text } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import html2canvas from "html2canvas"; import jsPDF from "jspdf"; @@ -35,7 +35,7 @@ export default function ModalSurat({ fontSize: "14px", fontFamily: "Times New Roman", }; - const [uploading, setUploading] = useState<"Menyiapkan" | "Mengupload" | "Selesai">("Menyiapkan") + const [uploading, setUploading] = useState<{ text: "Menyiapkan" | "Mengupload" | "Selesai", value: number }>({ text: "Menyiapkan", value: 10 }) const hiddenRef = useRef(null); const { data, mutate, isLoading } = useSWR("surat", () => apiFetch.api.surat.detail.get({ @@ -52,7 +52,7 @@ export default function ModalSurat({ const uploadPdf = async () => { try { if (data && data.data && data.data.surat && (data.data.surat.file == "" || data.data.surat.file == null)) { - setUploading("Mengupload"); + setUploading({ text: "Mengupload", value: 75 }); const element = hiddenRef.current; const canvas = await html2canvas(element, { scale: 2, @@ -95,7 +95,7 @@ export default function ModalSurat({ filename: resImg.data?.filename!, }); - setUploading("Selesai"); + setUploading({ text: "Selesai", value: 100 }); setTimeout(() => { onClose(resUpdate.data?.link); }, 1000) @@ -136,14 +136,24 @@ export default function ModalSurat({ }, }} title={ - -
Preview Surat
+ <> + +
Preview Surat
- + {/* - {uploading} + {uploading.text} + */} -
+ + {uploading.text} - Harap menunggu sampai selesai + + + } >
diff --git a/src/pages/darmasaba/update_data_surat.tsx b/src/pages/darmasaba/update_data_surat.tsx index e983dfc..c40011b 100644 --- a/src/pages/darmasaba/update_data_surat.tsx +++ b/src/pages/darmasaba/update_data_surat.tsx @@ -317,57 +317,60 @@ function SearchData() { } return ( - - - - - } - placeholder="PS-2025-000123" - onChange={(e) => { - setSearchPengajuan(e.target.value); - }} - /> - + <> + + + + + + } + placeholder="PS-2025-000123" + onChange={(e) => { + setSearchPengajuan(e.target.value); + }} + /> + - - - } - placeholder="08123456789" - type="number" - onChange={(e) => { - setSearchPengajuanPhone(e.target.value); - }} - /> - + + + } + placeholder="08123456789" + type="number" + onChange={(e) => { + setSearchPengajuanPhone(e.target.value); + }} + /> + - - - - - + + + + + + ); } @@ -387,6 +390,7 @@ function DataUpdate({ const [dataSyaratDokumen, setDataSyaratDokumen] = useState([]); const [dataPengajuan, setDataPengajuan] = useState({}); const [status, setStatus] = useState(""); + const [loadingFetchData, setLoadingFetchData] = useState(false); const [formSurat, setFormSurat] = useState({ dataPelengkap: [], syaratDokumen: [], @@ -394,6 +398,7 @@ function DataUpdate({ async function fetchData() { try { + setLoadingFetchData(true); const res = await apiFetch.api.pelayanan["detail-data"].post({ nomerPengajuan: noPengajuan, }); @@ -421,6 +426,8 @@ function DataUpdate({ } } catch (error) { console.error("Error fetching data:", error); + } finally { + setLoadingFetchData(false); } } @@ -600,7 +607,7 @@ function DataUpdate({ return ( <> - + {item.type == "enum" ? (