fix:enable create button, merge dev-restructure

This commit is contained in:
Rama Priyanto 2025-06-10 13:11:02 +07:00
commit aac0c76356
6 changed files with 51 additions and 54 deletions

View File

@ -11,24 +11,16 @@ export default function BasicPage() {
<div className="overflow-x-hidden overflow-y-scroll">
<div className="px-2 md:px-4 md:py-4 w-full">
<div className="bg-white shadow-lg dark:bg-[#18181b] rounded-xl p-3">
{/* <Link href="/admin/article/create">
<Link href="/admin/article/create">
<Button
size="md"
className="bg-[#F07C00] text-white w-full lg:w-fit"
isDisabled
>
Tambah Artikel
<AddIcon />
</Button>
</Link> */}
<Button
size="md"
className="bg-[#F07C00] text-white w-full lg:w-fit"
isDisabled
>
Tambah Artikel
<AddIcon />
</Button>
</Link>
<ArticleTable />
</div>
</div>

View File

@ -124,46 +124,51 @@ export default function MasterCategoryTable() {
};
const onSubmit = async (values: z.infer<typeof createArticleSchema>) => {
if (selectedParent) {
loading();
const formData = {
title: values.title,
statusId: 1,
parentId: selectedParent ? selectedParent.id : 0,
tags: values.tags.join(","),
description: values.description,
};
console.log("values,", values);
loading();
const formData = {
title: values.title,
statusId: 1,
parentId: selectedParent ? selectedParent.id : 0,
tags: values.tags.join(","),
description: values.description,
};
const response = await createCategory(formData);
if (response?.error) {
error(response.message);
return false;
const response = await createCategory(formData);
console.log(response);
if (response?.error) {
console.log();
if (
response.message?.messages[0]?.includes(
"article_categories_title_unique"
)
) {
error("Judul sudah tersedia, silahkan buat dengan judul berbeda");
} else {
error(response.message?.messages);
}
const categoryId = response?.data?.data?.id;
const formFiles = new FormData();
formFiles.append("files", files[0]);
const resFile = await uploadCategoryThumbnail(categoryId, formFiles);
if (resFile?.error) {
error(resFile.message);
return false;
}
close();
setRefresh(!refresh);
MySwal.fire({
title: "Sukses",
icon: "success",
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then((result) => {
if (result.isConfirmed) {
}
});
return false;
}
const categoryId = response?.data?.data?.id;
const formFiles = new FormData();
setSelectedParentValidation("Parent harus diisi");
formFiles.append("files", files[0]);
const resFile = await uploadCategoryThumbnail(categoryId, formFiles);
if (resFile?.error) {
error(resFile.message);
return false;
}
close();
setRefresh(!refresh);
MySwal.fire({
title: "Sukses",
icon: "success",
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then((result) => {
if (result.isConfirmed) {
}
});
};
const handleRemoveFile = (file: File) => {
@ -180,7 +185,6 @@ export default function MasterCategoryTable() {
size="md"
className="bg-[#F07C00] text-white w-full lg:w-fit"
onPress={onOpen}
isDisabled
>
Tambah Kategori
<AddIcon />
@ -263,7 +267,9 @@ export default function MasterCategoryTable() {
)}
</div>
<div className="flex flex-col gap-1">
<p className="text-sm mt-3">Parent</p>
<p className="text-sm mt-3">
Parent Kategori <span>(Optional)</span>
</p>
<ReactSelect
className="basic-single text-black z-50"

View File

@ -362,8 +362,8 @@ export default function CreateArticleForm() {
title: values.title,
typeId: 1,
slug: values.slug,
categoryIds: "879507",
// 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),

View File

@ -356,8 +356,7 @@ export default function DashboardContainer() {
<div className="flex flex-col w-full lg:w-[45%] gap-6 shadow-md bg-white dark:bg-[#18181b] rounded-lg p-8 text-sm">
<div className="flex justify-between font-semibold">
<p>Recent Article</p>
<Link href="#">
{/* <Link href="/admin/article/create"> */}
<Link href="/admin/article/create">
<Button color="primary" variant="bordered">
Buat Article
</Button>

View File

@ -328,7 +328,7 @@ export default function ArticleTable() {
<DotsYIcon className="text-default-300" />
</Button>
</DropdownTrigger>
<DropdownMenu disabledKeys={["edit", "delete"]}>
<DropdownMenu>
<DropdownItem
key="copy-article"
onPress={() => copyUrlArticle(article.id, article.slug)}

View File

@ -285,7 +285,7 @@ export default function CategoriesTable(props: { triggerRefresh: boolean }) {
<DotsYIcon className="text-default-300" />
</Button>
</DropdownTrigger>
<DropdownMenu disabledKeys={["Edit", "Delete"]}>
<DropdownMenu>
<DropdownItem
key="Detail"
onPress={() => openModal(category.id, true)}