-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corina/644 fix a11y picks page #656
base: develop
Are you sure you want to change the base?
Changes from all commits
ebedd5a
29b2ea9
2514642
2d00061
b7f829e
ffa5e18
25803e7
8887e09
affca69
7c77bf2
1110acf
79e5934
af76040
75b0d4f
2c784f3
3318d55
e1d3a7a
7cf34d4
192ad24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import { | |
getGameWeek, | ||
} from '@/api/apiFunctions'; | ||
import { ILeague } from '@/api/apiFunctions.interface'; | ||
import { IPickHistoryTeam } from '@/api/apiFunctions.interface'; | ||
import WeekTeams from './WeekTeams'; | ||
import GlobalSpinner from '@/components/GlobalSpinner/GlobalSpinner'; | ||
import { onWeeklyPickChange } from './WeekHelper'; | ||
|
@@ -43,7 +44,7 @@ import Heading from '@/components/Heading/Heading'; | |
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | ||
const [pickHistory, setPickHistory] = useState<string[]>([]); | ||
const [pickHistory, setPickHistory] = useState<IPickHistoryTeam[]>([]); | ||
const [entryName, setEntryName] = useState<string>(''); | ||
const [error, setError] = useState<string | null>(null); | ||
const [schedule, setSchedule] = useState<ISchedule[]>([]); | ||
|
@@ -160,15 +161,16 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | |
} | ||
|
||
setEntryName(currentEntry.name); | ||
let entryHistory = currentEntry?.selectedTeams || []; | ||
const entryHistory = currentEntry?.selectedTeams || []; | ||
|
||
if (currentEntry?.selectedTeams.length > 0) { | ||
entryHistory = entryHistory.map((teamName) => | ||
getNFLTeamLogo(NFLTeams, teamName), | ||
); | ||
const entryHistoryObject = entryHistory.map((teamName) => ({ | ||
teamName: teamName, | ||
teamLogo: getNFLTeamLogo(NFLTeams, teamName), | ||
})); | ||
setPickHistory(entryHistoryObject); | ||
} | ||
|
||
setPickHistory(entryHistory); | ||
} catch (error) { | ||
throw new Error("Error fetching user's pick history"); | ||
} finally { | ||
|
@@ -291,14 +293,14 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | |
className="flex flex-wrap w-[90%] gap-4 overflow-x-scroll justify-center pb-10 items-center" | ||
data-testid="user-pick-history" | ||
> | ||
{pickHistory?.map((logoURL, index) => { | ||
{pickHistory?.map((team, index) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to refactor this code for this ticket? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shashilo |
||
const isCurrentWeek = index === pickHistory.length - 1; | ||
const hasCurrentWeekPick = | ||
pickHistory.length === Number(week); | ||
|
||
return ( | ||
<div | ||
key={`${logoURL ? logoURL : 'no-pick'}-${index + 1}`} | ||
key={`${team.teamLogo ? team.teamLogo : 'no-pick'}-${index + 1}`} | ||
className={cn( | ||
'flex flex-col items-center justify-center border p-2 rounded-lg gap-1', | ||
isCurrentWeek && hasCurrentWeekPick | ||
|
@@ -311,15 +313,17 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => { | |
? 'CURRENT' | ||
: `WEEK ${index + 1}`} | ||
</span> | ||
{logoURL ? ( | ||
<Image | ||
className="league-entry-logo" | ||
width={64} | ||
height={64} | ||
data-testid="league-history-logo" | ||
src={logoURL} | ||
alt="teamLogo" | ||
/> | ||
{team.teamLogo ? ( | ||
<> | ||
<Image | ||
className="league-entry-logo" | ||
width={64} | ||
height={64} | ||
data-testid="league-history-logo" | ||
src={team.teamLogo} | ||
alt={team.teamName} | ||
/> | ||
</> | ||
) : ( | ||
<span | ||
className="text-xs h-16 w-16 text-primary pt-6 text-center" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this function need to be refactored for this ticket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shashilo
Previously, we only stored URLs for team logos in the
pickHistory
state. But we need to hold on to the team name as well to use it as thealt
text of the image. That's why theentryHistoryObject
.