fix: spit tags edit

This commit is contained in:
Sabda Yagra 2025-08-07 10:31:35 +07:00
parent 54633d8936
commit 74265cb797
1 changed files with 16 additions and 5 deletions

View File

@ -294,12 +294,11 @@ export default function FormConvertSPIT() {
};
const loadDetail = async () => {
loading()
loading();
try {
const response = await detailSPIT(id);
const details = response?.data?.data;
setIsAlreadySaved(details?.isPublish ? true : false)
setIsAlreadySaved(details?.isPublish ? true : false);
if (!details) {
throw new Error("Detail not found");
@ -341,7 +340,7 @@ export default function FormConvertSPIT() {
console.error("Failed to load detail:", error);
throw error;
}
close()
close();
};
const handleCategoryChange = async (categoryId: string) => {
@ -565,6 +564,18 @@ export default function FormConvertSPIT() {
// Form submission
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)) {
error("Select File Placement");
return false;
@ -613,7 +624,7 @@ export default function FormConvertSPIT() {
}).then(() => {
// router.push("/in/contributor/content/spit");
// router.replace(`${window.location.pathname}?id=${id}`);
loadDetail()
loadDetail();
});
} catch (error) {
console.error("Failed to save:", error);