Fix QC Kak Inno 17 Okt 25, Fix QC Kak Ayu 17 Okt 25, & Fix Qc Pak Jun 17 Okt 25
This commit is contained in:
@@ -43,15 +43,48 @@ export default function Page() {
|
||||
const loadingGrid = state.findMany.loading;
|
||||
const loadingFeatured = featured.loading;
|
||||
|
||||
// Load featured data once on component mount
|
||||
useEffect(() => {
|
||||
if (!featured.data && !loadingFeatured) {
|
||||
gotongRoyongState.kegiatanDesa.findFirst.load();
|
||||
let mounted = true;
|
||||
|
||||
const loadFeatured = async () => {
|
||||
try {
|
||||
if (!featured.data && !loadingFeatured) {
|
||||
await gotongRoyongState.kegiatanDesa.findFirst.load();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading featured data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
if (mounted) {
|
||||
loadFeatured();
|
||||
}
|
||||
}, [featured.data, loadingFeatured]);
|
||||
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, []); // Empty dependency array to run only once on mount
|
||||
|
||||
useEffect(() => {
|
||||
const limit = 3;
|
||||
state.findMany.load(page, limit, search);
|
||||
let mounted = true;
|
||||
|
||||
const loadData = async () => {
|
||||
try {
|
||||
const limit = 3;
|
||||
await state.findMany.load(page, limit, search);
|
||||
} catch (error) {
|
||||
console.error('Error loading data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
if (mounted) {
|
||||
loadData();
|
||||
}
|
||||
|
||||
return () => {
|
||||
mounted = false;
|
||||
};
|
||||
}, [page, search]);
|
||||
|
||||
const handlePageChange = (newPage: number) => {
|
||||
@@ -59,7 +92,9 @@ export default function Page() {
|
||||
if (search) url.set('search', search);
|
||||
if (newPage > 1) url.set('page', newPage.toString());
|
||||
else url.delete('page');
|
||||
router.replace(`?${url.toString()}`);
|
||||
|
||||
// Use push instead of replace to keep browser history
|
||||
router.push(`?${url.toString()}`, { scroll: false });
|
||||
};
|
||||
|
||||
const featuredData = featured.data;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client'
|
||||
import pengelolaanSampahState from '@/app/admin/(dashboard)/_state/lingkungan/pengelolaan-sampah';
|
||||
import colors from '@/con/colors';
|
||||
import { Box, Center, Flex, Pagination, Paper, SimpleGrid, Skeleton, Stack, Text, TextInput } from '@mantine/core';
|
||||
import { Box, Center, Flex, Group, Pagination, Paper, SimpleGrid, Skeleton, Stack, Text, TextInput } from '@mantine/core';
|
||||
import { useDebouncedValue, useShallowEffect } from '@mantine/hooks';
|
||||
import { Icon, IconChartLine, IconClipboardTextFilled, IconLeaf, IconRecycle, IconScale, IconSearch, IconTent, IconTrashFilled, IconTrophy, IconTruckFilled } from '@tabler/icons-react';
|
||||
import { Icon, IconChartLine, IconClipboardTextFilled, IconLeaf, IconRecycle, IconRoute, IconScale, IconSearch, IconTent, IconTrashFilled, IconTrophy, IconTruckFilled } from '@tabler/icons-react';
|
||||
import React, { useState } from 'react';
|
||||
import { useProxy } from 'valtio/utils';
|
||||
import BackButton from '../../desa/layanan/_com/BackButto';
|
||||
@@ -122,20 +122,28 @@ function Page() {
|
||||
<Stack gap="md">
|
||||
{data2?.map((v, k) => (
|
||||
<Paper key={k} p="md" withBorder radius="md">
|
||||
<Text fw="bold" fz="lg">{v.namaTempatMaps}</Text>
|
||||
<Text c="dimmed" fz="sm" mb="sm">{v.alamat}</Text>
|
||||
{v.lat && v.lng ? (
|
||||
<a
|
||||
href={`https://www.google.com/maps/dir/?api=1&destination=${v.lat},${v.lng}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ color: colors['blue-button'], textDecoration: 'none' }}
|
||||
>
|
||||
<Text fz="sm">📌 Buka di Google Maps</Text>
|
||||
</a>
|
||||
) : (
|
||||
<Text c="dimmed" fz="sm">Koordinat belum tersedia</Text>
|
||||
)}
|
||||
<Group justify='space-between'>
|
||||
<Box>
|
||||
<Text fw="bold" fz="lg">{v.namaTempatMaps}</Text>
|
||||
<Text c="dimmed" fz="sm" mb="sm">{v.alamat}</Text>
|
||||
</Box>
|
||||
<Box>
|
||||
<IconRoute color={colors['blue-button']} size={30} />
|
||||
<Text fw={"bold"} fz="sm" c={colors['blue-button']}>Rute</Text>
|
||||
</Box>
|
||||
</Group>
|
||||
{v.lat && v.lng ? (
|
||||
<a
|
||||
href={`https://www.google.com/maps/dir/?api=1&destination=${v.lat},${v.lng}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ color: colors['blue-button'], textDecoration: 'none' }}
|
||||
>
|
||||
<Text fz="sm">📌 Lihat Peta Lebih Besar</Text>
|
||||
</a>
|
||||
) : (
|
||||
<Text c="dimmed" fz="sm">Koordinat belum tersedia</Text>
|
||||
)}
|
||||
</Paper>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user