import DesaSetting from "@/components/DesaSetting"; import KategoriPelayananSurat from "@/components/KategoriPelayananSurat"; import KategoriPengaduan from "@/components/KategoriPengaduan"; import ProfileUser from "@/components/ProfileUser"; import UserRoleSetting from "@/components/UserRoleSetting"; import UserSetting from "@/components/UserSetting"; import apiFetch from "@/lib/apiFetch"; import { Card, Container, Grid, NavLink } from "@mantine/core"; import { IconBuildingBank, IconCategory2, IconMailSpark, IconUserCog, IconUserScreen, IconUsersGroup } from "@tabler/icons-react"; import type { JsonValue } from "generated/prisma/runtime/library"; import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; export default function DetailSettingPage() { const { search } = useLocation(); const query = new URLSearchParams(search); const type = query.get("type"); const [permissions, setPermissions] = useState([]); useEffect(() => { async function fetchPermissions() { const { data } = await apiFetch.api.user.find.get(); if (Array.isArray(data?.permissions)) { const onlySetting = data.permissions.filter((p: any) => p.startsWith("setting")); setPermissions(onlySetting); } else { setPermissions([]); } } fetchPermissions(); }, []); const navItems = [ { key: "setting.profile", path: "profile", icon: , label: "Profile", description: "Manage profile settings", }, { key: "setting.user", path: "user", icon: , label: "User", description: "Manage user accounts", }, { key: "setting.user_role", path: "role", icon: , label: "Role", description: "Manage user roles", }, { key: "setting.kategori_pengaduan", path: "cat-pengaduan", icon: , label: "Kategori Pengaduan", description: "Manage complaint categories", }, { key: "setting.kategori_pelayanan", path: "cat-pelayanan", icon: , label: "Kategori Pelayanan Surat", description: "Manage letter service categories", }, { key: "setting.desa", path: "desa", icon: , label: "Desa", description: "Manage desa information", } ]; return ( { navItems.filter((item) => permissions.includes(item.key)).map((item) => ( )) } {type === "cat-pengaduan" ? ( typeof p === 'string' && p.startsWith("setting.kategori_pengaduan"))} /> ) : type === "cat-pelayanan" ? ( typeof p === 'string' && p.startsWith("setting.kategori_pelayanan"))} /> ) : type === "desa" ? ( typeof p === 'string' && p.startsWith("setting.desa"))} /> ) : type === "user" ? ( typeof p === 'string' && p.startsWith("setting.user."))} /> ) : type === "role" ? ( typeof p === 'string' && p.startsWith("setting.user_role"))} /> ) : ( typeof p === 'string' && p.startsWith("setting.profile"))} /> )} ); }