diff --git a/src/App.tsx b/src/App.tsx index b16f189..e7587f5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -56,7 +56,12 @@ export default function App() {
- {/* TODO - shows.map((show)=>{ return })*/} + {/* 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..44865e4 100644 --- a/src/components/showCard/ShowCard.tsx +++ b/src/components/showCard/ShowCard.tsx @@ -11,62 +11,87 @@ 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] = ... + const [isInterested, setIsInterested] = useState(false); + // TODO 3: Function that toggles true/false in isInterested // function handleToggleInterested() {} + function handleToggleInterested() { + setIsInterested(!isInterested); + } // TODO 4: Create ticketsStatusText (string): // 0 → "SOLD OUT" // 1–30 → "Last tickets – hurry up!" // >30 → "Tickets available" - +function getTicketsStatusText(ticketsLeft: number): string { + if (ticketsLeft === 0) { + return "SOLD OUT"; + } else if (ticketsLeft >= 1 && ticketsLeft <= 30) { + return "Last tickets – hurry up!"; + } else { + return "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 getInterestedText(isInterested: boolean): string { + if (isInterested) { + return "This show is in your interested list 🎟️" ; + } else { + return "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" + {getTicketsStatusText(ticketsLeft)}

{/* TODO 10: Display the interestedText */} - "Interested status text" + {getInterestedText(isInterested)}

);