@@ -1564,19 +1594,19 @@ export default function FormAudio() {
? isAllChecked
: field.value.includes(option.id);
- const handleChange = () => {
+ const handleChange = (checked: boolean) => {
let updated: string[] = [];
if (option.id === "all") {
- updated = isAllChecked
- ? []
- : options
+ updated = checked
+ ? options
.filter((opt: any) => opt.id !== "all")
- .map((opt: any) => opt.id);
+ .map((opt: any) => opt.id)
+ : [];
} else {
- updated = isChecked
- ? field.value.filter((val) => val !== option.id)
- : [...field.value, option.id];
+ updated = checked
+ ? [...field.value, option.id]
+ : field.value.filter((val) => val !== option.id);
if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all");
@@ -1587,17 +1617,47 @@ export default function FormAudio() {
setPublishedFor(updated);
};
+ // const handleChange = () => {
+ // let updated: string[] = [];
+
+ // if (option.id === "all") {
+ // updated = isAllChecked
+ // ? []
+ // : options
+ // .filter((opt: any) => opt.id !== "all")
+ // .map((opt: any) => opt.id);
+ // } else {
+ // updated = isChecked
+ // ? field.value.filter((val) => val !== option.id)
+ // : [...field.value, option.id];
+
+ // if (isAllChecked && option.id !== "all") {
+ // updated = updated.filter((val) => val !== "all");
+ // }
+ // }
+
+ // field.onChange(updated);
+ // setPublishedFor(updated);
+ // };
+
return (
- handleChange(e.target.checked)}
+ className="h-4 w-4 border border-gray-300 rounded text-blue-600 focus:ring-blue-500"
+ />
+ {/*
+ /> */}
);
diff --git a/components/form/content/audio/audio-update-form.tsx b/components/form/content/audio/audio-update-form.tsx
index 191ff16..a3e63e1 100644
--- a/components/form/content/audio/audio-update-form.tsx
+++ b/components/form/content/audio/audio-update-form.tsx
@@ -71,12 +71,12 @@ const audioSchema = z.object({
"audio/x-wav",
"audio/mp4",
"audio/aac",
- ].includes(file.type) && file.size <= 20 * 1024 * 1024
+ ].includes(file.type) && file.size <= 20 * 1024 * 1024,
),
{
message:
"Hanya file audio (.mp3, .wav, .m4a, .aac) dengan ukuran maksimal 20MB yang diperbolehkan.",
- }
+ },
),
publishedFor: z
@@ -118,7 +118,7 @@ const CustomEditor = dynamic(
() => {
return import("@/components/editor/custom-editor");
},
- { ssr: false }
+ { ssr: false },
);
export default function FormAudioUpdate() {
@@ -232,7 +232,7 @@ export default function FormAudioUpdate() {
const handleEditTag = (index: number, newValue: string) => {
setTags((prevTags) =>
- prevTags.map((tag, i) => (i === index ? newValue : tag))
+ prevTags.map((tag, i) => (i === index ? newValue : tag)),
);
};
@@ -283,7 +283,7 @@ export default function FormAudioUpdate() {
const filesData = details.files || [];
const fileUrls = filesData.map((file: { secondaryUrl: string }) =>
- file.secondaryUrl ? file.secondaryUrl : "default-image.jpg"
+ file.secondaryUrl ? file.secondaryUrl : "default-image.jpg",
);
setDetailThumb(fileUrls);
}
@@ -310,7 +310,7 @@ export default function FormAudioUpdate() {
.filter(Boolean);
const allSelected = ["nasional", "wilayah", "internasional"].every((opt) =>
- options.includes(opt)
+ options.includes(opt),
);
return allSelected ? ["all", ...options] : options;
@@ -323,12 +323,12 @@ export default function FormAudioUpdate() {
.filter((opt) => opt.id !== "all")
.map((opt) => opt.id);
setPublishedFor(
- publishedFor.length === allOptions.length ? [] : allOptions
+ publishedFor.length === allOptions.length ? [] : allOptions,
);
} else {
// Toggle individual option
setPublishedFor((prev) =>
- prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id]
+ prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id],
);
}
};
@@ -352,20 +352,31 @@ export default function FormAudioUpdate() {
// isYoutube: false,
// isInternationalMedia: false,
// };
+
const payload = {
- aiArticleId: detail?.aiArticleId ?? "",
- categoryIds: selectedCategory ?? "",
- createdById: detail?.createdById ?? "",
+ aiArticleId: detail.aiArticleId,
+ categoryIds: selectedCategory,
description: htmlToString(data.description),
htmlDescription: data.description,
- isDraft: false,
- isPublish: true,
- slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
- statusId: detail?.statusId ?? 1,
tags: tags.join(","),
title: data.title,
- typeId: detail?.typeId ?? 4,
+ typeId: detail.typeId,
+ slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
};
+ // const payload = {
+ // aiArticleId: detail?.aiArticleId ?? "",
+ // categoryIds: selectedCategory ?? "",
+ // createdById: detail?.createdById ?? "",
+ // description: htmlToString(data.description),
+ // htmlDescription: data.description,
+ // isDraft: false,
+ // isPublish: true,
+ // slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
+ // statusId: detail?.statusId ?? 1,
+ // tags: tags.join(","),
+ // title: data.title,
+ // typeId: detail?.typeId ?? 4,
+ // };
const res = await updateArticle(Number(id), payload);
if (res?.error) {
@@ -421,7 +432,7 @@ export default function FormAudioUpdate() {
idx: number,
id: string,
file: any,
- duration: string
+ duration: string,
) {
console.log(idx, id, file, duration);
@@ -458,7 +469,7 @@ export default function FormAudioUpdate() {
onChunkComplete: (
chunkSize: any,
bytesAccepted: any,
- bytesTotal: any
+ bytesTotal: any,
) => {
const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100);
progressInfo[idx].percentage = uploadPersen;
@@ -614,7 +625,7 @@ export default function FormAudioUpdate() {
// If all individual options are selected, include "all" automatically
const isAllSelected = ["nasional", "wilayah", "internasional"].every(
- (opt) => updatedSelections.includes(opt)
+ (opt) => updatedSelections.includes(opt),
);
return {
...prev,
@@ -667,7 +678,7 @@ export default function FormAudioUpdate() {
// Jika berhasil, hapus file dari state lokal
setFiles((prevFiles: any) =>
- prevFiles.filter((file: any) => file.id !== id)
+ prevFiles.filter((file: any) => file.id !== id),
);
success();
} catch (err) {
@@ -812,7 +823,7 @@ export default function FormAudioUpdate() {
) : (
<>
{(Math.round(file.size / 100) / 10).toFixed(
- 1
+ 1,
)}
>
)}
@@ -1029,13 +1040,13 @@ export default function FormAudioUpdate() {
} else {
updated = isChecked
? field.value.filter(
- (val) => val !== option.id
+ (val) => val !== option.id,
)
: [...field.value, option.id];
if (isAllChecked && option.id !== "all") {
updated = updated.filter(
- (val) => val !== "all"
+ (val) => val !== "all",
);
}
}
diff --git a/components/form/content/document/teks-form.tsx b/components/form/content/document/teks-form.tsx
index 952bf65..40216d2 100644
--- a/components/form/content/document/teks-form.tsx
+++ b/components/form/content/document/teks-form.tsx
@@ -73,7 +73,7 @@ const CustomEditor = dynamic(
() => {
return import("@/components/editor/custom-editor");
},
- { ssr: false }
+ { ssr: false },
);
type Option = {
@@ -114,7 +114,7 @@ export default function FormTeks() {
const [isGeneratedArticle, setIsGeneratedArticle] = useState(false);
const [articleBody, setArticleBody] = useState
("");
const [selectedArticleId, setSelectedArticleId] = useState(
- null
+ null,
);
const [isContentRewriteClicked, setIsContentRewriteClicked] = useState(false);
const [showRewriteEditor, setShowRewriteEditor] = useState(false);
@@ -168,13 +168,13 @@ export default function FormTeks() {
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
- ].includes(file.type) && file.size <= 20 * 1024 * 1024
+ ].includes(file.type) && file.size <= 20 * 1024 * 1024,
);
const filesWithPreview = filtered.map((file) =>
Object.assign(file, {
preview: URL.createObjectURL(file),
- })
+ }),
);
setFiles(filesWithPreview);
@@ -200,12 +200,12 @@ export default function FormTeks() {
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"text/plain",
- ].includes(file.type) && file.size <= 100 * 1024 * 1024
+ ].includes(file.type) && file.size <= 100 * 1024 * 1024,
),
{
message:
"Hanya file .pdf, .doc, .docx, .txt, maksimal 100MB yang diperbolehkan.",
- }
+ },
),
categoryId: z.string().min(1, { message: "Kategori wajib dipilih." }),
tags: z
@@ -420,7 +420,7 @@ export default function FormTeks() {
const articleData = await waitForStatusUpdate();
const cleanArticleBody = articleData?.articleBody?.replace(
/
]*>/g,
- ""
+ "",
);
const articleImagesData = articleData?.imagesUrl?.split(",");
setArticleBody(cleanArticleBody || "");
@@ -500,7 +500,7 @@ export default function FormTeks() {
if (scheduleId && scheduleType === "3") {
const findCategory = resCategory.find((o) =>
- o.name.toLowerCase().includes("pers rilis")
+ o.name.toLowerCase().includes("pers rilis"),
);
if (findCategory) {
@@ -533,7 +533,7 @@ export default function FormTeks() {
setPublishedFor(
options
.filter((opt: any) => opt.id !== "all")
- .map((opt: any) => opt.id)
+ .map((opt: any) => opt.id),
);
}
} else {
@@ -572,8 +572,8 @@ export default function FormTeks() {
const finalDescription = isSwitchOn
? data.description
: selectedFileType === "rewrite"
- ? data.rewriteDescription
- : data.descriptionOri;
+ ? data.rewriteDescription
+ : data.descriptionOri;
if (!finalDescription?.trim()) {
MySwal.fire("Error", "Deskripsi tidak boleh kosong.", "error");
@@ -637,10 +637,10 @@ export default function FormTeks() {
if (id == undefined) {
const articleData: CreateArticleData = {
- aiArticleId: 0,
+ aiArticleId: 0,
categoryIds: selectedCategory.toString(),
- createdAt: formatDateForBackend(new Date()),
- createdById: Number(userId),
+ createdAt: formatDateForBackend(new Date()),
+ createdById: Number(userId),
description: htmlToString(finalDescription),
htmlDescription: finalDescription,
isDraft: true,
@@ -652,7 +652,7 @@ export default function FormTeks() {
.replace(/[^a-z0-9-]/g, ""),
tags: finalTags,
title: finalTitle,
- typeId: 3,
+ typeId: 3,
};
const response = await createArticle(articleData);
console.log("Article Data Submitted:", articleData);
@@ -662,7 +662,7 @@ export default function FormTeks() {
MySwal.fire(
"Error",
response.message || "Failed to create article",
- "error"
+ "error",
);
return false;
}
@@ -686,7 +686,7 @@ export default function FormTeks() {
MySwal.fire(
"Error",
uploadResponse.message || "Failed to upload files",
- "error"
+ "error",
);
return false;
}
@@ -702,18 +702,18 @@ export default function FormTeks() {
try {
const thumbnailResponse = await uploadArticleThumbnail(
articleId,
- thumbnailFormData
+ thumbnailFormData,
);
if (thumbnailResponse?.error) {
console.warn(
"Thumbnail upload failed:",
- thumbnailResponse.message
+ thumbnailResponse.message,
);
} else {
console.log(
"Thumbnail uploaded successfully:",
- thumbnailResponse
+ thumbnailResponse,
);
}
} catch (thumbnailError) {
@@ -725,7 +725,7 @@ export default function FormTeks() {
MySwal.fire(
"Error",
"Failed to upload files. Please try again.",
- "error"
+ "error",
);
return false;
}
@@ -767,7 +767,7 @@ export default function FormTeks() {
idx: number,
id: string,
file: any,
- duration: string
+ duration: string,
) {
console.log(idx, id, file, duration);
@@ -804,7 +804,7 @@ export default function FormTeks() {
onChunkComplete: (
chunkSize: any,
bytesAccepted: any,
- bytesTotal: any
+ bytesTotal: any,
) => {
const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100);
progressInfo[idx].percentage = uploadPersen;
@@ -1036,6 +1036,36 @@ export default function FormTeks() {
+
+
+ {/*
-
+
*/}
{isSwitchOn && (
@@ -1517,19 +1547,42 @@ export default function FormTeks() {
? isAllChecked
: field.value.includes(option.id);
- const handleChange = () => {
+ // const handleChange = () => {
+ // let updated: string[] = [];
+
+ // if (option.id === "all") {
+ // updated = isAllChecked
+ // ? []
+ // : options
+ // .filter((opt: any) => opt.id !== "all")
+ // .map((opt: any) => opt.id);
+ // } else {
+ // updated = isChecked
+ // ? field.value.filter((val) => val !== option.id)
+ // : [...field.value, option.id];
+
+ // if (isAllChecked && option.id !== "all") {
+ // updated = updated.filter((val) => val !== "all");
+ // }
+ // }
+
+ // field.onChange(updated);
+ // setPublishedFor(updated);
+ // };
+
+ const handleChange = (checked: boolean) => {
let updated: string[] = [];
if (option.id === "all") {
- updated = isAllChecked
- ? []
- : options
+ updated = checked
+ ? options
.filter((opt: any) => opt.id !== "all")
- .map((opt: any) => opt.id);
+ .map((opt: any) => opt.id)
+ : [];
} else {
- updated = isChecked
- ? field.value.filter((val) => val !== option.id)
- : [...field.value, option.id];
+ updated = checked
+ ? [...field.value, option.id]
+ : field.value.filter((val) => val !== option.id);
if (isAllChecked && option.id !== "all") {
updated = updated.filter((val) => val !== "all");
@@ -1545,12 +1598,19 @@ export default function FormTeks() {
key={option.id}
className="flex gap-2 items-center"
>
- handleChange(e.target.checked)}
+ className="h-4 w-4 border border-gray-300 rounded text-blue-600 focus:ring-blue-500"
+ />
+ {/*
+ /> */}
);
diff --git a/components/form/content/document/teks-update-form.tsx b/components/form/content/document/teks-update-form.tsx
index 16ca40f..bde2ab4 100644
--- a/components/form/content/document/teks-update-form.tsx
+++ b/components/form/content/document/teks-update-form.tsx
@@ -70,12 +70,12 @@ const teksSchema = z.object({
"application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"text/plain",
- ].includes(file.type) && file.size <= 10 * 1024 * 1024
+ ].includes(file.type) && file.size <= 10 * 1024 * 1024,
),
{
message:
"Hanya file .pdf, .doc, .docx, atau .txt dengan ukuran maksimal 10MB yang diperbolehkan.",
- }
+ },
),
publishedFor: z
@@ -121,7 +121,7 @@ const CustomEditor = dynamic(
() => {
return import("@/components/editor/custom-editor");
},
- { ssr: false }
+ { ssr: false },
);
export default function FormTeksUpdate() {
@@ -273,7 +273,7 @@ export default function FormTeksUpdate() {
.filter(Boolean);
const allSelected = ["nasional", "wilayah", "internasional"].every((opt) =>
- options.includes(opt)
+ options.includes(opt),
);
return allSelected ? ["all", ...options] : options;
@@ -286,12 +286,12 @@ export default function FormTeksUpdate() {
.filter((opt) => opt.id !== "all")
.map((opt) => opt.id);
setPublishedFor(
- publishedFor.length === allOptions.length ? [] : allOptions
+ publishedFor.length === allOptions.length ? [] : allOptions,
);
} else {
// Toggle individual option
setPublishedFor((prev) =>
- prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id]
+ prev.includes(id) ? prev.filter((item) => item !== id) : [...prev, id],
);
}
};
@@ -316,20 +316,31 @@ export default function FormTeksUpdate() {
// isYoutube: false,
// isInternationalMedia: false,
// };
+
const payload = {
- aiArticleId: detail?.aiArticleId ?? "",
+ aiArticleId: detail.aiArticleId,
categoryIds: selectedCategory,
- createdById: detail?.createdById ?? "",
description: htmlToString(data.description),
htmlDescription: data.description,
- isDraft: false,
- isPublish: true,
- slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
- statusId: detail?.statusId ?? 1,
tags: tags.join(","),
title: data.title,
- typeId: detail?.typeId ?? 3,
+ typeId: detail.typeId,
+ slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
};
+ // const payload = {
+ // aiArticleId: detail?.aiArticleId ?? "",
+ // categoryIds: selectedCategory,
+ // createdById: detail?.createdById ?? "",
+ // description: htmlToString(data.description),
+ // htmlDescription: data.description,
+ // isDraft: false,
+ // isPublish: true,
+ // slug: detail?.slug ?? data.title.toLowerCase().replace(/\s+/g, "-"),
+ // statusId: detail?.statusId ?? 1,
+ // tags: tags.join(","),
+ // title: data.title,
+ // typeId: detail?.typeId ?? 3,
+ // };
const res = await updateArticle(Number(id), payload);
if (res?.error) {
@@ -386,7 +397,7 @@ export default function FormTeksUpdate() {
idx: number,
id: string,
file: any,
- duration: string
+ duration: string,
) {
console.log(idx, id, file, duration);
@@ -424,7 +435,7 @@ export default function FormTeksUpdate() {
onChunkComplete: (
chunkSize: any,
bytesAccepted: any,
- bytesTotal: any
+ bytesTotal: any,
) => {
const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100);
progressInfo[idx].percentage = uploadPersen;
@@ -568,7 +579,7 @@ export default function FormTeksUpdate() {
// If all individual options are selected, include "all" automatically
const isAllSelected = ["nasional", "wilayah", "internasional"].every(
- (opt) => updatedSelections.includes(opt)
+ (opt) => updatedSelections.includes(opt),
);
return {
...prev,
@@ -599,7 +610,7 @@ export default function FormTeksUpdate() {
const handleEditTag = (index: number, newValue: string) => {
setTags((prevTags) =>
- prevTags.map((tag, i) => (i === index ? newValue : tag))
+ prevTags.map((tag, i) => (i === index ? newValue : tag)),
);
};
@@ -692,12 +703,12 @@ export default function FormTeksUpdate() {