Compare commits
11 Commits
amalia/08-
...
amalia/09-
| Author | SHA1 | Date | |
|---|---|---|---|
| 6428f5084e | |||
| bfc292ec6c | |||
| 5680466c98 | |||
| 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,
|
||||
@@ -359,6 +362,10 @@ const PelayananRoute = new Elysia({
|
||||
let dataInsertDataText = []
|
||||
|
||||
for (const item of syaratDokumen) {
|
||||
console.log('syarat dokumen', item)
|
||||
const jenisFix = (category?.syaratDokumen as Array<{ name: string; desc: string }>)
|
||||
?.find((v) => v.name === item.jenis || v.desc === item.jenis);
|
||||
console.log('jenis fix', jenisFix)
|
||||
dataInsertSyaratDokumen.push({
|
||||
idPengajuanLayanan: pengaduan.id,
|
||||
idCategory: idCategoryFix,
|
||||
@@ -368,6 +375,9 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
|
||||
for (const item of dataText) {
|
||||
console.log('dataitem', item)
|
||||
const jenisFix = category?.dataText.find((v) => v.toLowerCase() == item.jenis.toLowerCase())
|
||||
console.log('data text fix', jenisFix)
|
||||
dataInsertDataText.push({
|
||||
idPengajuanLayanan: pengaduan.id,
|
||||
idCategory: idCategoryFix,
|
||||
@@ -376,6 +386,9 @@ const PelayananRoute = new Elysia({
|
||||
})
|
||||
}
|
||||
|
||||
console.log('datainsertsyaratdokumen', dataInsertSyaratDokumen)
|
||||
console.log('datainsertdatatext', dataInsertDataText)
|
||||
|
||||
await prisma.syaratDokumenPelayanan.createMany({
|
||||
data: dataInsertSyaratDokumen,
|
||||
})
|
||||
@@ -400,17 +413,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({
|
||||
|
||||
Reference in New Issue
Block a user