diff --git a/src/app/shop/page.tsx b/src/app/shop/page.tsx index 5994280..5c6cf50 100644 --- a/src/app/shop/page.tsx +++ b/src/app/shop/page.tsx @@ -1,10 +1,10 @@ "use client"; -import Image from 'next/image'; -import { Dispatch, SetStateAction, useCallback, useState } from 'react'; +import Image from "next/image"; +import { Dispatch, SetStateAction, useCallback, useState } from "react"; -import Artifact from '@appTypes/Artifact'; -import { Currency } from '@appTypes/StoreModel'; -import { useStoreState } from '@hooks/store'; +import Artifact from "@appTypes/Artifact"; +import { Currency } from "@appTypes/StoreModel"; +import { useStoreState } from "@hooks/store"; // Artifacts Data const artifacts: Artifact[] = [ @@ -13,6 +13,9 @@ const artifacts: Artifact[] = [ name: "Golden Scarab", description: "An ancient Egyptian artifact symbolizing rebirth.", location: "Cairo, Egypt", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact1.jpg", price: 150, }, @@ -21,6 +24,9 @@ const artifacts: Artifact[] = [ name: "Aztec Sunstone", description: "A replica of the Aztec calendar (inscriptions intact).", location: "Peru", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact2.jpg", price: 200, }, @@ -29,6 +35,9 @@ const artifacts: Artifact[] = [ name: "Medieval Chalice", description: "Used by royalty in medieval ceremonies.", location: "Cambridge, England", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact3.jpg", price: 120, }, @@ -37,6 +46,9 @@ const artifacts: Artifact[] = [ 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: "/artifact4.jpg", price: 80, }, @@ -45,6 +57,9 @@ const artifacts: Artifact[] = [ name: "Samurai Mask", description: "Replica of Japanese Samurai battle masks.", location: "Tokyo, Japan", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact5.jpg", price: 300, }, @@ -53,6 +68,9 @@ const artifacts: Artifact[] = [ name: "Ancient Greek Vase", description: "Depicts Greek mythology, found in the Acropolis.", location: "Athens, Greece", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact6.jpg", price: 250, }, @@ -61,6 +79,9 @@ const artifacts: Artifact[] = [ name: "Incan Pendant", description: "Represents the Sun God Inti.", location: "India", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact7.jpg", price: 175, }, @@ -69,6 +90,9 @@ const artifacts: Artifact[] = [ name: "Persian Carpet Fragment", description: "Ancient Persian artistry.", location: "Petra, Jordan", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact8.jpg", price: 400, }, @@ -77,6 +101,9 @@ const artifacts: Artifact[] = [ name: "Stone Buddha", description: "Authentic stone Buddha carving.", location: "India", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact9.jpg", price: 220, }, @@ -85,6 +112,9 @@ const artifacts: Artifact[] = [ 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: "/artifact10.jpg", price: 150, }, @@ -93,6 +123,9 @@ const artifacts: Artifact[] = [ name: "Ancient Scroll", description: "A mysterious scroll from ancient times.", location: "Madrid, Spain", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact11.jpg", price: 500, }, @@ -101,6 +134,9 @@ const artifacts: Artifact[] = [ name: "Ming Dynasty Porcelain", description: "Porcelain from China's Ming Dynasty.", location: "Beijing, China", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact12.jpg", price: 300, }, @@ -109,6 +145,9 @@ const artifacts: Artifact[] = [ name: "African Tribal Mask", description: "A unique tribal mask from Africa.", location: "Nigeria", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact13.jpg", price: 250, }, @@ -117,6 +156,9 @@ const artifacts: Artifact[] = [ name: "Crystal Skull", description: "A mystical pre-Columbian artifact.", location: "Colombia", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact14.jpg", price: 1000, }, @@ -125,159 +167,169 @@ const artifacts: Artifact[] = [ name: "Medieval Armor Fragment", description: "A fragment of medieval armor.", location: "Normandy, France", + earthquakeID: "h", + observatory: "jhd", + dateReleased: "12/02/2025", image: "/artifact15.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: "/artifact16.jpg", price: 500, }, ]; export default function Shop() { - const [currentPage, setCurrentPage] = useState(1); - const [selectedArtifact, setSelectedArtifact] = useState(null); - const artifactsPerPage = 12; - const indexOfLastArtifact = currentPage * artifactsPerPage; - const indexOfFirstArtifact = indexOfLastArtifact - artifactsPerPage; - const currentArtifacts = artifacts.slice(indexOfFirstArtifact, indexOfLastArtifact); + const [currentPage, setCurrentPage] = useState(1); + const [selectedArtifact, setSelectedArtifact] = useState(null); + const artifactsPerPage = 12; + const indexOfLastArtifact = currentPage * artifactsPerPage; + const indexOfFirstArtifact = indexOfLastArtifact - artifactsPerPage; + const currentArtifacts = artifacts.slice(indexOfFirstArtifact, indexOfLastArtifact); - const selectedCurrency = useStoreState((state) => state.currency.selectedCurrency); - const conversionRates = useStoreState((state) => state.currency.conversionRates); - const currencyTickers = useStoreState((state) => state.currency.tickers); + 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 convertPrice = useCallback((price: number, currency: Currency) => (price * conversionRates[currency]).toFixed(2), []); - const handleNextPage = () => { - if (indexOfLastArtifact < artifacts.length) { - setCurrentPage((prev) => prev + 1); - } - }; - const handlePreviousPage = () => { - if (currentPage > 1) { - setCurrentPage((prev) => prev - 1); - } - }; + const handleNextPage = () => { + if (indexOfLastArtifact < artifacts.length) { + setCurrentPage((prev) => prev + 1); + } + }; + const handlePreviousPage = () => { + if (currentPage > 1) { + setCurrentPage((prev) => prev - 1); + } + }; - function Modal({ artifact }: { artifact: Artifact }) { - if (!artifact) return null; - const handleOverlayClick = (e: { target: any; currentTarget: any }) => { - if (e.target === e.currentTarget) { - setSelectedArtifact(null); - } - }; - return ( -
-
-

{artifact.name}

- {artifact.name} -

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

-

{artifact.description}

-

Location: {artifact.location}

-
- -
-
-
- ); - } + function Modal({ artifact }: { artifact: Artifact }) { + if (!artifact) return null; + const handleOverlayClick = (e: { target: any; currentTarget: any }) => { + if (e.target === e.currentTarget) { + setSelectedArtifact(null); + } + }; + return ( +
+
+

{artifact.name}

+ {artifact.name} +

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

+

{artifact.description}

+

Location: {artifact.location}

+

{artifact.earthquakeID}

+

{artifact.observatory}

+

{artifact.dateReleased}

+
+ +
+
+
+ ); + } - function ArtifactCard({ artifact }: { artifact: Artifact }) { - return ( -
setSelectedArtifact(artifact)} - > - {artifact.name} -
-

{artifact.name}

-

{artifact.location}

-

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

-
-
- ); - } + function ArtifactCard({ artifact }: { artifact: Artifact }) { + return ( +
setSelectedArtifact(artifact)} + > + {artifact.name} +
+

{artifact.name}

+

{artifact.location}

+

{artifact.earthquakeID}

+

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

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

- Artifact Shop -

-

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

+ return ( +
+ {/* Overlay */} +
+
+ {/* Title & Subheading */} +

+ Artifact Shop +

+

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

- {/* Artifact Grid */} -
{/* gap-10 for more spacing */} - {currentArtifacts.map((artifact) => ( - - ))} -
+ {/* Artifact Grid */} +
+ {" "} + {/* gap-10 for more spacing */} + {currentArtifacts.map((artifact) => ( + + ))} +
- {/* Pagination Footer */} -
- -

{currentPage}

- -
-
+ {/* Pagination Footer */} +
+ +

{currentPage}

+ +
+
- {/* Modal */} - {selectedArtifact && } -
- ); -} \ No newline at end of file + {/* Modal */} + {selectedArtifact && } +
+ ); +} diff --git a/src/types/Artifact.ts b/src/types/Artifact.ts index 0bd3d8c..b9ef623 100644 --- a/src/types/Artifact.ts +++ b/src/types/Artifact.ts @@ -4,6 +4,9 @@ interface Artifact { name: string; description: string; location: string; + earthquakeID: string; + observatory: string; + dateReleased: string; image: string; price: number; }