Compare commits
24 Commits
amalia/08-
...
amalia/10-
| Author | SHA1 | Date | |
|---|---|---|---|
| 6bc6a9d357 | |||
| dee32b8cfd | |||
| ff0b0273bf | |||
| f8dcffa9c5 | |||
| 20e3056e04 | |||
| 84c9f405d6 | |||
| 22597c0159 | |||
| 0f9af404e1 | |||
| 676edaa22b | |||
| 7f6f495eaa | |||
| b5af41b07d | |||
| 6428f5084e | |||
| bfc292ec6c | |||
| 3b71976863 | |||
| 5680466c98 | |||
| 270f3687a3 | |||
| f5cc45937c | |||
| 5b4164b151 | |||
| 225c58b346 | |||
| b8b3aed86e | |||
| 281e34ea69 | |||
| 4fb98d0480 | |||
| 2579714000 | |||
| 20e24a03aa |
@@ -291,11 +291,14 @@ const PelayananRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/create", async ({ body }) => {
|
||||
const { kategoriId, namaWarga, noTelepon, dataText, syaratDokumen } = body
|
||||
.post("/create", async ({ body, headers }) => {
|
||||
const { kategoriId, dataText, syaratDokumen } = body
|
||||
const namaWarga = headers['x-user'] || ""
|
||||
const noTelepon = headers['x-phone'] || ""
|
||||
const noPengajuan = await generateNoPengajuanSurat()
|
||||
let idCategoryFix = kategoriId
|
||||
let idWargaFix = ""
|
||||
|
||||
const category = await prisma.categoryPelayanan.findUnique({
|
||||
where: {
|
||||
id: kategoriId,
|
||||
@@ -376,6 +379,7 @@ const PelayananRoute = new Elysia({
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
await prisma.syaratDokumenPelayanan.createMany({
|
||||
data: dataInsertSyaratDokumen,
|
||||
})
|
||||
@@ -400,17 +404,17 @@ const PelayananRoute = new Elysia({
|
||||
examples: ["skusaha"],
|
||||
error: "ID kategori harus diisi"
|
||||
}),
|
||||
namaWarga: t.String({
|
||||
description: "Nama warga",
|
||||
examples: ["Budi Santoso"],
|
||||
error: "Nama warga harus diisi"
|
||||
}),
|
||||
// namaWarga: t.String({
|
||||
// description: "Nama warga",
|
||||
// examples: ["Budi Santoso"],
|
||||
// error: "Nama warga harus diisi"
|
||||
// }),
|
||||
|
||||
noTelepon: t.String({
|
||||
error: "Nomor telepon harus diisi",
|
||||
examples: ["08123456789", "+628123456789"],
|
||||
description: "Nomor telepon warga pelapor"
|
||||
}),
|
||||
// noTelepon: t.String({
|
||||
// error: "Nomor telepon harus diisi",
|
||||
// examples: ["08123456789", "+628123456789"],
|
||||
// description: "Nomor telepon warga pelapor"
|
||||
// }),
|
||||
|
||||
dataText: t.Array(
|
||||
t.Object({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Elysia, { t } from "elysia"
|
||||
import type { StatusPengaduan } from "generated/prisma"
|
||||
import _ from "lodash"
|
||||
import _, { head } from "lodash"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
import { getLastUpdated } from "../lib/get-last-updated"
|
||||
import { mimeToExtension } from "../lib/mimetypeToExtension"
|
||||
@@ -130,12 +130,14 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if (!cariCategory) {
|
||||
idCategoryFix = "lainnya"
|
||||
} else {
|
||||
idCategoryFix = cariCategory.id
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
idCategoryFix = "lainnya"
|
||||
@@ -218,8 +220,8 @@ const PengaduanRoute = new Elysia({
|
||||
})),
|
||||
|
||||
kategoriId: t.Optional(t.String({
|
||||
examples: ["kebersihan"],
|
||||
description: "ID atau nama kategori pengaduan (contoh: kebersihan, keamanan, lainnya)"
|
||||
examples: ["kebersihan", "infrastruktur", "keamanan"],
|
||||
description: "Nama kategori pengaduan (contoh: kebersihan, keamanan, lainnya)"
|
||||
})),
|
||||
|
||||
// namaWarga: t.String({
|
||||
@@ -476,43 +478,44 @@ const PengaduanRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.get("/", async ({ query }) => {
|
||||
const { take, page, search, phone } = query
|
||||
const skip = !page ? 0 : (Number(page) - 1) * (!take ? 10 : Number(take))
|
||||
.get("/", async ({ query, headers }) => {
|
||||
// const { take, page, search } = query
|
||||
const phone = headers['x-phone'] || ""
|
||||
// const skip = !page ? 0 : (Number(page) - 1) * (!take ? 10 : Number(take))
|
||||
|
||||
const data = await prisma.pengaduan.findMany({
|
||||
skip,
|
||||
take: !take ? 10 : Number(take),
|
||||
// skip,
|
||||
// take: !take ? 10 : Number(take),
|
||||
orderBy: {
|
||||
createdAt: "asc"
|
||||
},
|
||||
where: {
|
||||
isActive: true,
|
||||
OR: [
|
||||
{
|
||||
title: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
{
|
||||
noPengaduan: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
},
|
||||
{
|
||||
detail: {
|
||||
contains: search ?? "",
|
||||
mode: "insensitive"
|
||||
},
|
||||
}
|
||||
],
|
||||
AND: {
|
||||
Warga: {
|
||||
phone: phone
|
||||
}
|
||||
}
|
||||
// OR: [
|
||||
// {
|
||||
// title: {
|
||||
// contains: search ?? "",
|
||||
// mode: "insensitive"
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// noPengaduan: {
|
||||
// contains: search ?? "",
|
||||
// mode: "insensitive"
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// detail: {
|
||||
// contains: search ?? "",
|
||||
// mode: "insensitive"
|
||||
// },
|
||||
// }
|
||||
// ],
|
||||
// AND: {
|
||||
// Warga: {
|
||||
// phone: phone
|
||||
// }
|
||||
// }
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -547,12 +550,11 @@ const PengaduanRoute = new Elysia({
|
||||
|
||||
return dataFix
|
||||
}, {
|
||||
query: t.Object({
|
||||
take: t.String({ optional: true }),
|
||||
page: t.String({ optional: true }),
|
||||
search: t.String({ optional: true }),
|
||||
phone: t.String({ minLength: 11, error: "phone harus diisi" }),
|
||||
}),
|
||||
// query: t.Object({
|
||||
// take: t.String({ optional: true }),
|
||||
// page: t.String({ optional: true }),
|
||||
// search: t.String({ optional: true }),
|
||||
// }),
|
||||
detail: {
|
||||
summary: "List Pengaduan Warga By Phone",
|
||||
description: `tool untuk mendapatkan list pengaduan warga by phone`,
|
||||
|
||||
Reference in New Issue
Block a user