feat: implement update news functionality with API integration and form handling

This commit is contained in:
Ardeman
2025-03-07 14:40:04 +08:00
parent e0b68611bd
commit d885b3cf26
5 changed files with 105 additions and 6 deletions
+3 -1
View File
@@ -15,6 +15,7 @@ import { TitleDashboard } from '~/components/ui/title-dashboard'
import type { loader } from '~/routes/_admin.lg-admin'
export const contentSchema = z.object({
id: z.string().optional(),
categories: z
.array(
z
@@ -74,6 +75,7 @@ export const ContentsFormPage = (properties: TProperties) => {
fetcher,
resolver: zodResolver(contentSchema),
values: {
id: newsData?.id || '',
categories: newsData?.categories || [],
tags: newsData?.tags || [],
title: newsData?.title || '',
@@ -110,7 +112,7 @@ export const ContentsFormPage = (properties: TProperties) => {
<fetcher.Form
method="post"
onSubmit={handleSubmit}
action="/actions/admin/contents/update"
action={`/actions/admin/contents/${newsData ? 'update' : 'create'}`}
className="space-y-4"
>
{error && (
+1 -1
View File
@@ -32,7 +32,7 @@ export const ContentsPage = () => {
},
},
{
title: 'Tanggal Konten',
title: 'Tanggal Live',
data: 'live_at',
},
{