"use client"; import Image from "next/image"; import { Dispatch, SetStateAction, useCallback, useState } from "react"; import Artefact from "@appTypes/Artefact"; import { Currency } from "@appTypes/StoreModel"; import { useStoreState } from "@hooks/store"; // Artefacts Data const artefacts: Artefact[] = [ { id: 1, name: "Golden Scarab", description: "An ancient Egyptian artefact symbolizing rebirth.", location: "Cairo, Egypt", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact1.jpg", price: 150, }, { id: 2, name: "Aztec Sunstone", description: "A replica of the Aztec calendar (inscriptions intact).", location: "Peru", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact2.jpg", price: 200, }, { id: 3, name: "Medieval Chalice", description: "Used by royalty in medieval ceremonies.", location: "Cambridge, England", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact3.jpg", price: 120, }, { id: 4, name: "Roman Coin", description: "An authentic Roman coin from the 2nd century CE.", location: "Rome, Italy", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact4.jpg", price: 80, }, { id: 5, name: "Samurai Mask", description: "Replica of Japanese Samurai battle masks.", location: "Tokyo, Japan", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact5.jpg", price: 300, }, { id: 6, name: "Ancient Greek Vase", description: "Depicts Greek mythology, found in the Acropolis.", location: "Athens, Greece", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact6.jpg", price: 250, }, { id: 7, name: "Incan Pendant", description: "Represents the Sun God Inti.", location: "India", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact7.jpg", price: 175, }, { id: 8, name: "Persian Carpet Fragment", description: "Ancient Persian artistry.", location: "Petra, Jordan", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact8.jpg", price: 400, }, { id: 9, name: "Stone Buddha", description: "Authentic stone Buddha carving.", location: "India", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact9.jpg", price: 220, }, { id: 10, name: "Victorian Brooch", description: "A beautiful Victorian-era brooch with a ruby centre.", location: "Oxford, England", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact10.jpg", price: 150, }, { id: 11, name: "Ancient Scroll", description: "A mysterious scroll from ancient times.", location: "Madrid, Spain", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact11.jpg", price: 500, }, { id: 12, name: "Ming Dynasty Porcelain", description: "Porcelain from China's Ming Dynasty.", location: "Beijing, China", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact12.jpg", price: 300, }, { id: 13, name: "African Tribal Mask", description: "A unique tribal mask from Africa.", location: "Nigeria", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact13.jpg", price: 250, }, { id: 14, name: "Crystal Skull", description: "A mystical pre-Columbian artefact.", location: "Colombia", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact14.jpg", price: 1000, }, { id: 15, name: "Medieval Armor Fragment", description: "A fragment of medieval armor.", location: "Normandy, France", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact15.jpg", price: 400, }, { id: 16, name: "Medieval Helmet Fragment", description: "A fragment of a medieval helmet.", location: "Normandy, France", earthquakeID: "h", observatory: "jhd", dateReleased: "12/02/2025", image: "/artefact16.jpg", price: 500, }, ]; export default function Shop() { const [currentPage, setCurrentPage] = useState(1); const [selectedArtefact, setSelectedArtefact] = useState(null); const artefactsPerPage = 12; const indexOfLastArtefact = currentPage * artefactsPerPage; const indexOfFirstArtefact = indexOfLastArtefact - artefactsPerPage; const currentArtefacts = artefacts.slice(indexOfFirstArtefact, indexOfLastArtefact); const selectedCurrency = useStoreState((state) => state.currency.selectedCurrency); const conversionRates = useStoreState((state) => state.currency.conversionRates); const currencyTickers = useStoreState((state) => state.currency.tickers); const convertPrice = useCallback((price: number, currency: Currency) => (price * conversionRates[currency]).toFixed(2), []); const handleNextPage = () => { if (indexOfLastArtefact < artefacts.length) { setCurrentPage((prev) => prev + 1); } }; const handlePreviousPage = () => { if (currentPage > 1) { setCurrentPage((prev) => prev - 1); } }; function Modal({ artefact }: { artefact: Artefact }) { if (!artefact) return null; const handleOverlayClick = (e: { target: any; currentTarget: any }) => { if (e.target === e.currentTarget) { setSelectedArtefact(null); } }; return (

{artefact.name}

{artefact.name}

{currencyTickers[selectedCurrency]} {convertPrice(artefact.price, selectedCurrency)}

{artefact.description}

Location: {artefact.location}

{artefact.earthquakeID}

{artefact.observatory}

{artefact.dateReleased}

); } function ArtefactCard({ artefact }: { artefact: Artefact }) { return (
setSelectedArtefact(artefact)} > {artefact.name}

{artefact.name}

{artefact.location}

{artefact.earthquakeID}

{currencyTickers[selectedCurrency]} {convertPrice(artefact.price, selectedCurrency)}

); } return (
{/* Overlay */}
{/* Title & Subheading */}

Artefact Shop

Discover extraordinary historical artefacts and collectibles from major seismic events from around the world - now available for purchase.

{/* Artefact Grid */}
{" "} {/* gap-10 for more spacing */} {currentArtefacts.map((artefact) => ( ))}
{/* Pagination Footer */}

{currentPage}

{/* Modal */} {selectedArtefact && }
); }