UI & API Menu Struktur Organisasi Tabs Hubungan Organisasi
This commit is contained in:
@@ -35,14 +35,13 @@ const HubunganOrganisasi = new Elysia({
|
||||
return response;
|
||||
}, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
atasanId: t.Optional(t.String()),
|
||||
bawahanId: t.Optional(t.String()),
|
||||
tipe: t.Optional(t.String()),
|
||||
}),
|
||||
})
|
||||
|
||||
// ❌ DELETE /:id
|
||||
.delete("/:id", hubunganOrganisasiDelete);
|
||||
// ❌ DELETE /del/:id
|
||||
.delete("/del/:id", hubunganOrganisasiDelete);
|
||||
|
||||
export default HubunganOrganisasi;
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
type FormUpdateHubungan = {
|
||||
id: string;
|
||||
atasanId?: string;
|
||||
bawahanId?: string;
|
||||
tipe?: string;
|
||||
};
|
||||
|
||||
export default async function hubunganOrganisasiUpdate(context: Context) {
|
||||
const body = await context.body as FormUpdateHubungan;
|
||||
const body = await context.body as Omit<FormUpdateHubungan, 'id'>;
|
||||
const id = context.params?.id;
|
||||
|
||||
if (!body?.id) {
|
||||
if (!id) {
|
||||
return {
|
||||
success: false,
|
||||
message: "ID wajib diisi untuk update",
|
||||
message: "ID wajib ada di URL",
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const updated = await prisma.hubunganOrganisasi.update({
|
||||
where: { id: body.id },
|
||||
where: { id },
|
||||
data: {
|
||||
atasanId: body.atasanId,
|
||||
bawahanId: body.bawahanId,
|
||||
|
||||
Reference in New Issue
Block a user