fix:disable category
This commit is contained in:
parent
85b73ca5ab
commit
2f3b6cb027
|
|
@ -104,9 +104,9 @@ const createArticleSchema = z.object({
|
||||||
description: z.string().min(2, {
|
description: z.string().min(2, {
|
||||||
message: "Deskripsi harus diisi",
|
message: "Deskripsi harus diisi",
|
||||||
}),
|
}),
|
||||||
category: z.array(categorySchema).nonempty({
|
// category: z.array(categorySchema).nonempty({
|
||||||
message: "Kategori harus memiliki setidaknya satu item",
|
// message: "Kategori harus memiliki setidaknya satu item",
|
||||||
}),
|
// }),
|
||||||
tags: z.array(z.string()).nonempty({
|
tags: z.array(z.string()).nonempty({
|
||||||
message: "Minimal 1 tag",
|
message: "Minimal 1 tag",
|
||||||
}),
|
}),
|
||||||
|
|
@ -300,7 +300,8 @@ export default function CreateArticleForm() {
|
||||||
title: values.title,
|
title: values.title,
|
||||||
typeId: 1,
|
typeId: 1,
|
||||||
slug: values.slug,
|
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(","),
|
tags: values.tags.join(","),
|
||||||
description: htmlToString(removeImgTags(values.description)),
|
description: htmlToString(removeImgTags(values.description)),
|
||||||
htmlDescription: removeImgTags(values.description),
|
htmlDescription: removeImgTags(values.description),
|
||||||
|
|
@ -458,27 +459,27 @@ export default function CreateArticleForm() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCategory = watch("category");
|
// const selectedCategory = watch("category");
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
getDetailCategory();
|
// getDetailCategory();
|
||||||
}, [selectedCategory]);
|
// }, [selectedCategory]);
|
||||||
|
|
||||||
const getDetailCategory = async () => {
|
// const getDetailCategory = async () => {
|
||||||
let temp = getValues("tags");
|
// let temp = getValues("tags");
|
||||||
for (const element of selectedCategory) {
|
// for (const element of selectedCategory) {
|
||||||
const res = await getCategoryById(element?.id);
|
// const res = await getCategoryById(element?.id);
|
||||||
const tagList = res?.data?.data?.tags;
|
// const tagList = res?.data?.data?.tags;
|
||||||
if (tagList) {
|
// if (tagList) {
|
||||||
temp = [...temp, ...res?.data?.data?.tags];
|
// temp = [...temp, ...res?.data?.data?.tags];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
const uniqueArray = temp.filter(
|
// const uniqueArray = temp.filter(
|
||||||
(item, index) => temp.indexOf(item) === index
|
// (item, index) => temp.indexOf(item) === index
|
||||||
);
|
// );
|
||||||
|
|
||||||
setValue("tags", uniqueArray as [string, ...string[]]);
|
// setValue("tags", uniqueArray as [string, ...string[]]);
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
|
|
@ -700,7 +701,7 @@ export default function CreateArticleForm() {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<p className="text-sm mt-3">Kategori</p>
|
{/* <p className="text-sm mt-3">Kategori</p>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="category"
|
name="category"
|
||||||
|
|
@ -728,7 +729,7 @@ export default function CreateArticleForm() {
|
||||||
<p className="text-red-400 text-sm mb-3">
|
<p className="text-red-400 text-sm mb-3">
|
||||||
{errors.category?.message}
|
{errors.category?.message}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<p className="text-sm">Tags</p>
|
<p className="text-sm">Tags</p>
|
||||||
<Controller
|
<Controller
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue