diff --git a/app/(admin)/admin/master-category/page.tsx b/app/(admin)/admin/master-category/page.tsx index a970199..2e063af 100644 --- a/app/(admin)/admin/master-category/page.tsx +++ b/app/(admin)/admin/master-category/page.tsx @@ -33,6 +33,7 @@ import { } from "@/service/master-categories"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; +import Image from "next/image"; const categorySchema = z.object({ id: z.number(), @@ -48,6 +49,9 @@ const createArticleSchema = z.object({ message: "Deskripsi harus diisi", }), tags: z.array(z.string()), + // parent: z.array(categorySchema).nonempty({ + // message: "Kategori harus memiliki setidaknya satu item", + // }), // tags: z.array(z.string()).nonempty({ // message: "Minimal 1 tag", // }), @@ -69,10 +73,11 @@ export default function MasterCategoryTable() { const [files, setFiles] = useState([]); const [refresh, setRefresh] = useState(false); const [tag, setTag] = useState(""); + const [selectedParent, setSelectedParent] = useState(); const formOptions = { resolver: zodResolver(createArticleSchema), - defaultValues: { title: "", description: "", category: [], tags: [] }, + defaultValues: { title: "", description: "", tags: [] }, }; const { getRootProps, getInputProps } = useDropzone({ @@ -122,7 +127,7 @@ export default function MasterCategoryTable() { const formData = { title: values.title, statusId: 1, - parentId: 1, + parentId: selectedParent ? selectedParent.id : 0, tags: values.tags.join(","), description: values.description, }; @@ -250,6 +255,27 @@ export default function MasterCategoryTable() {

)} +
+

Parent

+ + + "!rounded-lg bg-white !border-1 !border-gray-200 dark:!border-stone-500", + }} + classNamePrefix="select" + onChange={setSelectedParent} + closeMenuOnSelect={false} + components={animatedComponents} + isClearable={true} + isSearchable={true} + isMulti={false} + placeholder="Kategori..." + name="sub-module" + options={listCategory} + /> +

Tag Terkait

0 && (
- thumbnail
+
+

Parent

+ + + "!rounded-lg bg-white !border-1 !border-gray-200 dark:!border-stone-500", + }} + classNamePrefix="select" + value={selectedParent} + isDisabled={isDetail} + onChange={setSelectedParent} + closeMenuOnSelect={false} + components={animatedComponents} + isClearable={true} + isSearchable={true} + isMulti={false} + placeholder="Kategori..." + name="sub-module" + options={listCategory} + /> +

Tag Terkait

{isDetail ? ( - thumbnail ) : (