/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable react-hooks/exhaustive-deps */ 'use client'; import colors from '@/con/colors'; import { Box, Button, Center, Group, Pagination, Paper, Skeleton, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text, Title, } from '@mantine/core'; import { IconAlertTriangle, IconAmbulance, IconBook, IconBuilding, IconBuildingCommunity, IconCash, IconChartLine, IconChristmasTreeFilled, IconClipboardTextFilled, IconDeviceImacCog, IconDroplet, IconFileText, IconFiretruck, IconFirstAidKit, IconHome, IconHomeEco, IconHospital, IconInfoCircle, IconLeaf, IconLifebuoy, IconMessageReport, IconPhoneCall, IconPlus, IconRecycle, IconRun, IconScale, IconSchool, IconSearch, IconShield, IconShieldFilled, IconShoppingCart, IconStethoscope, IconTent, IconTrashFilled, IconTree, IconTrendingUp, IconTrophy, IconTruckFilled, IconUsers, } from '@tabler/icons-react'; import { useRouter } from 'next/navigation'; import React, { useEffect, useState } from 'react'; import { useProxy } from 'valtio/utils'; import HeaderSearch from '../../_com/header'; import dataLingkunganDesaState from '../../_state/lingkungan/data-lingkungan-desa'; import { useDebouncedValue } from '@mantine/hooks'; function DataLingkunganDesa() { const [search, setSearch] = useState(''); return ( } value={search} onChange={(e) => setSearch(e.currentTarget.value)} /> ); } function ListDataLingkunganDesa({ search }: { search: string }) { const listState = useProxy(dataLingkunganDesaState); const { data, loading, page, totalPages, load } = listState.findMany; const router = useRouter(); const [debouncedSearch] = useDebouncedValue(search, 1000); useEffect(() => { load(page, 10, debouncedSearch); }, [page, debouncedSearch]); const filteredData = data || []; const iconMap: Record> = { // ===== Umum & Lingkungan ===== ekowisata: IconLeaf, kompetisi: IconTrophy, wisata: IconTent, ekonomi: IconChartLine, sampah: IconRecycle, truck: IconTruckFilled, scale: IconScale, clipboard: IconClipboardTextFilled, trash: IconTrashFilled, lingkunganSehat: IconHomeEco, sumberOksigen: IconChristmasTreeFilled, ekonomiBerkelanjutan: IconTrendingUp, mencegahBencana: IconShieldFilled, rumah: IconHome, pohon: IconTree, air: IconDroplet, bantuan: IconCash, pelatihan: IconSchool, subsidi: IconShoppingCart, layananKesehatan: IconHospital, // ===== Keamanan & Darurat ===== polisi: IconShieldFilled, ambulans: IconAmbulance, pemadam: IconFiretruck, darurat: IconAlertTriangle, sar: IconLifebuoy, evakuasi: IconRun, keamanan: IconShield, teleponDarurat: IconPhoneCall, // ===== Kesehatan ===== rumahSakit: IconHospital, puskesmas: IconFirstAidKit, klinik: IconStethoscope, // ===== Pemerintahan & Fasilitas ===== bangunan: IconBuilding, kantorDesa: IconBuildingCommunity, administrasi: IconFileText, informasi: IconInfoCircle, pengaduan: IconMessageReport, layananPublik: IconUsers, book: IconBook }; if (loading || !data) { return ( ); } if (data.length === 0) { return ( Daftar Data Lingkungan Desa No Nama Data Lingkungan Desa Jumlah Ikon Detail
Tidak ada data lingkungan desa yang tersedia
); } return ( Daftar Data Lingkungan Desa {/* Desktop Table */} No Nama Data Jumlah Ikon Detail {filteredData.map((item, index) => ( {index + 1} {item.name} ± {item.jumlah} {iconMap[item.icon] && {React.createElement(iconMap[item.icon], { size: 22 })}} ))}
{/* Mobile Cards */} {filteredData.map((item, index) => ( No {index + 1} Nama Data {item.name} Jumlah ± {item.jumlah} Ikon {iconMap[item.icon] && {React.createElement(iconMap[item.icon], { size: 22 })}}
))}
{ load(newPage, 10); window.scrollTo({ top: 0, behavior: 'smooth' }); }} total={totalPages} mt="md" mb="md" color="blue" radius="md" />
); } export default DataLingkunganDesa;