Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,21 @@ export default function App() {

<main>
<div className="shows-grid">
{/* TODO - shows.map((show)=>{ return <ShowCard id={show.id} .../> })*/}
{
shows.map((show) =>{
return(
<ShowCard
key={show.id}
artist ={show.artist}
stage ={show.stage}
day ={show.day}
hour = {show.hour}
ticketsLeft = {show.ticketsLeft}
image = {show.image}
/>
);
}
)}
</div>
</main>
</div>
Expand Down
37 changes: 24 additions & 13 deletions src/components/showCard/ShowCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,75 @@ export interface ShowCardProps {
image: string;
}

export default function ShowCard(
/* TODO 1: Accept props with ShowCardProps type here */
) {
export default function ShowCard({artist,
stage,
day,
hour,
ticketsLeft,
image}: ShowCardProps){
const[isInterested,setIsInterested] = useState<boolean>(false);

// 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() {}
function handleToggleInterested() {setIsInterested(!isInterested);}

// TODO 4: Create ticketsStatusText (string):
// 0 → "SOLD OUT"
// 1–30 → "Last tickets – hurry up!"
// >30 → "Tickets available"

let ticketsStatusText:string = "SOLD OUT";
if(ticketsLeft === 0) { ticketsStatusText ="SOLD OUT"}
else if(ticketsLeft >0 && ticketsLeft <=30) { ticketsStatusText ="Last tickets – hurry up!"}
else { ticketsStatusText ="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 🎟️"
let isInterestedText:string = "You haven't added this show yet";
if(isInterested === false){isInterestedText = "You haven't added this show yet"}
else{ isInterestedText = "This show is in your interested list 🎟️"}

return (
<article className="show-card">
<div className="show-image-wrapper">
{/* TODO 6: Replace placeholder with real <img> from props */}
{/* <img src={image} alt={artist} className="show-image" /> */}
<div className="show-image-placeholder">Image goes here</div>
{<img src={image} alt={artist} className="show-image" />}
</div>

<header className="show-header">
<h2 className="show-artist">
{/* TODO 7: If isInterested → show ⭐ before artist name */}
"Artist name here"
{isInterested ? "⭐":""}
{artist}
</h2>
<p className="show-meta">
{/* TODO 8: Display stage, day, hour from props */}
"Stage · Day · Hour"
{stage} · {day} · {hour}
</p>
</header>

<section className="show-info">
<p className="tickets-status">
{/* TODO 9: Display the ticketsStatusText */}
"Tickets status text"
{ticketsStatusText}
</p>

<p className="interested-status">
{/* TODO 10: Display the interestedText */}
"Interested status text"
{isInterestedText}
</p>
</section>

<button
className="interested-button"
// TODO 11: Connect onClick to handleToggleInterested function
>
onClick={handleToggleInterested}>
{/* TODO 12: Button text:
false → "Mark as interested"
true → "Remove from my list"
*/}
"Button text"
{isInterested ? "Remove from my list" : "Mark as interested"}
</button>
</article>
);
Expand Down