fix(apbdes): integrate new APBDes API with admin UI
- Update API schema to support name, deskripsi, and jumlah fields - Enhance state management with additional form fields - Add input fields for name, description, and total amount in create/edit pages - Display description and total amount in detail page - Fix APBDes component order in landing page - Update TypeScript types and Prisma schema integration API Changes: - POST /api/landingpage/apbdes/create: Added optional fields (name, deskripsi, jumlah) - PUT /api/landingpage/apbdes/🆔 Added optional fields (name, deskripsi, jumlah) Admin UI Changes: - create/page.tsx: Add TextInput for name, deskripsi, and jumlah - edit/page.tsx: Add TextInput for name, deskripsi, and jumlah; improve reset functionality - [id]/page.tsx: Display deskripsi and jumlah if available - page.tsx: Minor formatting fix - _state/apbdes.ts: Update Zod schema and default form with new fields Landing Page: - Move Apbdes component to top of stack for better visibility Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -17,6 +17,9 @@ type APBDesItemInput = {
|
||||
|
||||
type FormCreate = {
|
||||
tahun: number;
|
||||
name?: string;
|
||||
deskripsi?: string;
|
||||
jumlah?: string;
|
||||
imageId: string;
|
||||
fileId: string;
|
||||
items: APBDesItemInput[];
|
||||
@@ -48,7 +51,9 @@ export default async function apbdesCreate(context: Context) {
|
||||
const apbdes = await prisma.aPBDes.create({
|
||||
data: {
|
||||
tahun: body.tahun,
|
||||
name: `APBDes Tahun ${body.tahun}`,
|
||||
name: body.name || `APBDes Tahun ${body.tahun}`,
|
||||
deskripsi: body.deskripsi,
|
||||
jumlah: body.jumlah,
|
||||
imageId: body.imageId,
|
||||
fileId: body.fileId,
|
||||
},
|
||||
|
||||
@@ -47,7 +47,13 @@ export default async function apbdesFindMany(context: Context) {
|
||||
include: {
|
||||
image: true,
|
||||
file: true,
|
||||
items: true,
|
||||
items: {
|
||||
where: { isActive: true },
|
||||
orderBy: { kode: "asc" },
|
||||
include: {
|
||||
parent: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
prisma.aPBDes.count({ where }),
|
||||
|
||||
@@ -48,11 +48,14 @@ export default async function apbdesFindUnique(context: Context) {
|
||||
include: {
|
||||
items: {
|
||||
where: { isActive: true },
|
||||
orderBy: { kode: 'asc' }
|
||||
orderBy: { kode: 'asc' },
|
||||
include: {
|
||||
parent: true, // Include parent item for hierarchy
|
||||
},
|
||||
},
|
||||
image: true,
|
||||
file: true
|
||||
}
|
||||
file: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!result || !result.isActive) {
|
||||
|
||||
@@ -33,6 +33,9 @@ const APBDes = new Elysia({
|
||||
.post("/create", apbdesCreate, {
|
||||
body: t.Object({
|
||||
tahun: t.Number(),
|
||||
name: t.Optional(t.String()),
|
||||
deskripsi: t.Optional(t.String()),
|
||||
jumlah: t.Optional(t.String()),
|
||||
imageId: t.String(),
|
||||
fileId: t.String(),
|
||||
items: t.Array(ApbdesItemSchema),
|
||||
@@ -44,6 +47,9 @@ const APBDes = new Elysia({
|
||||
params: t.Object({ id: t.String() }),
|
||||
body: t.Object({
|
||||
tahun: t.Number(),
|
||||
name: t.Optional(t.String()),
|
||||
deskripsi: t.Optional(t.String()),
|
||||
jumlah: t.Optional(t.String()),
|
||||
imageId: t.String(),
|
||||
fileId: t.String(),
|
||||
items: t.Array(ApbdesItemSchema),
|
||||
|
||||
@@ -15,6 +15,9 @@ type APBDesItemInput = {
|
||||
|
||||
type FormUpdateBody = {
|
||||
tahun: number;
|
||||
name?: string;
|
||||
deskripsi?: string;
|
||||
jumlah?: string;
|
||||
imageId: string;
|
||||
fileId: string;
|
||||
items: APBDesItemInput[];
|
||||
@@ -79,6 +82,9 @@ export default async function apbdesUpdate(context: Context) {
|
||||
where: { id },
|
||||
data: {
|
||||
tahun: body.tahun,
|
||||
name: body.name || `APBDes Tahun ${body.tahun}`,
|
||||
deskripsi: body.deskripsi,
|
||||
jumlah: body.jumlah,
|
||||
imageId: body.imageId,
|
||||
fileId: body.fileId,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user