tampilan pelayanan surat
Deskripsi: - tampilan list pelayanan surat No Issues
This commit is contained in:
@@ -17,6 +17,7 @@ import FormSuratKeteranganKelakuanBaik from "./pages/darmasaba/form_surat_ketera
|
|||||||
import Home from "./pages/Home";
|
import Home from "./pages/Home";
|
||||||
import CredentialPage from "./pages/scr/dashboard/credential/credential_page";
|
import CredentialPage from "./pages/scr/dashboard/credential/credential_page";
|
||||||
import DashboardHome from "./pages/scr/dashboard/dashboard_home";
|
import DashboardHome from "./pages/scr/dashboard/dashboard_home";
|
||||||
|
import ListPelayananPage from "./pages/scr/dashboard/pelayanan-surat/list_pelayanan_page";
|
||||||
import ListPage from "./pages/scr/dashboard/pengaduan/list_page";
|
import ListPage from "./pages/scr/dashboard/pengaduan/list_page";
|
||||||
import ApikeyPage from "./pages/scr/dashboard/apikey/apikey_page";
|
import ApikeyPage from "./pages/scr/dashboard/apikey/apikey_page";
|
||||||
import DashboardLayout from "./pages/scr/dashboard/dashboard_layout";
|
import DashboardLayout from "./pages/scr/dashboard/dashboard_layout";
|
||||||
@@ -93,6 +94,10 @@ export default function AppRoutes() {
|
|||||||
path="/scr/dashboard/dashboard-home"
|
path="/scr/dashboard/dashboard-home"
|
||||||
element={<DashboardHome />}
|
element={<DashboardHome />}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path="/scr/dashboard/pelayanan-surat/list-pelayanan"
|
||||||
|
element={<ListPelayananPage />}
|
||||||
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/scr/dashboard/pengaduan/list"
|
path="/scr/dashboard/pengaduan/list"
|
||||||
element={<ListPage />}
|
element={<ListPage />}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const clientRoutes = {
|
|||||||
"/scr/dashboard": "/scr/dashboard",
|
"/scr/dashboard": "/scr/dashboard",
|
||||||
"/scr/dashboard/credential/credential": "/scr/dashboard/credential/credential",
|
"/scr/dashboard/credential/credential": "/scr/dashboard/credential/credential",
|
||||||
"/scr/dashboard/dashboard-home": "/scr/dashboard/dashboard-home",
|
"/scr/dashboard/dashboard-home": "/scr/dashboard/dashboard-home",
|
||||||
|
"/scr/dashboard/pelayanan-surat/list-pelayanan": "/scr/dashboard/pelayanan-surat/list-pelayanan",
|
||||||
"/scr/dashboard/pengaduan/list": "/scr/dashboard/pengaduan/list",
|
"/scr/dashboard/pengaduan/list": "/scr/dashboard/pengaduan/list",
|
||||||
"/scr/dashboard/apikey/apikey": "/scr/dashboard/apikey/apikey",
|
"/scr/dashboard/apikey/apikey": "/scr/dashboard/apikey/apikey",
|
||||||
"/dir/dir": "/dir/dir",
|
"/dir/dir": "/dir/dir",
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ function NavigationDashboard() {
|
|||||||
description: "Manage pengaduan warga",
|
description: "Manage pengaduan warga",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/scr/dashboard/pelayanan",
|
path: "/scr/dashboard/pelayanan-surat/list-pelayanan",
|
||||||
icon: <IconFileCertificate size={20} />,
|
icon: <IconFileCertificate size={20} />,
|
||||||
label: "Pelayanan Surat",
|
label: "Pelayanan Surat",
|
||||||
description: "Manage pelayanan surat",
|
description: "Manage pelayanan surat",
|
||||||
|
|||||||
271
src/pages/scr/dashboard/pelayanan-surat/list_pelayanan_page.tsx
Normal file
271
src/pages/scr/dashboard/pelayanan-surat/list_pelayanan_page.tsx
Normal file
@@ -0,0 +1,271 @@
|
|||||||
|
import apiFetch from "@/lib/apiFetch";
|
||||||
|
import {
|
||||||
|
Badge,
|
||||||
|
Card,
|
||||||
|
CloseButton,
|
||||||
|
Container,
|
||||||
|
Divider,
|
||||||
|
Flex,
|
||||||
|
Group,
|
||||||
|
Input,
|
||||||
|
Stack,
|
||||||
|
Tabs,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
|
import {
|
||||||
|
IconAlignJustified,
|
||||||
|
IconClockHour3,
|
||||||
|
IconFileSad,
|
||||||
|
IconMapPin,
|
||||||
|
IconSearch,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
import useSwr from "swr";
|
||||||
|
import { proxy } from "valtio";
|
||||||
|
|
||||||
|
const state = proxy({ reload: "" });
|
||||||
|
function reloadState() {
|
||||||
|
state.reload = Math.random().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PelayananSuratListPage() {
|
||||||
|
const { search } = useLocation();
|
||||||
|
const query = new URLSearchParams(search);
|
||||||
|
const status = query.get("status") as StatusKey;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container size="xl" py="xl" w={"100%"}>
|
||||||
|
<Stack gap="xl">
|
||||||
|
<TabListPelayananSurat status={status || "semua"} />
|
||||||
|
<ListPelayananSurat status={status || "semua"} />
|
||||||
|
</Stack>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function TabListPelayananSurat({ status }: { status: string }) {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const dataCount = useSwr("/pelayanan-surat/count", () =>
|
||||||
|
apiFetch.api.pengaduan.count.get().then((res) => res.data),
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tabs defaultValue={status || "semua"} color="teal">
|
||||||
|
<Tabs.List grow>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="all"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=semua");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Semua ({dataCount?.data?.semua || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="antrian"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=antrian");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Antrian ({dataCount?.data?.antrian || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="diterima"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=diterima");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Diterima ({dataCount?.data?.diterima || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="dikerjakan"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=dikerjakan");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Dikerjakan ({dataCount?.data?.dikerjakan || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="selesai"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=selesai");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Selesai ({dataCount?.data?.selesai || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
<Tabs.Tab
|
||||||
|
value="ditolak"
|
||||||
|
onClick={() => {
|
||||||
|
navigate("?status=ditolak");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Ditolak ({dataCount?.data?.ditolak || 0})
|
||||||
|
</Tabs.Tab>
|
||||||
|
</Tabs.List>
|
||||||
|
</Tabs>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type StatusKey =
|
||||||
|
| "antrian"
|
||||||
|
| "diterima"
|
||||||
|
| "dikerjakan"
|
||||||
|
| "ditolak"
|
||||||
|
| "selesai"
|
||||||
|
| "semua";
|
||||||
|
function ListPelayananSurat({ status }: { status: StatusKey }) {
|
||||||
|
const [page, setPage] = useState(1);
|
||||||
|
const [value, setValue] = useState("");
|
||||||
|
const { data, mutate, isLoading } = useSwr("/", () =>
|
||||||
|
apiFetch.api.pengaduan.list.get({
|
||||||
|
query: {
|
||||||
|
status,
|
||||||
|
search: value,
|
||||||
|
take: "",
|
||||||
|
page: "",
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
mutate();
|
||||||
|
}, [status, value]);
|
||||||
|
|
||||||
|
if (isLoading)
|
||||||
|
return (
|
||||||
|
<Card
|
||||||
|
radius="lg"
|
||||||
|
p="xl"
|
||||||
|
withBorder
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
Loading pengaduan...
|
||||||
|
</Text>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
|
||||||
|
const list = data?.data || [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack gap="xl">
|
||||||
|
<Group grow>
|
||||||
|
<Input
|
||||||
|
value={value}
|
||||||
|
placeholder="Cari pengaduan..."
|
||||||
|
onChange={(event) => setValue(event.currentTarget.value)}
|
||||||
|
leftSection={<IconSearch size={16} />}
|
||||||
|
rightSectionPointerEvents="all"
|
||||||
|
rightSection={
|
||||||
|
<CloseButton
|
||||||
|
aria-label="Clear input"
|
||||||
|
onClick={() => setValue("")}
|
||||||
|
style={{ display: value ? undefined : "none" }}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{/* <Group justify="flex-end">
|
||||||
|
<Text size="sm">Menampilkan {Number(data?.data?.length) * (page - 1) + 1} – {Math.min(10, Number(data?.data?.length) * page)} dari {Number(data?.data?.length)}</Text>
|
||||||
|
<Pagination total={Number(data?.data?.length)} value={page} onChange={setPage} withPages={false} />
|
||||||
|
</Group> */}
|
||||||
|
</Group>
|
||||||
|
{list.length === 0 ? (
|
||||||
|
<Flex justify="center" align="center" py={"xl"}>
|
||||||
|
<Stack gap={4} align="center">
|
||||||
|
<IconFileSad size={32} color="gray" />
|
||||||
|
<Text c="dimmed" size="sm">
|
||||||
|
No pengaduan have been added yet.
|
||||||
|
</Text>
|
||||||
|
</Stack>
|
||||||
|
</Flex>
|
||||||
|
) : (
|
||||||
|
list.map((v: any) => (
|
||||||
|
<Card
|
||||||
|
key={v.id}
|
||||||
|
radius="lg"
|
||||||
|
p="xl"
|
||||||
|
withBorder
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
"linear-gradient(145deg, rgba(25,25,25,0.95), rgba(45,45,45,0.85))",
|
||||||
|
borderColor: "rgba(100,100,100,0.2)",
|
||||||
|
boxShadow: "0 0 20px rgba(0,255,200,0.08)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack gap="md">
|
||||||
|
<Flex align="center" justify="space-between">
|
||||||
|
<Flex direction={"column"}>
|
||||||
|
<Title order={3} c="gray.2">
|
||||||
|
{v.title}
|
||||||
|
</Title>
|
||||||
|
<Group>
|
||||||
|
<Title order={6} c="gray.5">
|
||||||
|
#{v.noPengaduan}
|
||||||
|
</Title>
|
||||||
|
<Text size="sm" c="dimmed">
|
||||||
|
{v.updatedAt}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Flex>
|
||||||
|
<Badge
|
||||||
|
size="xl"
|
||||||
|
variant="light"
|
||||||
|
radius="sm"
|
||||||
|
color={
|
||||||
|
v.status === "diterima"
|
||||||
|
? "green"
|
||||||
|
: v.status === "ditolak"
|
||||||
|
? "red"
|
||||||
|
: v.status === "selesai"
|
||||||
|
? "blue"
|
||||||
|
: v.status === "dikerjakan"
|
||||||
|
? "purple"
|
||||||
|
: "yellow"
|
||||||
|
}
|
||||||
|
style={{ textTransform: "none" }}
|
||||||
|
>
|
||||||
|
{v.status}
|
||||||
|
</Badge>
|
||||||
|
</Flex>
|
||||||
|
<Divider my={0} />
|
||||||
|
<Stack gap="sm">
|
||||||
|
<Flex direction={"column"} justify="flex-start">
|
||||||
|
<Group gap="xs">
|
||||||
|
<IconClockHour3 size={20} color="white" />
|
||||||
|
<Text size="md" c="white">
|
||||||
|
Tanggal Aduan
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Text size="md">{v.createdAt}</Text>
|
||||||
|
</Flex>
|
||||||
|
<Flex direction={"column"} justify="flex-start">
|
||||||
|
<Group gap="xs">
|
||||||
|
<IconMapPin size={20} color="white" />
|
||||||
|
<Text size="md" c="white">
|
||||||
|
Lokasi
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Text size="md">{v.location}</Text>
|
||||||
|
</Flex>
|
||||||
|
<Flex direction={"column"} justify="flex-start">
|
||||||
|
<Group gap="xs">
|
||||||
|
<IconAlignJustified size={20} color="white" />
|
||||||
|
<Text size="md" c="white">
|
||||||
|
Detail
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
<Text size="md">{v.detail}</Text>
|
||||||
|
</Flex>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</Card>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Tabs,
|
Tabs,
|
||||||
Text,
|
Text,
|
||||||
Title
|
Title,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useShallowEffect } from "@mantine/hooks";
|
import { useShallowEffect } from "@mantine/hooks";
|
||||||
import {
|
import {
|
||||||
@@ -108,7 +108,13 @@ function TabListPengaduan({ status }: { status: string }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatusKey = "antrian" | "diterima" | "dikerjakan" | "ditolak" | "selesai" | "semua";
|
type StatusKey =
|
||||||
|
| "antrian"
|
||||||
|
| "diterima"
|
||||||
|
| "dikerjakan"
|
||||||
|
| "ditolak"
|
||||||
|
| "selesai"
|
||||||
|
| "semua";
|
||||||
function ListPengaduan({ status }: { status: StatusKey }) {
|
function ListPengaduan({ status }: { status: StatusKey }) {
|
||||||
const [page, setPage] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [value, setValue] = useState("");
|
const [value, setValue] = useState("");
|
||||||
@@ -158,8 +164,8 @@ function ListPengaduan({ status }: { status: StatusKey }) {
|
|||||||
rightSection={
|
rightSection={
|
||||||
<CloseButton
|
<CloseButton
|
||||||
aria-label="Clear input"
|
aria-label="Clear input"
|
||||||
onClick={() => setValue('')}
|
onClick={() => setValue("")}
|
||||||
style={{ display: value ? undefined : 'none' }}
|
style={{ display: value ? undefined : "none" }}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user