import { useState, useEffect } from 'react'; import { Search, Trash2, Heart, Image as ImageIcon } from 'lucide-react'; import api, { BASE_DOMAIN } from '../services/api'; import Spinner from '../components/ui/Spinner'; import Pagination from '../components/ui/Pagination'; export default function Pets() { const [pets, setPets] = useState([]); const [isLoading, setIsLoading] = useState(true); const [search, setSearch] = useState(''); const [page, setPage] = useState(1); const [totalPages, setTotalPages] = useState(1); const limit = 10; const fetchPets = async () => { try { setIsLoading(true); const res = await api.get('/admin/pets', { params: { page, limit, search } }); if (res.data?.data) { setPets(res.data.data); setTotalPages(res.data.meta?.lastPage || 1); } } catch (err) { console.error(err); } finally { setIsLoading(false); } }; useEffect(() => { const timer = setTimeout(() => { fetchPets(); }, 500); return () => clearTimeout(timer); }, [search, page]); const handleDelete = async (id: string) => { if (!window.confirm('آیا از حذف پروفایل این حیوان خانگی مطمئن هستید؟')) return; try { await api.delete(`/admin/pets/${id}`); fetchPets(); } catch (error) { console.error('Delete failed', error); } }; return (

حیوانات خانگی کاربران (Pets)

مشاهده و مدیریت پروفایل حیوانات خانگی ثبت شده توسط کاربران

{ setSearch(e.target.value); setPage(1); }} className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none transition-all" />
{isLoading ? ( ) : pets.length === 0 ? ( ) : ( pets.map((pet) => ( )) )}
تصویر نام و نژاد صاحب حیوان مشخصات فیزیکی عملیات
هیچ حیوانی یافت نشد
{pet.imageUrl ? ( {pet.name} ) : (
)}
{pet.name} {pet.type}
{pet.breed}
{pet.user?.firstName} {pet.user?.lastName}
{pet.user?.mobile || pet.user?.email}
{pet.age} ساله، {pet.weight} کیلوگرم
تحرک: {pet.activityLevel}
{!isLoading && totalPages > 1 && (
)}
); }