Merge pull request 'upd: api jenna ai' (#75) from amalia/11-des-25 into main
Reviewed-on: http://wibugit.wibudev.com/wibu/jenna-mcp/pulls/75
This commit is contained in:
@@ -45,7 +45,7 @@ export default function DetailPengajuanPage() {
|
|||||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||||
apiFetch.api.pelayanan.detail.get({
|
apiFetch.api.pelayanan.detail.get({
|
||||||
query: {
|
query: {
|
||||||
nomerPengajuan: id!,
|
id: id!,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -343,16 +343,19 @@ function DetailDataPengajuan({ data, syaratDokumen, dataText, onAction }: { data
|
|||||||
Setujui
|
Setujui
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
) : (
|
) :
|
||||||
<Group justify="center" grow>
|
data?.status === "selesai" ?
|
||||||
<Button
|
(
|
||||||
variant="light"
|
<Group justify="center" grow>
|
||||||
onClick={() => setOpenedPreview(!openedPreview)}
|
<Button
|
||||||
>
|
variant="light"
|
||||||
Surat
|
onClick={() => setOpenedPreview(!openedPreview)}
|
||||||
</Button>
|
>
|
||||||
</Group>
|
Surat
|
||||||
)
|
</Button>
|
||||||
|
</Group>
|
||||||
|
)
|
||||||
|
: <></>
|
||||||
}
|
}
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export default function DetailPengaduanPage() {
|
|||||||
const { data, mutate, isLoading } = useSwr("/", () =>
|
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||||
apiFetch.api.pengaduan.detail.get({
|
apiFetch.api.pengaduan.detail.get({
|
||||||
query: {
|
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 [opened, { open, close }] = useDisclosure(false);
|
||||||
const [catModal, setCatModal] = useState<"tolak" | "terima">("tolak");
|
const [catModal, setCatModal] = useState<"tolak" | "terima">("tolak");
|
||||||
const [openedPreview, setOpenedPreview] = useState(false);
|
const [openedPreview, setOpenedPreview] = useState(false);
|
||||||
|
|||||||
@@ -151,18 +151,10 @@ const PelayananRoute = new Elysia({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.get("/detail", async ({ query }) => {
|
.get("/detail", async ({ query }) => {
|
||||||
const { nomerPengajuan } = query
|
const { id } = query
|
||||||
console.log(nomerPengajuan, query)
|
|
||||||
const data = await prisma.pelayananAjuan.findFirst({
|
const data = await prisma.pelayananAjuan.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
id: id
|
||||||
{
|
|
||||||
noPengajuan: nomerPengajuan
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: nomerPengajuan
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
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({
|
const dataSurat = await prisma.suratPelayanan.findFirst({
|
||||||
where: {
|
where: {
|
||||||
idPengajuanLayanan: data?.id,
|
idPengajuanLayanan: data?.id,
|
||||||
@@ -303,16 +306,14 @@ const PelayananRoute = new Elysia({
|
|||||||
dataText: dataTextFix,
|
dataText: dataTextFix,
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(datafix)
|
|
||||||
return datafix
|
return datafix
|
||||||
}, {
|
}, {
|
||||||
query: t.Object({
|
query: t.Object({
|
||||||
nomerPengajuan: t.String({ minLength: 1, error: "nomer pengajuan harus diisi" }),
|
id: t.String({ minLength: 1, error: "id harus diisi" }),
|
||||||
}),
|
}),
|
||||||
detail: {
|
detail: {
|
||||||
summary: "Detail Ajuan Pelayanan Surat by Nomer Pengajuan",
|
summary: "Detail Ajuan Pelayanan Surat by ID",
|
||||||
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan nomer pengajuan`,
|
description: `tool untuk mendapatkan detail ajuan pelayanan surat berdasarkan id`,
|
||||||
tags: ["mcp"]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.post("/create", async ({ body, headers }) => {
|
.post("/create", async ({ body, headers }) => {
|
||||||
@@ -505,6 +506,171 @@ const PelayananRoute = new Elysia({
|
|||||||
tags: ["mcp"]
|
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 }) => {
|
.post("/update-status", async ({ body }) => {
|
||||||
const { id, status, keterangan, idUser, noSurat } = body
|
const { id, status, keterangan, idUser, noSurat } = body
|
||||||
let deskripsi = ""
|
let deskripsi = ""
|
||||||
|
|||||||
@@ -372,18 +372,11 @@ const PengaduanRoute = new Elysia({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.get("/detail", async ({ query }) => {
|
.get("/detail", async ({ query }) => {
|
||||||
const { nomerPengaduan } = query
|
const { id } = query
|
||||||
console.log(nomerPengaduan, query)
|
|
||||||
|
|
||||||
const data = await prisma.pengaduan.findFirst({
|
const data = await prisma.pengaduan.findFirst({
|
||||||
where: {
|
where: {
|
||||||
OR: [
|
id: id
|
||||||
{
|
|
||||||
noPengaduan: nomerPengaduan
|
|
||||||
}, {
|
|
||||||
id: nomerPengaduan
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
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({
|
const dataHistory = await prisma.historyPengaduan.findMany({
|
||||||
where: {
|
where: {
|
||||||
idPengaduan: data?.id,
|
idPengaduan: data?.id,
|
||||||
@@ -470,15 +473,13 @@ const PengaduanRoute = new Elysia({
|
|||||||
history: dataHistoryFix,
|
history: dataHistoryFix,
|
||||||
warga: warga,
|
warga: warga,
|
||||||
}
|
}
|
||||||
console.log(datafix)
|
|
||||||
|
|
||||||
return datafix
|
return datafix
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
detail: {
|
detail: {
|
||||||
summary: "Detail Pengaduan Warga by Nomer Pengaduan",
|
summary: "Detail Pengaduan Warga By ID",
|
||||||
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan nomer Pengaduan`,
|
description: `tool untuk mendapatkan detail pengaduan warga / history pengaduan / mengecek status pengaduan berdasarkan id pengaduan`,
|
||||||
tags: ["mcp"]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.get("/", async ({ query, headers }) => {
|
.get("/", async ({ query, headers }) => {
|
||||||
@@ -887,6 +888,118 @@ const PengaduanRoute = new Elysia({
|
|||||||
description: "Tool untuk delete file Seafile",
|
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
|
export default PengaduanRoute
|
||||||
|
|||||||
Reference in New Issue
Block a user