feat: implement update news functionality with API integration and form handling
This commit is contained in:
@@ -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 && (
|
||||
|
||||
@@ -32,7 +32,7 @@ export const ContentsPage = () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Tanggal Konten',
|
||||
title: 'Tanggal Live',
|
||||
data: 'live_at',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user