fix: make dashboard public and remove admin-only restriction from main pages
- Make homepage (/) accessible without authentication - Allow all authenticated users (user & admin) to access main pages: - /kinerja-divisi, /pengaduan, /jenna, /demografi - /keuangan, /bumdes, /sosial, /keamanan - /bantuan, /pengaturan - Reserve admin-only access for /admin/* routes - Update auth middleware to handle public routes properly Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Collapse,
|
||||
Image,
|
||||
Group,
|
||||
Input,
|
||||
NavLink as MantineNavLink,
|
||||
Stack,
|
||||
useMantineColorScheme
|
||||
Text,
|
||||
useMantineColorScheme,
|
||||
} from "@mantine/core";
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
import { ChevronDown, ChevronUp, Search } from "lucide-react";
|
||||
@@ -25,35 +27,29 @@ export function Sidebar({ className }: SidebarProps) {
|
||||
|
||||
// State for settings submenu collapse
|
||||
const [settingsOpen, setSettingsOpen] = useState(
|
||||
location.pathname.startsWith("/dashboard/pengaturan"),
|
||||
location.pathname.startsWith("/pengaturan"),
|
||||
);
|
||||
|
||||
// Define menu items with their paths
|
||||
const menuItems = [
|
||||
{ name: "Beranda", path: "/dashboard" },
|
||||
{ name: "Kinerja Divisi", path: "/dashboard/kinerja-divisi" },
|
||||
{
|
||||
name: "Pengaduan & Layanan Publik",
|
||||
path: "/dashboard/pengaduan-layanan-publik",
|
||||
},
|
||||
{ name: "Jenna Analytic", path: "/dashboard/jenna-analytic" },
|
||||
{
|
||||
name: "Demografi & Kependudukan",
|
||||
path: "/dashboard/demografi-pekerjaan",
|
||||
},
|
||||
{ name: "Keuangan & Anggaran", path: "/dashboard/keuangan-anggaran" },
|
||||
{ name: "Bumdes & UMKM Desa", path: "/dashboard/bumdes" },
|
||||
{ name: "Sosial", path: "/dashboard/sosial" },
|
||||
{ name: "Keamanan", path: "/dashboard/keamanan" },
|
||||
{ name: "Bantuan", path: "/dashboard/bantuan" },
|
||||
{ name: "Beranda", path: "/" },
|
||||
{ name: "Kinerja Divisi", path: "/kinerja-divisi" },
|
||||
{ name: "Pengaduan & Layanan Publik", path: "/pengaduan-layanan-publik" },
|
||||
{ name: "Jenna Analytic", path: "/jenna-analytic" },
|
||||
{ name: "Demografi & Kependudukan", path: "/demografi-pekerjaan" },
|
||||
{ name: "Keuangan & Anggaran", path: "/keuangan-anggaran" },
|
||||
{ name: "Bumdes & UMKM Desa", path: "/bumdes" },
|
||||
{ name: "Sosial", path: "/sosial" },
|
||||
{ name: "Keamanan", path: "/keamanan" },
|
||||
{ name: "Bantuan", path: "/bantuan" },
|
||||
];
|
||||
|
||||
// Settings submenu items
|
||||
const settingsItems = [
|
||||
{ name: "Umum", path: "/dashboard/pengaturan/umum" },
|
||||
{ name: "Notifikasi", path: "/dashboard/pengaturan/notifikasi" },
|
||||
{ name: "Keamanan", path: "/dashboard/pengaturan/keamanan" },
|
||||
{ name: "Akses & Tim", path: "/dashboard/pengaturan/akses-dan-tim" },
|
||||
{ name: "Umum", path: "/pengaturan/umum" },
|
||||
{ name: "Notifikasi", path: "/pengaturan/notifikasi" },
|
||||
{ name: "Keamanan", path: "/pengaturan/keamanan" },
|
||||
{ name: "Akses & Tim", path: "/pengaturan/akses-dan-tim" },
|
||||
];
|
||||
|
||||
// Check if any settings submenu is active
|
||||
@@ -61,12 +57,33 @@ export function Sidebar({ className }: SidebarProps) {
|
||||
(item) => location.pathname === item.path,
|
||||
);
|
||||
|
||||
const headerBgColor = colorScheme === "dark" ? "#ebedf0ff" : "#19355E";
|
||||
|
||||
return (
|
||||
<Box className={className}>
|
||||
{/* Logo */}
|
||||
<Image src={"/logo-desa-plus.png"} width={201} height={84} />
|
||||
<Box
|
||||
p="md"
|
||||
style={{ borderBottom: "1px solid var(--mantine-color-gray-3)" }}
|
||||
>
|
||||
<Group gap="xs">
|
||||
<Badge
|
||||
color="dark"
|
||||
variant="filled"
|
||||
size="xl"
|
||||
radius="md"
|
||||
py="xs"
|
||||
px="md"
|
||||
style={{ fontSize: "1.5rem", fontWeight: "bold" }}
|
||||
>
|
||||
DESA
|
||||
</Badge>
|
||||
<Badge color="green" variant="filled" size="md" radius="md">
|
||||
+
|
||||
</Badge>
|
||||
</Group>
|
||||
<Text size="xs" c="dimmed" mt="xs">
|
||||
Digitalisasi Desa Transparansi Kerja
|
||||
</Text>
|
||||
</Box>
|
||||
|
||||
{/* Search */}
|
||||
<Box p="md">
|
||||
@@ -94,7 +111,7 @@ export function Sidebar({ className }: SidebarProps) {
|
||||
label={item.name}
|
||||
active={isActive}
|
||||
variant="subtle"
|
||||
color={headerBgColor}
|
||||
color="blue"
|
||||
style={{
|
||||
background: isActive ? isActiveBg : "transparent",
|
||||
fontWeight: isActive ? "bold" : "normal",
|
||||
@@ -186,6 +203,5 @@ export function Sidebar({ className }: SidebarProps) {
|
||||
</Box>
|
||||
</Stack>
|
||||
</Box>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user