UI & API Pendidikan Non Formal
This commit is contained in:
@@ -2,6 +2,7 @@ import Elysia from "elysia";
|
||||
import InfoSekolahPAUD from "./info-sekolah-paud";
|
||||
import ProgramPendidikanAnak from "./program-pendidikan-anak";
|
||||
import BimbinganBelajarDesa from "./bimbingan-belajar-desa";
|
||||
import PendidikanNonFormal from "./pendidikan-non-formal";
|
||||
|
||||
const Pendidikan = new Elysia({
|
||||
prefix: "/api/pendidikan",
|
||||
@@ -11,5 +12,6 @@ const Pendidikan = new Elysia({
|
||||
.use(InfoSekolahPAUD)
|
||||
.use(ProgramPendidikanAnak)
|
||||
.use(BimbinganBelajarDesa)
|
||||
.use(PendidikanNonFormal)
|
||||
|
||||
export default Pendidikan;
|
||||
@@ -0,0 +1,14 @@
|
||||
import Elysia from "elysia";
|
||||
import JenisProgramYangDiselenggarakan from "./jenis-program-yang-diselenggarakan";
|
||||
import TujuanPendidikanNonFormal from "./tujuan-program";
|
||||
import TempatKegiatan from "./tempat-kegiatan";
|
||||
|
||||
const PendidikanNonFormal = new Elysia({
|
||||
prefix: "/pendidikannonformal",
|
||||
tags: ["Pendidikan/Pendidikan Non Formal"]
|
||||
})
|
||||
.use(JenisProgramYangDiselenggarakan)
|
||||
.use(TujuanPendidikanNonFormal)
|
||||
.use(TempatKegiatan)
|
||||
|
||||
export default PendidikanNonFormal
|
||||
@@ -0,0 +1,37 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function jenisProgramYangDiselenggarakanFindUnique(
|
||||
context: Context
|
||||
) {
|
||||
try {
|
||||
const id = context?.params?.slugs?.[0];
|
||||
|
||||
// If no ID provided, get the first profile
|
||||
if (!id) {
|
||||
const data = await prisma.jenisProgramYangDiselenggarakan.findFirst();
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
const data = await prisma.jenisProgramYangDiselenggarakan.findUniqueOrThrow(
|
||||
{
|
||||
where: { id },
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching jenis program yang diselenggarakan:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : "Unknown error",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import jenisProgramYangDiselenggarakanFindUnique from "./findUnique";
|
||||
import jenisProgramYangDiselenggarakanUpdate from "./updt";
|
||||
|
||||
|
||||
const JenisProgramYangDiselenggarakan = new Elysia({
|
||||
prefix: "/jenisprogramyangdiselenggarakan",
|
||||
tags: ["Pendidikan/Pendidikan Non Formal/Jenis Program Yang Diselenggarakan"]
|
||||
})
|
||||
.get("/find-by-id", jenisProgramYangDiselenggarakanFindUnique)
|
||||
.post("/update", jenisProgramYangDiselenggarakanUpdate, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
judul: t.String(),
|
||||
deskripsi: t.String(),
|
||||
})
|
||||
})
|
||||
|
||||
export default JenisProgramYangDiselenggarakan
|
||||
@@ -0,0 +1,29 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormUpdate = Prisma.JenisProgramYangDiselenggarakanGetPayload<{
|
||||
select: {
|
||||
id: true;
|
||||
judul: true;
|
||||
deskripsi: true;
|
||||
}
|
||||
}>
|
||||
export default async function jenisProgramYangDiselenggarakanUpdate(context: Context) {
|
||||
const body = context.body as FormUpdate;
|
||||
|
||||
await prisma.jenisProgramYangDiselenggarakan.update({
|
||||
where: {
|
||||
id: body.id
|
||||
},
|
||||
data: {
|
||||
judul: body.judul,
|
||||
deskripsi: body.deskripsi,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Jenis program yang diselenggarakan berhasil diupdate",
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function tempatKegiatanFindUnique(
|
||||
context: Context
|
||||
) {
|
||||
try {
|
||||
const id = context?.params?.slugs?.[0];
|
||||
|
||||
// If no ID provided, get the first profile
|
||||
if (!id) {
|
||||
const data = await prisma.tempatKegiatan.findFirst();
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
const data = await prisma.tempatKegiatan.findUniqueOrThrow(
|
||||
{
|
||||
where: { id },
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching tempat kegiatan:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : "Unknown error",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import tempatKegiatanFindUnique from "./findUnique";
|
||||
import tempatKegiatanUpdate from "./updt";
|
||||
|
||||
const TempatKegiatan = new Elysia({
|
||||
prefix: "/tempatkegiatan",
|
||||
tags: ["Pendidikan/Pendidikan Non Formal/Tempat Kegiatan"]
|
||||
})
|
||||
.get("/find-by-id", tempatKegiatanFindUnique)
|
||||
.post("/update", tempatKegiatanUpdate, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
judul: t.String(),
|
||||
deskripsi: t.String(),
|
||||
})
|
||||
})
|
||||
|
||||
export default TempatKegiatan
|
||||
@@ -0,0 +1,29 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormUpdate = Prisma.TempatKegiatanGetPayload<{
|
||||
select: {
|
||||
id: true;
|
||||
judul: true;
|
||||
deskripsi: true;
|
||||
}
|
||||
}>
|
||||
export default async function tempatKegiatanUpdate(context: Context) {
|
||||
const body = context.body as FormUpdate;
|
||||
|
||||
await prisma.tempatKegiatan.update({
|
||||
where: {
|
||||
id: body.id
|
||||
},
|
||||
data: {
|
||||
judul: body.judul,
|
||||
deskripsi: body.deskripsi,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Tempat kegiatan berhasil diupdate",
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function tujuanPendidikanNonFormalFindUnique(
|
||||
context: Context
|
||||
) {
|
||||
try {
|
||||
const id = context?.params?.slugs?.[0];
|
||||
|
||||
// If no ID provided, get the first profile
|
||||
if (!id) {
|
||||
const data = await prisma.tujuanPendidikanNonFormal.findFirst();
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
const data = await prisma.tujuanPendidikanNonFormal.findUniqueOrThrow(
|
||||
{
|
||||
where: { id },
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching tujuan pendidikan non formal:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : "Unknown error",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import tujuanPendidikanNonFormalFindUnique from "./findUnique";
|
||||
import tujuanPendidikanNonFormalUpdate from "./updt";
|
||||
|
||||
const TujuanPendidikanNonFormal = new Elysia({
|
||||
prefix: "/tujuanpendidikannonformal",
|
||||
tags: ["Pendidikan/Pendidikan Non Formal/Tujuan Pendidikan Non Formal"]
|
||||
})
|
||||
.get("/find-by-id", tujuanPendidikanNonFormalFindUnique)
|
||||
.post("/update", tujuanPendidikanNonFormalUpdate, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
judul: t.String(),
|
||||
deskripsi: t.String(),
|
||||
})
|
||||
})
|
||||
|
||||
export default TujuanPendidikanNonFormal
|
||||
@@ -0,0 +1,29 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.TujuanPendidikanNonFormalGetPayload<{
|
||||
select: {
|
||||
id: true;
|
||||
judul: true;
|
||||
deskripsi: true;
|
||||
}
|
||||
}>
|
||||
export default async function tujuanPendidikanNonFormalUpdate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
|
||||
await prisma.tujuanPendidikanNonFormal.update({
|
||||
where: {
|
||||
id: body.id
|
||||
},
|
||||
data: {
|
||||
judul: body.judul,
|
||||
deskripsi: body.deskripsi,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Tujuan pendidikan non formal berhasil diupdate",
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user