diff --git a/src/server/routes/pelayanan_surat_route.ts b/src/server/routes/pelayanan_surat_route.ts index b549809..62c596e 100644 --- a/src/server/routes/pelayanan_surat_route.ts +++ b/src/server/routes/pelayanan_surat_route.ts @@ -781,14 +781,39 @@ const PelayananRoute = new Elysia({ } } + const category = await prisma.categoryPelayanan.findUnique({ + where: { + id: pengajuan.idCategory, + } + }) + + type SyaratDokumen = { + desc: string; + name: string; + }; + + const syarat = category?.syaratDokumen as SyaratDokumen[] | undefined + + if (syaratDokumen && syaratDokumen.length > 0) { console.log("syaratDokumen") for (const item of syaratDokumen) { - dataUpdate.push(item.jenis) + const pilih = syarat?.find((cat) => cat.desc == item.jenis)?.name; + console.log(syarat, pilih) + dataUpdate.push(pilih) + const hasil = await prisma.syaratDokumenPelayanan.findFirst({ where: { idPengajuanLayanan: pengajuan.id, - jenis: item.jenis, + OR: [ + { + jenis: pilih, + }, + { + jenis: pilih, + } + ] + } }) console.log(hasil, item) @@ -803,7 +828,7 @@ const PelayananRoute = new Elysia({ }, create: { value: item.value, - jenis: item.jenis, + jenis: hasil.jenis, idPengajuanLayanan: pengajuan.id, idCategory: pengajuan.idCategory, }