From 70fd273b643942216451e4655ac4873a9b24eea7 Mon Sep 17 00:00:00 2001 From: snirtal Date: Mon, 15 Dec 2025 17:24:46 +0200 Subject: [PATCH] finish --- src/App.tsx | 2 + src/components/showCard/ShowCard.tsx | 82 ++++++++++++++++------------ 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index b16f189..a4303ad 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,6 +56,8 @@ export default function App() {
+{shows.map((show) =>{ return ( )})} + {/* TODO - shows.map((show)=>{ return })*/}
diff --git a/src/components/showCard/ShowCard.tsx b/src/components/showCard/ShowCard.tsx index 7e18a47..5ea9abf 100644 --- a/src/components/showCard/ShowCard.tsx +++ b/src/components/showCard/ShowCard.tsx @@ -1,6 +1,7 @@ import { useState } from "react"; export interface ShowCardProps { + id: number; artist: string; stage: string; day: string; @@ -9,64 +10,75 @@ export interface ShowCardProps { image: string; } -export default function ShowCard( - /* TODO 1: Accept props with ShowCardProps type here */ -) { - // TODO 2: Create state called isInterested of type boolean (default false) - // const [isInterested, setIsInterested] = ... +export default function ShowCard(Props: ShowCardProps) { - // TODO 3: Function that toggles true/false in isInterested - // function handleToggleInterested() {} + const [isInterested, setIsInterested] = useState(false); - // TODO 4: Create ticketsStatusText (string): - // 0 → "SOLD OUT" - // 1–30 → "Last tickets – hurry up!" - // >30 → "Tickets available" - // TODO 5: Create text for interest status based on isInterested: - // false → "You haven't added this show yet" - // true → "This show is in your interested list 🎟️" + function handleToggleInterested() { + setIsInterested((prev) => !prev); + } + + + let ticketsStatusText: string; + + if (Props.ticketsLeft === 0) { + ticketsStatusText = "SOLD OUT"; + } else if (Props.ticketsLeft <= 30) { + ticketsStatusText = "Last tickets – hurry up!"; + } else { + ticketsStatusText = "Tickets available"; + } + + + + + let interestedText: string; + + if (isInterested === true) { + interestedText = "This show is in your interested list 🎟️"; + } else { + interestedText = "You haven't added this show yet"; + } return (
- {/* TODO 6: Replace placeholder with real from props */} - {/* {artist} */} -
Image goes here
+ {Props.artist} + + +
+

- {/* TODO 7: If isInterested → show ⭐ before artist name */} - "Artist name here" + {isInterested ? "⭐ " : ""} + {Props.artist} +

- {/* TODO 8: Display stage, day, hour from props */} - "Stage · Day · Hour" + {Props.stage} + {Props.day} + {Props.hour}

-

- {/* TODO 9: Display the ticketsStatusText */} - "Tickets status text" -

+

{ticketsStatusText}

-

- {/* TODO 10: Display the interestedText */} - "Interested status text" -

+

{interestedText}

);