This commit is contained in:
hanif salafi 2025-08-07 10:40:19 +07:00
commit 090006fa30
1 changed files with 16 additions and 5 deletions

View File

@ -297,12 +297,11 @@ export default function FormConvertSPIT() {
}; };
const loadDetail = async () => { const loadDetail = async () => {
loading() loading();
try { try {
const response = await detailSPIT(id); const response = await detailSPIT(id);
const details = response?.data?.data; const details = response?.data?.data;
setIsAlreadySaved(details?.isPublish ? true : false) setIsAlreadySaved(details?.isPublish ? true : false);
if (!details) { if (!details) {
throw new Error("Detail not found"); throw new Error("Detail not found");
@ -344,7 +343,7 @@ export default function FormConvertSPIT() {
console.error("Failed to load detail:", error); console.error("Failed to load detail:", error);
throw error; throw error;
} }
close() close();
}; };
const handleCategoryChange = async (categoryId: string) => { const handleCategoryChange = async (categoryId: string) => {
@ -568,6 +567,18 @@ export default function FormConvertSPIT() {
// Form submission // Form submission
const onSubmit = async (data: FormData) => { const onSubmit = async (data: FormData) => {
const pnmhTags = tags.filter((tag) => tag.toLowerCase().includes("pnmh"));
if (pnmhTags.length > 1) {
MySwal.fire({
title: "Error",
text: "Tags penugasan hanya diperbolehkan 1 (satu) saja.",
icon: "error",
confirmButtonColor: "#3085d6",
});
return false;
}
if (!checkPlacement(filePlacements)) { if (!checkPlacement(filePlacements)) {
error("Select File Placement"); error("Select File Placement");
return false; return false;
@ -616,7 +627,7 @@ export default function FormConvertSPIT() {
}).then(() => { }).then(() => {
// router.push("/in/contributor/content/spit"); // router.push("/in/contributor/content/spit");
// router.replace(`${window.location.pathname}?id=${id}`); // router.replace(`${window.location.pathname}?id=${id}`);
loadDetail() loadDetail();
}); });
} catch (error) { } catch (error) {
console.error("Failed to save:", error); console.error("Failed to save:", error);