From 2f3b6cb027b5f813b4ead57187658b30f3217f8a Mon Sep 17 00:00:00 2001
From: Rama Priyanto
Date: Mon, 26 May 2025 11:04:22 +0700
Subject: [PATCH] fix:disable category
---
.../form/article/create-article-form.tsx | 49 ++++++++++---------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/components/form/article/create-article-form.tsx b/components/form/article/create-article-form.tsx
index 8dcd4ce..6dd5370 100644
--- a/components/form/article/create-article-form.tsx
+++ b/components/form/article/create-article-form.tsx
@@ -104,9 +104,9 @@ const createArticleSchema = z.object({
description: z.string().min(2, {
message: "Deskripsi harus diisi",
}),
- category: z.array(categorySchema).nonempty({
- message: "Kategori harus memiliki setidaknya satu item",
- }),
+ // category: z.array(categorySchema).nonempty({
+ // message: "Kategori harus memiliki setidaknya satu item",
+ // }),
tags: z.array(z.string()).nonempty({
message: "Minimal 1 tag",
}),
@@ -300,7 +300,8 @@ export default function CreateArticleForm() {
title: values.title,
typeId: 1,
slug: values.slug,
- categoryIds: values.category.map((a) => a.id).join(","),
+ categoryIds: "879507",
+ // categoryIds: values.category.map((a) => a.id).join(","),
tags: values.tags.join(","),
description: htmlToString(removeImgTags(values.description)),
htmlDescription: removeImgTags(values.description),
@@ -458,27 +459,27 @@ export default function CreateArticleForm() {
}
};
- const selectedCategory = watch("category");
+ // const selectedCategory = watch("category");
- useEffect(() => {
- getDetailCategory();
- }, [selectedCategory]);
+ // useEffect(() => {
+ // getDetailCategory();
+ // }, [selectedCategory]);
- const getDetailCategory = async () => {
- let temp = getValues("tags");
- for (const element of selectedCategory) {
- const res = await getCategoryById(element?.id);
- const tagList = res?.data?.data?.tags;
- if (tagList) {
- temp = [...temp, ...res?.data?.data?.tags];
- }
- }
- const uniqueArray = temp.filter(
- (item, index) => temp.indexOf(item) === index
- );
+ // const getDetailCategory = async () => {
+ // let temp = getValues("tags");
+ // for (const element of selectedCategory) {
+ // const res = await getCategoryById(element?.id);
+ // const tagList = res?.data?.data?.tags;
+ // if (tagList) {
+ // temp = [...temp, ...res?.data?.data?.tags];
+ // }
+ // }
+ // const uniqueArray = temp.filter(
+ // (item, index) => temp.indexOf(item) === index
+ // );
- setValue("tags", uniqueArray as [string, ...string[]]);
- };
+ // setValue("tags", uniqueArray as [string, ...string[]]);
+ // };
return (
)}
- Kategori
+ {/* Kategori
{errors.category?.message}
- )}
+ )} */}
Tags