Fix Dibagian Data Kesehatan Warga
This commit is contained in:
@@ -17,7 +17,7 @@ export default async function grafikKepuasanCreate(context: Context) {
|
||||
jumlah: body.jumlah,
|
||||
},
|
||||
select: {
|
||||
uuid: true,
|
||||
id: true,
|
||||
label: true,
|
||||
jumlah: true,
|
||||
}
|
||||
|
||||
@@ -2,35 +2,35 @@ import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function grafikKepuasanDelete(context: Context) {
|
||||
const uuid = context.params?.uuid;
|
||||
|
||||
if (!uuid) {
|
||||
return {
|
||||
success: false,
|
||||
message: "ID tidak ditemukan"
|
||||
}
|
||||
}
|
||||
|
||||
const existing = await prisma.grafikKepuasan.findUnique({
|
||||
where: {
|
||||
uuid: uuid,
|
||||
},
|
||||
})
|
||||
|
||||
if (!existing) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Data tidak ditemukan",
|
||||
}
|
||||
}
|
||||
|
||||
const deleted = await prisma.grafikKepuasan.delete({
|
||||
where: { uuid },
|
||||
})
|
||||
const id = context.params?.id;
|
||||
|
||||
if (!id) {
|
||||
return {
|
||||
success: true,
|
||||
message: "Data berhasil dihapus",
|
||||
data: deleted,
|
||||
}
|
||||
}
|
||||
success: false,
|
||||
message: "ID tidak ditemukan",
|
||||
};
|
||||
}
|
||||
|
||||
const existing = await prisma.grafikKepuasan.findUnique({
|
||||
where: {
|
||||
id: id,
|
||||
},
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Data tidak ditemukan",
|
||||
};
|
||||
}
|
||||
|
||||
const deleted = await prisma.grafikKepuasan.delete({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Data berhasil dihapus",
|
||||
data: deleted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ import prisma from "@/lib/prisma";
|
||||
export default async function grafikKepuasanFindUnique(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const pathSegments = url.pathname.split('/');
|
||||
const uuid = pathSegments[pathSegments.length - 1];
|
||||
const id = pathSegments[pathSegments.length - 1];
|
||||
|
||||
if (!uuid) {
|
||||
if (!id) {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: 'ID tidak boleh kosong',
|
||||
@@ -13,7 +13,7 @@ export default async function grafikKepuasanFindUnique(request: Request) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof uuid !== 'string') {
|
||||
if (typeof id !== 'string') {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak valid",
|
||||
@@ -21,7 +21,7 @@ export default async function grafikKepuasanFindUnique(request: Request) {
|
||||
}
|
||||
|
||||
const data = await prisma.grafikKepuasan.findUnique({
|
||||
where: { uuid },
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
|
||||
@@ -9,7 +9,7 @@ const GrafikKepuasan = new Elysia({
|
||||
prefix: "/grafikkepuasan",
|
||||
tags: ["Data Kesehatan/Grafik Kepuasan"]
|
||||
})
|
||||
.get("/:uuid", async (context) => {
|
||||
.get("/:id", async (context) => {
|
||||
const response = await grafikKepuasanFindUnique(new Request(context.request));
|
||||
return response;
|
||||
})
|
||||
@@ -20,18 +20,18 @@ const GrafikKepuasan = new Elysia({
|
||||
jumlah: t.String(),
|
||||
}),
|
||||
})
|
||||
.put("/:uuid", grafikKepuasanUpdate, {
|
||||
.put("/:id", grafikKepuasanUpdate, {
|
||||
params: t.Object({
|
||||
uuid: t.String(),
|
||||
id: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
label: t.String(),
|
||||
jumlah: t.String(),
|
||||
}),
|
||||
})
|
||||
.delete("/del/:uuid", grafikKepuasanDelete, {
|
||||
.delete("/del/:id", grafikKepuasanDelete, {
|
||||
params: t.Object({
|
||||
uuid: t.String(),
|
||||
id: t.String(),
|
||||
}),
|
||||
})
|
||||
export default GrafikKepuasan
|
||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function grafikKepuasanUpdate(context: Context) {
|
||||
const uuid = context.params?.uuid;
|
||||
const id = context.params?.id;
|
||||
|
||||
if (!uuid) {
|
||||
if (!id) {
|
||||
return {
|
||||
success: false,
|
||||
message: "ID tidak ditemukan"
|
||||
@@ -18,7 +18,7 @@ export default async function grafikKepuasanUpdate(context: Context) {
|
||||
|
||||
const existing = await prisma.grafikKepuasan.findUnique({
|
||||
where: {
|
||||
uuid: uuid,
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -30,7 +30,7 @@ export default async function grafikKepuasanUpdate(context: Context) {
|
||||
}
|
||||
|
||||
const updated = await prisma.grafikKepuasan.update({
|
||||
where: { uuid },
|
||||
where: { id },
|
||||
data: {
|
||||
label,
|
||||
jumlah,
|
||||
|
||||
@@ -22,7 +22,7 @@ export default async function persentaseKelahiranKematianCreate(context: Context
|
||||
kelahiranKasar: body.kelahiranKasar,
|
||||
},
|
||||
select: {
|
||||
uuid: true,
|
||||
id: true,
|
||||
tahun: true,
|
||||
kematianKasar: true,
|
||||
kematianBayi: true,
|
||||
|
||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function persentaseKelahiranKematianDelete(context: Context) {
|
||||
const uuid = context.params?.uuid;
|
||||
const id = context.params?.id;
|
||||
|
||||
if (!uuid) {
|
||||
if (!id) {
|
||||
return {
|
||||
success: false,
|
||||
message: "ID tidak ditemukan",
|
||||
@@ -13,7 +13,7 @@ export default async function persentaseKelahiranKematianDelete(context: Context
|
||||
|
||||
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||
where: {
|
||||
uuid: uuid,
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ export default async function persentaseKelahiranKematianDelete(context: Context
|
||||
}
|
||||
|
||||
const deleted = await prisma.dataKematian_Kelahiran.delete({
|
||||
where: { uuid },
|
||||
where: { id },
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,9 +3,9 @@ import prisma from "@/lib/prisma";
|
||||
export default async function persentaseKelahiranKematianFindUnique(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const pathSegments = url.pathname.split('/');
|
||||
const uuid = pathSegments[pathSegments.length - 1];
|
||||
const id = pathSegments[pathSegments.length - 1];
|
||||
|
||||
if (!uuid) {
|
||||
if (!id) {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak boleh kosong",
|
||||
@@ -13,7 +13,7 @@ export default async function persentaseKelahiranKematianFindUnique(request: Req
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof uuid !== 'string') {
|
||||
if (typeof id !== 'string') {
|
||||
return Response.json({
|
||||
success: false,
|
||||
message: "ID tidak valid",
|
||||
@@ -21,7 +21,7 @@ export default async function persentaseKelahiranKematianFindUnique(request: Req
|
||||
}
|
||||
|
||||
const data = await prisma.dataKematian_Kelahiran.findUnique({
|
||||
where: { uuid },
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
|
||||
@@ -9,7 +9,7 @@ const PersentaseKelahiranKematian = new Elysia({
|
||||
prefix: "/persentasekelahiran",
|
||||
tags: ["Data Kesehatan/Persentase Kelahiran Kematian"],
|
||||
})
|
||||
.get("/:uuid", async (context) => {
|
||||
.get("/:id", async (context) => {
|
||||
const response = await persentaseKelahiranKematianFindUnique(new Request(context.request))
|
||||
return response
|
||||
})
|
||||
@@ -22,9 +22,9 @@ const PersentaseKelahiranKematian = new Elysia({
|
||||
kelahiranKasar: t.String(),
|
||||
}),
|
||||
})
|
||||
.put("/:uuid", persentaseKelahiranKematianUpdate, {
|
||||
.put("/:id", persentaseKelahiranKematianUpdate, {
|
||||
params: t.Object({
|
||||
uuid: t.String(),
|
||||
id: t.String(),
|
||||
}),
|
||||
body: t.Object({
|
||||
tahun: t.String(),
|
||||
@@ -33,9 +33,9 @@ const PersentaseKelahiranKematian = new Elysia({
|
||||
kelahiranKasar: t.String(),
|
||||
}),
|
||||
})
|
||||
.delete("/del/:uuid", persentaseKelahiranKematianDelete, {
|
||||
.delete("/del/:id", persentaseKelahiranKematianDelete, {
|
||||
params: t.Object({
|
||||
uuid: t.String(),
|
||||
id: t.String(),
|
||||
}),
|
||||
})
|
||||
export default PersentaseKelahiranKematian;
|
||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function persentaseKelahiranKematianUpdate(context: Context) {
|
||||
const uuid = context.params?.uuid;
|
||||
const id = context.params?.id;
|
||||
|
||||
if (!uuid) {
|
||||
if (!id) {
|
||||
return {
|
||||
success: false,
|
||||
message: "ID tidak ditemukan",
|
||||
@@ -20,7 +20,7 @@ export default async function persentaseKelahiranKematianUpdate(context: Context
|
||||
|
||||
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||
where: {
|
||||
uuid: uuid,
|
||||
id: id,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -32,7 +32,7 @@ export default async function persentaseKelahiranKematianUpdate(context: Context
|
||||
}
|
||||
|
||||
const updated = await prisma.dataKematian_Kelahiran.update({
|
||||
where: { uuid },
|
||||
where: { id },
|
||||
data: {
|
||||
tahun,
|
||||
kematianKasar,
|
||||
|
||||
Reference in New Issue
Block a user