upd: api jenna ai
Deskripsi: - detail post pengaduan - detail post pengajuan surat No Issues
This commit is contained in:
@@ -45,7 +45,7 @@ export default function DetailPengajuanPage() {
|
||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||
apiFetch.api.pelayanan.detail.get({
|
||||
query: {
|
||||
nomerPengajuan: id!,
|
||||
id: id!,
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -343,16 +343,19 @@ function DetailDataPengajuan({ data, syaratDokumen, dataText, onAction }: { data
|
||||
Setujui
|
||||
</Button>
|
||||
</Group>
|
||||
) : (
|
||||
<Group justify="center" grow>
|
||||
<Button
|
||||
variant="light"
|
||||
onClick={() => setOpenedPreview(!openedPreview)}
|
||||
>
|
||||
Surat
|
||||
</Button>
|
||||
</Group>
|
||||
)
|
||||
) :
|
||||
data?.status === "selesai" ?
|
||||
(
|
||||
<Group justify="center" grow>
|
||||
<Button
|
||||
variant="light"
|
||||
onClick={() => setOpenedPreview(!openedPreview)}
|
||||
>
|
||||
Surat
|
||||
</Button>
|
||||
</Group>
|
||||
)
|
||||
: <></>
|
||||
}
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function DetailPengaduanPage() {
|
||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||
apiFetch.api.pengaduan.detail.get({
|
||||
query: {
|
||||
nomerPengaduan: id!,
|
||||
id: id!,
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -70,7 +70,7 @@ export default function DetailPengaduanPage() {
|
||||
);
|
||||
}
|
||||
|
||||
function DetailDataPengaduan({ data, onAction }: { data: any, onAction: () => void }) {
|
||||
function DetailDataPengaduan({ data, onAction }: { data: any | null, onAction: () => void }) {
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [catModal, setCatModal] = useState<"tolak" | "terima">("tolak");
|
||||
const [openedPreview, setOpenedPreview] = useState(false);
|
||||
|
||||
@@ -151,18 +151,10 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
.get("/detail", async ({ query }) => {
|
||||
const { nomerPengajuan } = query
|
||||
console.log(nomerPengajuan, query)
|
||||
const { id } = query
|
||||
const data = await prisma.pelayananAjuan.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
noPengajuan: nomerPengajuan
|
||||
},
|
||||
{
|
||||
id: nomerPengajuan
|
||||
}
|
||||
]
|
||||
id: id
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -192,6 +184,17 @@ const PelayananRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
const datafix = {
|
||||
pengajuan: {},
|
||||
history: [],
|
||||
warga: {},
|
||||
syaratDokumen: [],
|
||||
dataText: [],
|
||||
}
|
||||
return datafix
|
||||
}
|
||||
|
||||
const dataSurat = await prisma.suratPelayanan.findFirst({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
@@ -303,16 +306,14 @@ const PelayananRoute = new Elysia({
|
||||
dataText: dataTextFix,
|
||||
}
|
||||
|
||||
console.log(datafix)
|
||||
return datafix
|
||||
}, {
|
||||
query: t.Object({
|
||||
nomerPengajuan: t.String({ minLength: 1, error: "nomer pengajuan harus diisi" }),
|
||||
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Ajuan Pelayanan Surat by Nomer Pengajuan",
|
||||
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan nomer pengajuan`,
|
||||
tags: ["mcp"]
|
||||
summary: "Detail Ajuan Pelayanan Surat by ID",
|
||||
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan id`,
|
||||
}
|
||||
})
|
||||
.post("/create", async ({ body, headers }) => {
|
||||
@@ -505,6 +506,171 @@ const PelayananRoute = new Elysia({
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/detail-data", async ({ body }) => {
|
||||
const { nomerPengajuan } = body
|
||||
const data = await prisma.pelayananAjuan.findFirst({
|
||||
where: {
|
||||
noPengajuan: nomerPengajuan
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noPengajuan: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
CategoryPelayanan: {
|
||||
select: {
|
||||
name: true,
|
||||
dataText: true,
|
||||
syaratDokumen: true,
|
||||
}
|
||||
},
|
||||
Warga: {
|
||||
select: {
|
||||
name: true,
|
||||
phone: true,
|
||||
_count: {
|
||||
select: {
|
||||
Pengaduan: true,
|
||||
PelayananAjuan: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
return { success: false, message: "Data tidak ditemukan" }
|
||||
}
|
||||
|
||||
const dataSurat = await prisma.suratPelayanan.findFirst({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
idCategory: true,
|
||||
}
|
||||
})
|
||||
|
||||
const dataSyarat = await prisma.syaratDokumenPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
jenis: true,
|
||||
value: true,
|
||||
}
|
||||
})
|
||||
|
||||
const dataText = await prisma.dataTextPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
isActive: true
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
value: true,
|
||||
jenis: true,
|
||||
}
|
||||
})
|
||||
const syaratDokumen = (data?.CategoryPelayanan?.syaratDokumen ?? []) as {
|
||||
name: string;
|
||||
desc: string;
|
||||
}[];
|
||||
|
||||
const dataSyaratFix = dataSyarat.map((item) => {
|
||||
const desc = syaratDokumen.find((v) => v.name == item.jenis)?.desc
|
||||
return {
|
||||
id: item.id,
|
||||
jenis: desc,
|
||||
value: item.value,
|
||||
}
|
||||
})
|
||||
|
||||
const dataTextFix = dataText.map((item) => {
|
||||
const desc = data?.CategoryPelayanan?.dataText.find((v) => v == item.jenis)
|
||||
return {
|
||||
id: item.id,
|
||||
jenis: item.jenis,
|
||||
value: item.value,
|
||||
}
|
||||
})
|
||||
|
||||
const dataHistory = await prisma.historyPelayanan.findMany({
|
||||
where: {
|
||||
idPengajuanLayanan: data?.id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const dataHistoryFix = dataHistory.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
deskripsi: item.deskripsi,
|
||||
status: item.status,
|
||||
createdAt: item.createdAt,
|
||||
idUser: item.idUser,
|
||||
nameUser: item.User?.name,
|
||||
}
|
||||
})
|
||||
|
||||
const warga = {
|
||||
name: data?.Warga?.name,
|
||||
phone: data?.Warga?.phone,
|
||||
pengaduan: data?.Warga?._count.Pengaduan,
|
||||
pelayanan: data?.Warga?._count.PelayananAjuan,
|
||||
}
|
||||
|
||||
const dataPengajuan = {
|
||||
id: data?.id,
|
||||
noPengajuan: data?.noPengajuan,
|
||||
category: data?.CategoryPelayanan.name,
|
||||
status: data?.status,
|
||||
createdAt: data?.createdAt,
|
||||
updatedAt: data?.updatedAt,
|
||||
idSurat: dataSurat?.id,
|
||||
}
|
||||
|
||||
const datafix = {
|
||||
pengajuan: dataPengajuan,
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
syaratDokumen: dataSyaratFix,
|
||||
dataText: dataTextFix,
|
||||
}
|
||||
|
||||
return datafix
|
||||
|
||||
}, {
|
||||
body: t.Object({
|
||||
nomerPengajuan: t.String({
|
||||
description: "Nomor pengajuan pelayanan surat yang ingin diakses.",
|
||||
examples: ["PS-101225-001", "PS-101225-002"],
|
||||
error: "Nomor pengajuan harus diisi"
|
||||
})
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Pengajuan Pelayanan Surat By Nomor Pengajuan",
|
||||
description: `tool untuk mendapatkan detail pengajuan pelayanan surat berdasarkan nomor pengajuan`,
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
.post("/update-status", async ({ body }) => {
|
||||
const { id, status, keterangan, idUser, noSurat } = body
|
||||
let deskripsi = ""
|
||||
|
||||
@@ -372,18 +372,11 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
.get("/detail", async ({ query }) => {
|
||||
const { nomerPengaduan } = query
|
||||
console.log(nomerPengaduan, query)
|
||||
const { id } = query
|
||||
|
||||
const data = await prisma.pengaduan.findFirst({
|
||||
where: {
|
||||
OR: [
|
||||
{
|
||||
noPengaduan: nomerPengaduan
|
||||
}, {
|
||||
id: nomerPengaduan
|
||||
}
|
||||
]
|
||||
id: id
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -418,6 +411,16 @@ const PengaduanRoute = new Elysia({
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
const datafix = {
|
||||
pengaduan: {},
|
||||
history: [],
|
||||
warga: {},
|
||||
}
|
||||
|
||||
return datafix
|
||||
}
|
||||
|
||||
const dataHistory = await prisma.historyPengaduan.findMany({
|
||||
where: {
|
||||
idPengaduan: data?.id,
|
||||
@@ -470,15 +473,13 @@ const PengaduanRoute = new Elysia({
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
}
|
||||
console.log(datafix)
|
||||
|
||||
return datafix
|
||||
|
||||
}, {
|
||||
detail: {
|
||||
summary: "Detail Pengaduan Warga by Nomer Pengaduan",
|
||||
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan nomer Pengaduan`,
|
||||
tags: ["mcp"]
|
||||
summary: "Detail Pengaduan Warga By ID",
|
||||
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan id pengaduan`,
|
||||
}
|
||||
})
|
||||
.get("/", async ({ query, headers }) => {
|
||||
@@ -887,6 +888,118 @@ const PengaduanRoute = new Elysia({
|
||||
description: "Tool untuk delete file Seafile",
|
||||
},
|
||||
})
|
||||
.post("/detail-data", async ({ body }) => {
|
||||
const { nomerPengaduan } = body
|
||||
|
||||
const data = await prisma.pengaduan.findFirst({
|
||||
where: {
|
||||
noPengaduan: nomerPengaduan
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
noPengaduan: true,
|
||||
title: true,
|
||||
detail: true,
|
||||
location: true,
|
||||
image: true,
|
||||
idCategory: true,
|
||||
idWarga: true,
|
||||
status: true,
|
||||
keterangan: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
CategoryPengaduan: {
|
||||
select: {
|
||||
name: true
|
||||
}
|
||||
},
|
||||
Warga: {
|
||||
select: {
|
||||
name: true,
|
||||
phone: true,
|
||||
_count: {
|
||||
select: {
|
||||
Pengaduan: true,
|
||||
PelayananAjuan: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (!data) {
|
||||
return { success: false, message: "Data tidak ditemukan" };
|
||||
}
|
||||
|
||||
const dataHistory = await prisma.historyPengaduan.findMany({
|
||||
where: {
|
||||
idPengaduan: data?.id,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
status: true,
|
||||
createdAt: true,
|
||||
idUser: true,
|
||||
User: {
|
||||
select: {
|
||||
name: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
const dataHistoryFix = dataHistory.map((item: any) => ({
|
||||
..._.omit(item, ["User", "createdAt"]),
|
||||
nameUser: item.User?.name,
|
||||
createdAt: item.createdAt
|
||||
}))
|
||||
|
||||
|
||||
const warga = {
|
||||
name: data?.Warga?.name,
|
||||
phone: data?.Warga?.phone,
|
||||
pengaduan: data?.Warga?._count.Pengaduan,
|
||||
pelayanan: data?.Warga?._count.PelayananAjuan,
|
||||
}
|
||||
|
||||
const dataPengaduan = {
|
||||
id: data?.id,
|
||||
noPengaduan: data?.noPengaduan,
|
||||
title: data?.title,
|
||||
detail: data?.detail,
|
||||
location: data?.location,
|
||||
image: data?.image,
|
||||
category: data?.CategoryPengaduan.name,
|
||||
status: data?.status,
|
||||
keterangan: data?.keterangan,
|
||||
createdAt: data?.createdAt,
|
||||
updatedAt: data?.updatedAt,
|
||||
}
|
||||
|
||||
const datafix = {
|
||||
pengaduan: dataPengaduan,
|
||||
history: dataHistoryFix,
|
||||
warga: warga,
|
||||
}
|
||||
|
||||
return datafix
|
||||
}, {
|
||||
body: t.Object({
|
||||
nomerPengaduan: t.String({
|
||||
description: "Nomer pengaduan yg ingin diakses",
|
||||
examples: ["PGD-101225-001", "PGD-101225-002"],
|
||||
error: "Nomer pengaduan harus diisi",
|
||||
}),
|
||||
}),
|
||||
detail: {
|
||||
summary: "Detail Pengaduan Warga By Nomor Pengaduan",
|
||||
description: `tool untuk mendapatkan detail data pengaduan berdasarkan nomor pengaduan`,
|
||||
tags: ["mcp"]
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
export default PengaduanRoute
|
||||
|
||||
Reference in New Issue
Block a user