fixing
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6e3d01cdc0
commit
b898fc3069
|
|
@ -34,10 +34,10 @@ import { createCategories } from "@/service/categories/categories";
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
title: z.string().min(1, "Nama kategori wajib diisi"),
|
title: z.string().min(1, "Nama kategori wajib diisi"),
|
||||||
slug: z.string().min(1, "Slug wajib diisi"),
|
slug: z.string().optional(),
|
||||||
description: z.string().min(1, "Deskripsi wajib diisi"),
|
description: z.string().min(1, "Deskripsi wajib diisi"),
|
||||||
statusId: z.coerce.number().default(1), // biar default aktif
|
statusId: z.coerce.number().default(1),
|
||||||
tags: z.string().optional(), // opsional aja kalau belum wajib
|
tags: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// helper untuk bikin slug otomatis
|
// helper untuk bikin slug otomatis
|
||||||
|
|
@ -64,22 +64,30 @@ const ReactTableImagePage = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const handleTitleChange = (value: string) => {
|
||||||
|
// form.setValue("title", value);
|
||||||
|
// const autoSlug = slugify(value);
|
||||||
|
// if (
|
||||||
|
// !form.getValues("slug") ||
|
||||||
|
// form.getValues("slug") ===
|
||||||
|
// slugify(form.formState.defaultValues?.title || "")
|
||||||
|
// ) {
|
||||||
|
// form.setValue("slug", autoSlug);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
const handleTitleChange = (value: string) => {
|
const handleTitleChange = (value: string) => {
|
||||||
form.setValue("title", value);
|
form.setValue("title", value);
|
||||||
const autoSlug = slugify(value);
|
form.setValue("slug", slugify(value));
|
||||||
if (
|
|
||||||
!form.getValues("slug") ||
|
|
||||||
form.getValues("slug") ===
|
|
||||||
slugify(form.formState.defaultValues?.title || "")
|
|
||||||
) {
|
|
||||||
form.setValue("slug", autoSlug);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
||||||
loading();
|
loading();
|
||||||
try {
|
try {
|
||||||
const response = await createCategories(data);
|
const payload = {
|
||||||
|
...data,
|
||||||
|
slug: slugify(data.title),
|
||||||
|
};
|
||||||
|
const response = await createCategories(payload);
|
||||||
MySwal.close();
|
MySwal.close();
|
||||||
|
|
||||||
if (response?.error) {
|
if (response?.error) {
|
||||||
|
|
@ -128,7 +136,7 @@ const ReactTableImagePage = () => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gray-50 dark:bg-default-50">
|
<div className="min-h-screen bg-gray-50 dark:bg-default-50">
|
||||||
{/* <SiteBreadcrumb /> */}
|
<SiteBreadcrumb />
|
||||||
<div className="p-6">
|
<div className="p-6">
|
||||||
<div className="max-w-7xl mx-auto">
|
<div className="max-w-7xl mx-auto">
|
||||||
<Card className="shadow-sm border-0">
|
<Card className="shadow-sm border-0">
|
||||||
|
|
@ -184,7 +192,7 @@ const ReactTableImagePage = () => {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Slug */}
|
{/* Slug */}
|
||||||
<FormField
|
{/* <FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="slug"
|
name="slug"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
|
|
@ -199,7 +207,7 @@ const ReactTableImagePage = () => {
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/> */}
|
||||||
|
|
||||||
{/* Deskripsi */}
|
{/* Deskripsi */}
|
||||||
<FormField
|
<FormField
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
@import "swiper/css";
|
||||||
|
@import "swiper/css/navigation";
|
||||||
|
|
||||||
/* ================================
|
/* ================================
|
||||||
GLOBAL CSS VARIABLE (LIGHT MODE)
|
GLOBAL CSS VARIABLE (LIGHT MODE)
|
||||||
|
|
|
||||||
|
|
@ -161,12 +161,12 @@ export default function CategoriesDetailForm() {
|
||||||
{formatDateToIndonesian(new Date(detail.createdAt))}
|
{formatDateToIndonesian(new Date(detail.createdAt))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{/* <div>
|
||||||
<Label>Updated At</Label>
|
<Label>Updated At</Label>
|
||||||
<p className="text-sm">
|
<p className="text-sm">
|
||||||
{formatDateToIndonesian(new Date(detail.updatedAt))}
|
{formatDateToIndonesian(new Date(detail.updatedAt))}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div> */}
|
||||||
|
|
||||||
{/* Back Button */}
|
{/* Back Button */}
|
||||||
<Button
|
<Button
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
declare module '*.css';
|
||||||
|
|
@ -22,6 +22,6 @@
|
||||||
"@/*": ["./*"]
|
"@/*": ["./*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "global.d.ts"],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue