Comments, appointments adjustments, fixed some issues
This commit is contained in:
@@ -7,6 +7,8 @@ import PetProfile from "@/components/PetProfile";
|
||||
|
||||
const API_BASE = "";
|
||||
|
||||
//Pet detail page
|
||||
//Fetches a single pet by ID and passes it to PetProfile
|
||||
export default function PetDetailPage() {
|
||||
const { id } = useParams();
|
||||
const [pet, setPet] = useState(null);
|
||||
|
||||
@@ -5,6 +5,8 @@ import PetCard from "@/components/PetCard";
|
||||
import { fetchAllPages } from "@/lib/fetchAllPages";
|
||||
import { useCart } from "@/context/CartContext";
|
||||
|
||||
//Adopt page
|
||||
//Browse available pets with species/breed filters and search
|
||||
const API_BASE = "";
|
||||
const PAGE_SIZE = 10000;
|
||||
|
||||
@@ -12,6 +14,8 @@ const inputCls = "px-4 py-[0.6rem] border-2 border-[#ddd] rounded-md text-base o
|
||||
const btnPrimaryCls = "px-[1.4rem] py-[0.6rem] bg-[#e68672] text-white border-none rounded-md text-base cursor-pointer transition-colors hover:bg-[#d4705e]";
|
||||
const btnOutlineCls = "px-4 py-[0.6rem] bg-transparent text-[#666] border-2 border-[#ddd] rounded-md text-base cursor-pointer transition-all hover:border-[#aaa] hover:text-[#333]";
|
||||
|
||||
//Pagination button
|
||||
//Highlighted when it represents the current page
|
||||
function PaginationBtn({ children, active, ...props }) {
|
||||
return (
|
||||
<button
|
||||
@@ -23,6 +27,7 @@ function PaginationBtn({ children, active, ...props }) {
|
||||
);
|
||||
}
|
||||
|
||||
//Main adopt page component
|
||||
export default function AdoptPage() {
|
||||
const { selectedStoreId } = useCart();
|
||||
|
||||
@@ -35,6 +40,7 @@ export default function AdoptPage() {
|
||||
const [selectedBreed, setSelectedBreed] = useState("");
|
||||
const [speciesOptions, setSpeciesOptions] = useState([]);
|
||||
|
||||
//Loads the species list from the first page of pets whenever the store changes
|
||||
useEffect(() => {
|
||||
setSelectedSpecies("");
|
||||
const params = new URLSearchParams({ page: "0", size: String(PAGE_SIZE) });
|
||||
@@ -68,6 +74,7 @@ export default function AdoptPage() {
|
||||
.finally(() => setLoading(false));
|
||||
}, [query, selectedSpecies, selectedStoreId]);
|
||||
|
||||
//Builds the breed dropdown from the currently loaded pets
|
||||
const breedOptions = useMemo(
|
||||
() => [...new Set(pets.map((p) => p.petBreed).filter(Boolean))].sort((a, b) =>
|
||||
a.localeCompare(b, undefined, { sensitivity: "base" })
|
||||
@@ -84,7 +91,10 @@ export default function AdoptPage() {
|
||||
const totalPages = Math.ceil(filteredPets.length / ITEMS_PER_PAGE);
|
||||
const displayedPets = filteredPets.slice(currentPage * ITEMS_PER_PAGE, (currentPage + 1) * ITEMS_PER_PAGE);
|
||||
|
||||
//Submits search form
|
||||
function handleSearch(e) { e.preventDefault(); setCurrentPage(0); setQuery(search.trim()); }
|
||||
|
||||
//Resets all active filters and search text
|
||||
function handleClearFilters() { setSearch(""); setQuery(""); setSelectedSpecies(""); setSelectedBreed(""); setCurrentPage(0); }
|
||||
const hasActiveFilters = query || selectedSpecies || selectedBreed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user