feat: expose isDummy on get-villages and edit-villages endpoints
This commit is contained in:
@@ -311,13 +311,13 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
try {
|
||||
const data = await prisma.village.findMany({
|
||||
where: {
|
||||
isDummy: false,
|
||||
...(search && { name: { contains: search, mode: 'insensitive' } })
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
isActive: true,
|
||||
isDummy: true,
|
||||
createdAt: true,
|
||||
User: {
|
||||
where: {
|
||||
@@ -335,7 +335,6 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
|
||||
const count = await prisma.village.count({
|
||||
where: {
|
||||
isDummy: false,
|
||||
...(search && { name: { contains: search, mode: 'insensitive' } })
|
||||
},
|
||||
})
|
||||
@@ -344,6 +343,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
id: village.id,
|
||||
name: village.name,
|
||||
isActive: village.isActive,
|
||||
isDummy: village.isDummy,
|
||||
createdAt: formatDateTime(village.createdAt),
|
||||
perbekel: village.User[0]?.name || null,
|
||||
}));
|
||||
@@ -501,6 +501,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
id: true,
|
||||
name: true,
|
||||
isActive: true,
|
||||
isDummy: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
desc: true,
|
||||
@@ -529,6 +530,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
id: data?.id,
|
||||
name: data?.name,
|
||||
isActive: data?.isActive,
|
||||
isDummy: data?.isDummy,
|
||||
desc: data?.desc,
|
||||
createdAt: data?.createdAt ? formatDateTime(data.createdAt) : null,
|
||||
updatedAt: data?.updatedAt ? formatDateTime(data.updatedAt) : null,
|
||||
@@ -957,7 +959,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
}
|
||||
)
|
||||
.post("/edit-villages", async ({ body, set }) => {
|
||||
const { id, name, desc } = body;
|
||||
const { id, name, desc, isDummy } = body;
|
||||
|
||||
try {
|
||||
const village = await prisma.village.findUnique({
|
||||
@@ -977,6 +979,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
data: {
|
||||
name,
|
||||
desc,
|
||||
isDummy,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -998,6 +1001,7 @@ const MonitoringServer = new Elysia({ prefix: "/api/monitoring" })
|
||||
id: t.String({ description: "ID desa" }),
|
||||
name: t.String({ description: "Nama desa" }),
|
||||
desc: t.String({ description: "Deskripsi desa" }),
|
||||
isDummy: t.Boolean({ description: "Apakah desa dummy" }),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Edit Villages",
|
||||
|
||||
Reference in New Issue
Block a user