diff --git a/src/pages/scr/dashboard/pengaduan/detail_page.tsx b/src/pages/scr/dashboard/pengaduan/detail_page.tsx
index 0be588d..144a88e 100644
--- a/src/pages/scr/dashboard/pengaduan/detail_page.tsx
+++ b/src/pages/scr/dashboard/pengaduan/detail_page.tsx
@@ -1,3 +1,4 @@
+import notification from "@/components/notificationGlobal";
import apiFetch from "@/lib/apiFetch";
import {
Anchor,
@@ -17,7 +18,7 @@ import {
Textarea,
Title,
} from "@mantine/core";
-import { useDisclosure } from "@mantine/hooks";
+import { useDisclosure, useShallowEffect } from "@mantine/hooks";
import {
IconAlignJustified,
IconCategory,
@@ -25,14 +26,15 @@ import {
IconInfoTriangle,
IconMapPin,
IconMessageReport,
+ IconPhone,
IconPhotoScan,
IconUser,
} from "@tabler/icons-react";
+import type { User } from "generated/prisma";
import _ from "lodash";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import useSwr from "swr";
-import { useShallowEffect } from "@mantine/hooks";
export default function DetailPengaduanPage() {
const { search } = useLocation();
@@ -55,7 +57,7 @@ export default function DetailPengaduanPage() {
-
+ { mutate(); }} />
@@ -67,24 +69,57 @@ export default function DetailPengaduanPage() {
);
}
-function DetailDataPengaduan({ data }: { data: any }) {
+function DetailDataPengaduan({ data, onAction }: { data: any, onAction: () => void }) {
const [opened, { open, close }] = useDisclosure(false);
const [catModal, setCatModal] = useState<"tolak" | "terima">("tolak");
const [imageSrc, setImageSrc] = useState(null);
const [openedModalImage, { open: openModalImage, close: closeModalImage }] =
useDisclosure(false);
+ const [keterangan, setKeterangan] = useState("");
+ const [host, setHost] = useState(null);
- // async function handleLihatGambar() {
- // const res = await apiFetch.api.pengaduan.image.get({
- // query: {
- // fileName: "57d5ce89-7d18-4244-9f4c-ca21b70adb7e",
- // },
- // });
- // console.error("client", res);
- // // const blob = await res.data?.blob();
- // // setImageSrc(URL.createObjectURL(blob!));
- // // openModalImage();
- // }
+ useEffect(() => {
+ async function fetchHost() {
+ const { data } = await apiFetch.api.user.find.get();
+ setHost(data?.user ?? null);
+ }
+ fetchHost();
+ }, []);
+
+ const handleKonfirmasi = async (cat: "terima" | "tolak") => {
+ try {
+ const res = await apiFetch.api.pengaduan["update-status"].post({
+ id: data?.id,
+ status: cat == 'tolak' ? 'ditolak' : data.status == 'antrian' ? 'diterima' : data.status == 'diterima' ? 'dikerjakan' : 'selesai',
+ keterangan: keterangan,
+ idUser: host?.id ?? ""
+ });
+
+ if (res?.status === 200) {
+ onAction();
+ close();
+ notification({
+ title: "Success",
+ message: "Success update pengaduan",
+ type: "success",
+ });
+ } else {
+ notification({
+ title: "Error",
+ message: "Failed to update pengaduan",
+ type: "error",
+ });
+ }
+
+ } catch (error) {
+ console.error(error);
+ notification({
+ title: "Error",
+ message: "Failed to update pengaduan",
+ type: "error",
+ });
+ }
+ }
return (
<>
@@ -94,7 +129,6 @@ function DetailDataPengaduan({ data }: { data: any }) {
opened={opened}
onClose={close}
title={"Konfirmasi"}
- centered
overlayProps={{ backgroundOpacity: 0.55, blur: 3 }}
>
@@ -104,25 +138,25 @@ function DetailDataPengaduan({ data }: { data: any }) {
Anda yakin ingin menolak pengaduan ini? Berikan alasan penolakan
-
+
-
-
-
-
+ {
+ data?.status === "antrian" ? (
+
+
+
+
+ ) : data?.status === "diterima" ? (
+
+
+
+ ) : data?.status === "dikerjakan" ? (
+
+
+
+ ) : <>>
+ }
@@ -317,10 +378,10 @@ function DetailDataHistori({ data }: { data: any }) {
{
data?.map((item: any) => (
- {item.createdAt}
+ {item.createdAt}
{item.deskripsi}
{item.status}
- {item.user}
+ {item.nameUser ? item.nameUser : "-"}
))
}
@@ -365,7 +426,7 @@ function DetailUserPengaduan({ data }: { data: any }) {
-
+
Telepon
diff --git a/src/pages/scr/dashboard/pengaduan/list_page.tsx b/src/pages/scr/dashboard/pengaduan/list_page.tsx
index 4f86a46..e1472ed 100644
--- a/src/pages/scr/dashboard/pengaduan/list_page.tsx
+++ b/src/pages/scr/dashboard/pengaduan/list_page.tsx
@@ -233,7 +233,7 @@ function ListPengaduan({ status }: { status: StatusKey }) {
: v.status === "selesai"
? "blue"
: v.status === "dikerjakan"
- ? "purple"
+ ? "gray"
: "yellow"
}
style={{ textTransform: "none" }}
diff --git a/src/server/routes/pengaduan_route.ts b/src/server/routes/pengaduan_route.ts
index 292179d..2253d9f 100644
--- a/src/server/routes/pengaduan_route.ts
+++ b/src/server/routes/pengaduan_route.ts
@@ -383,7 +383,14 @@ Respon:
id: item.id,
deskripsi: item.deskripsi,
status: item.status,
- createdAt: item.createdAt.toLocaleDateString("id-ID", { day: "numeric", month: "long", year: "numeric" }),
+ createdAt: item.createdAt.toLocaleString("id-ID", {
+ day: "2-digit",
+ month: "short",
+ year: "numeric",
+ hour: "2-digit",
+ minute: "2-digit",
+ hour12: false
+ }),
idUser: item.idUser,
nameUser: item.User?.name,
}