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.

4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ 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} {...show } />
})}
</div>
</main>
</div>
Expand Down
67 changes: 34 additions & 33 deletions src/components/showCard/ShowCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useState } from "react";
const outOfTickets = 0,lastTickets = 0;

export interface ShowCardProps {
artist: string;
Expand All @@ -9,64 +10,64 @@ 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({
artist,
stage,
day,
hour,
ticketsLeft,
image}: 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"
function handleToggleInterested() {
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 🎟️"
let ticketsStatusText;

if (ticketsLeft <= outOfTickets) {
ticketsStatusText = "SOLD OUT";
} else if (ticketsLeft <= lastTickets) {
ticketsStatusText = "Last tickets – hurry up!";
} else {
ticketsStatusText = "Tickets available";
}

let interestString = isInterested
? "this show is in your interested list 🎟️"
: "You haven't added this show yet";

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" /> */}
<img src={image} alt={artist} className="show-image" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the alt attribute

<div className="show-image-placeholder">Image goes here</div>
</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"
{interestString}
</p>
</section>

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