From 977c35bd57ec7390c6f2bc72317fa3114e0ffc40 Mon Sep 17 00:00:00 2001 From: IZZY Date: Tue, 27 May 2025 13:48:32 +0100 Subject: [PATCH] Working Shop and footer --- prisma/schema.prisma | 44 +++--- public/BlueBackground.png | Bin 0 -> 1800 bytes src/app/api/artefacts/route.ts | 18 +++ src/app/shop/page.tsx | 237 +++++++-------------------------- 4 files changed, 88 insertions(+), 211 deletions(-) create mode 100644 public/BlueBackground.png create mode 100644 src/app/api/artefacts/route.ts diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3049ca4..4541b6a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -10,18 +10,18 @@ generator client { // User model model User { - id Int @id @default(autoincrement()) - createdAt DateTime @default(now()) - name String - email String @unique - passwordHash String - role String @default("GUEST") @db.VarChar(10) // Allowed: ADMIN, SCIENTIST, GUEST - scientist Scientist? @relation - purchasedOrders Order[] @relation("UserOrders") - requests Request[] @relation("UserRequests") - earthquakes Earthquake[] @relation("UserEarthquakeCreator") - observatories Observatory[] @relation("UserObservatoryCreator") - artefacts Artefact[] @relation("UserArtefactCreator") + id Int @id @default(autoincrement()) + createdAt DateTime @default(now()) + name String + email String @unique + passwordHash String + role String @default("GUEST") @db.VarChar(10) // Allowed: ADMIN, SCIENTIST, GUEST + scientist Scientist? @relation + purchasedOrders Order[] @relation("UserOrders") + requests Request[] @relation("UserRequests") + earthquakes Earthquake[] @relation("UserEarthquakeCreator") + observatories Observatory[] @relation("UserObservatoryCreator") + artefacts Artefact[] @relation("UserArtefactCreator") } model Request { @@ -35,15 +35,15 @@ model Request { // Scientist model model Scientist { - id Int @id @default(autoincrement()) - createdAt DateTime @default(now()) - name String - level String @db.VarChar(10) // JUNIOR, SENIOR - user User @relation(fields: [userId], references: [id]) - userId Int @unique - superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction) - superiorId Int? - subordinates Scientist[] @relation("SuperiorRelation") + id Int @id @default(autoincrement()) + createdAt DateTime @default(now()) + name String + level String @db.VarChar(10) // JUNIOR, SENIOR + user User @relation(fields: [userId], references: [id]) + userId Int @unique + superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction) + superiorId Int? + subordinates Scientist[] @relation("SuperiorRelation") } model Earthquake { @@ -93,7 +93,7 @@ model Artefact { earthquake Earthquake @relation(fields: [earthquakeId], references: [id]) creatorId Int? creator User? @relation("UserArtefactCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction) - isRequired Boolean @default(true) + isRequired Boolean @default(true) @map("isRequired") dateAddedToShop DateTime? shopPrice Float? isSold Boolean @default(false) diff --git a/public/BlueBackground.png b/public/BlueBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..949dedbcd117c1e0142f3fde6644ef4f4b597665 GIT binary patch literal 1800 zcmeAS@N?(olHy`uVBq!ia0y~yVB7%2r#aYwA}d#))c{hA#X;^)4C~IxyaaMs(j9#r z85lP9bN@+X1@buyJR*x37{pXTn9(yxG+w^t2$859^;4FAkdO|C78 zxwKHK>fLRI1#SrpDx5qGDvgX2R16p6u|B*Eax#H`>sDmfYmqbXrDJB*eI iqXi@NYlj7Ina?dZl1p-3{0&%pF?hQAxvX([]); + const [loading, setLoading] = useState(true); + + // 3. Fetch from your API route and map data to fit your existing fields + useEffect(() => { + async function fetchArtefacts() { + setLoading(true); + try { + const res = await fetch("/api/artefacts"); + const data = await res.json(); + + const transformed = data.artefact.map((a: any) => ({ + id: a.id, + name: a.name, + description: a.description, + location: a.warehouseArea, // your database + earthquakeID: a.earthquakeId?.toString() ?? "", + observatory: a.type ?? "", // if you want to display type + dateReleased: a.createdAt ? new Date(a.createdAt).toLocaleDateString() : "", + image: "/artefactImages/" + (a.imageName || "NoImageFound.PNG"), + price: a.shopPrice ?? 100, // fallback price if not in DB + })); + setArtefacts(transformed); + } catch (e) { + // Optionally handle error + console.error("Failed to fetch artefacts", e); + } finally { + setLoading(false); + } + } + fetchArtefacts(); + }, []); + const [currentPage, setCurrentPage] = useState(1); const [selectedArtefact, setSelectedArtefact] = useState(null); const [showPaymentModal, setShowPaymentModal] = useState(false); @@ -434,20 +289,20 @@ export default function Shop() { } return (
-
+
-

+

Artefact Shop

-

- Discover extraordinary historical artefacts and collectibles from major seismic events from around the world - now +

+ Discover extraordinary artefacts and collectibles from major seismic events from around the world - Previously studied by our scientists, now available for purchase.

@@ -490,6 +345,10 @@ export default function Shop() { {showThankYouModal && orderNumber && ( setShowThankYouModal(false)} /> )} -
- ); -} + {!selectedArtefact && !showPaymentModal && !showThankYouModal && ( +
+ +
+ )} +
+); \ No newline at end of file