diff --git a/src/App.tsx b/src/App.tsx index b16f189..e2a818c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,7 +56,10 @@ export default function App() {
- {/* TODO - shows.map((show)=>{ return })*/} + {shows.map((show) => { + return + })}
diff --git a/src/components/showCard/ShowCard.tsx b/src/components/showCard/ShowCard.tsx index 7e18a47..9910035 100644 --- a/src/components/showCard/ShowCard.tsx +++ b/src/components/showCard/ShowCard.tsx @@ -10,63 +10,70 @@ export interface ShowCardProps { } export default function ShowCard( - /* TODO 1: Accept props with ShowCardProps type here */ + { + artist, + stage, + day, + hour, + ticketsLeft, + image, + }: ShowCardProps ) { - // TODO 2: Create state called isInterested of type boolean (default false) - // const [isInterested, setIsInterested] = ... - // 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" + const handleToggleInterested = (): void => { + setIsInterested(!isInterested) + } - // 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 🎟️" + const ticketsStatusText = (): string => { + if (ticketsLeft == 0) { + return "SOLD OUT" + } + else if (ticketsLeft > 1 && ticketsLeft < 30) { + return "Last tickets – hurry up!" + } + else { + return "Tickets available" + } + } + + const interestText=isInterested ? "This show is in your interested list 🎟️":"You haven't added this show yet" return (
- {/* TODO 6: Replace placeholder with real from props */} - {/* {artist} */} -
Image goes here
+
+ {artist} +

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

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

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

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

);