This commit is contained in:
hanif salafi 2025-09-17 11:11:37 +07:00
commit e03bd4a878
1 changed files with 49 additions and 4 deletions

View File

@ -272,6 +272,47 @@ const DetailImage = (data: any) => {
// }
// };
// const handleDownload = () => {
// if (downloadProgress !== 0) return;
// if (!imageSizeSelected) {
// alert("Please select an image size before downloading.");
// return;
// }
// if (!userId) {
// router.push("/auth");
// return;
// }
// sendActivityLog(2);
// sendActivityLog(3);
// if (isDownloadAll) {
// const baseId = slug.split("-")?.[0];
// const url = `${process.env.NEXT_PUBLIC_API}/media/file/download-zip?id=${baseId}&resolution=${imageSizeSelected}`;
// downloadFile(url, "FileDownload.zip");
// } else {
// const selectedFile = detailDataImage?.files?.[selectedImage];
// if (!selectedFile) {
// toast({
// description: "Gambar tidak ditemukan.",
// variant: "destructive",
// });
// return;
// }
// if (isFromSPIT && main?.url?.includes("spit.humas")) {
// // downloadFile(selectedFile.url, selectedFile.names || "image.jpg");
// downloadFile(`${main?.url}`, `${main.names}`);
// } else {
// const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${selectedFile.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
// downloadFile(`${main?.url}`, `${main.names}`);
// }
// }
// };
const handleDownload = () => {
if (downloadProgress !== 0) return;
@ -303,12 +344,16 @@ const DetailImage = (data: any) => {
return;
}
if (isFromSPIT && main?.url?.includes("spit.humas")) {
// downloadFile(selectedFile.url, selectedFile.names || "image.jpg");
downloadFile(`${main?.url}`, `${main.names}`);
if (isFromSPIT && selectedFile?.url?.includes("spit.humas")) {
// ambil url asli dari SPIT, tapi nama file dari judul (main.names)
downloadFile(
selectedFile.url,
main?.names || detailDataImage?.title || "image"
);
} else {
const url = `${process.env.NEXT_PUBLIC_API}/media/view?id=${selectedFile.id}&operation=file&type=image&resolution=${imageSizeSelected}`;
downloadFile(`${main?.url}`, `${main.names}`);
// ambil file sesuai yang dipilih, nama tetap dari judul (main.names)
downloadFile(url, main?.names || detailDataImage?.title || "image");
}
}
};