/* eslint-disable @typescript-eslint/no-explicit-any */
'use client';
import stateGallery from '@/app/admin/(dashboard)/_state/desa/gallery';
import colors from '@/con/colors';
import {
Box,
Center,
Grid,
Image,
Pagination,
Paper,
Skeleton,
Stack,
Text,
Title,
} from '@mantine/core';
import { useShallowEffect } from '@mantine/hooks';
import { IconPhoto } from '@tabler/icons-react';
import { useState } from 'react';
import { useProxy } from 'valtio/utils';
// Komponen kartu foto
function FotoCard({ item }: { item: any }) {
return (
(e.currentTarget.style.transform = 'scale(1.02)')}
onMouseLeave={(e) => (e.currentTarget.style.transform = 'scale(1)')}
>
{item.imageGalleryFoto?.link ? (
) : (
)}
{item.name || 'Tanpa Judul'}
{item.deskripsi && (
)}
{new Date(item.createdAt).toLocaleDateString('id-ID', {
day: 'numeric',
month: 'short',
year: 'numeric',
})}
);
}
// Komponen utama
export default function GaleriFotoUser() {
const [search] = useState('');
return (
{/* Header */}
Galeri Foto Desa Darmasaba
{/* Daftar Foto */}
);
}
function FotoList({ search }: { search: string }) {
const FotoState = useProxy(stateGallery.foto);
const { data, page, totalPages, loading, load } = FotoState.findMany;
useShallowEffect(() => {
load(page, 3, search);
}, [page, search]);
if (loading) {
return (
{Array.from({ length: 3 }).map((_, i) => (
))}
);
}
if (!data || data.length === 0) {
return (
Tidak ada foto ditemukan
);
}
return (
{data.map((item) => (
))}
{/* Pagination */}
{
load(newPage, 3, search);
window.scrollTo({ top: 0, behavior: 'smooth' });
}}
total={totalPages}
color="blue"
radius="md"
/>
);
}