Skip to content

Commit 7dd21b6

Browse files
committed
added season filter
1 parent 18884d2 commit 7dd21b6

2 files changed

Lines changed: 29 additions & 24 deletions

File tree

app/components/Dashboard.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -169,21 +169,24 @@ const SeasonFilter = React.memo(
169169
return (
170170
<div className={styles.seasonFilterContainer}>
171171
<div className={styles.seasonButtons}>
172-
{availableSeasons.map((season) => (
173-
<button
174-
key={season}
175-
className={`${styles.seasonButton} ${selectedSeason === season ? styles.activeSeason : ''}`}
176-
onClick={() => onSeasonChange(season)}
177-
>
178-
{season}
179-
</button>
180-
))}
181172
<button
182173
className={`${styles.seasonButton} ${selectedSeason === 'all' ? styles.activeSeason : ''}`}
183174
onClick={() => onSeasonChange('all')}
184175
>
185176
All Seasons
186177
</button>
178+
{availableSeasons
179+
.slice()
180+
.reverse()
181+
.map((season) => (
182+
<button
183+
key={season}
184+
className={`${styles.seasonButton} ${selectedSeason === season ? styles.activeSeason : ''}`}
185+
onClick={() => onSeasonChange(season)}
186+
>
187+
{season}
188+
</button>
189+
))}
187190
</div>
188191
</div>
189192
)
@@ -345,7 +348,7 @@ const Dashboard = () => {
345348

346349
const uniqueMatches = useMemo(() => {
347350
return getUniqueMatches(seasonFilteredMatches, cleanTeamName)
348-
}, [])
351+
}, [seasonFilteredMatches])
349352

350353
// Mobile detection useEffect
351354
useEffect(() => {
@@ -448,21 +451,20 @@ const Dashboard = () => {
448451
<header className={styles.header}>
449452
<div className={styles.headerContent}>
450453
<h2>Dashboard</h2>
451-
<div className={styles.headerControls}>
452-
<SearchBox
453-
searchTerm={searchTerm}
454-
onSearch={handleSearch}
455-
onClear={handleClearSearch}
456-
/>
457-
<SeasonFilter
458-
availableSeasons={availableSeasons}
459-
selectedSeason={selectedSeason}
460-
onSeasonChange={handleSeasonChange}
461-
/>
462-
</div>
454+
<SearchBox
455+
searchTerm={searchTerm}
456+
onSearch={handleSearch}
457+
onClear={handleClearSearch}
458+
/>
463459
</div>
464460
</header>
465461

462+
<SeasonFilter
463+
availableSeasons={availableSeasons}
464+
selectedSeason={selectedSeason}
465+
onSeasonChange={handleSeasonChange}
466+
/>
467+
466468
<div className={styles.carousel}>
467469
{!seasonFilteredMatches.length
468470
? Array(10)

app/styles/Dashboard.module.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,22 @@
391391
}
392392
}
393393

394-
/* Header Controls - wraps search and season filter */
394+
/* Header Controls - wraps search and season filter
395395
.headerControls {
396396
display: flex;
397397
gap: 20px;
398398
align-items: center;
399399
flex-wrap: wrap;
400-
}
400+
}*/
401401

402402
/* Season Filter Container */
403403
.seasonFilterContainer {
404404
display: flex;
405405
align-items: center;
406406
gap: 12px;
407+
padding: 10px 0;
408+
margin-bottom: 10px;
409+
margin-left: 0;
407410
}
408411

409412
.seasonButtons {

0 commit comments

Comments
 (0)