Skip to content

Commit

Permalink
fix(644): remove comments, refactor entryHistoryObject
Browse files Browse the repository at this point in the history
  • Loading branch information
CorinaMurg committed Nov 20, 2024
1 parent 7cf34d4 commit 192ad24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 3 additions & 1 deletion api/apiFunctions.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ export interface INFLTeam {
teamLogo: string;
teamName: string;
}
export interface IEntryHistoryTeam extends Omit<INFLTeam, 'teamId'> {}
export interface IPickHistoryTeam extends Omit<INFLTeam, 'teamId'> {}

export interface IUserPicksData extends IUserPick {}

export interface ILeague {
leagueId: string;
leagueName: string;
Expand Down
12 changes: 5 additions & 7 deletions app/(main)/league/[leagueId]/entry/[entryId]/week/Week.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
getGameWeek,
} from '@/api/apiFunctions';
import { ILeague } from '@/api/apiFunctions.interface';
import { IEntryHistoryTeam } from '@/api/apiFunctions.interface';
import { IPickHistoryTeam } from '@/api/apiFunctions.interface';
import WeekTeams from './WeekTeams';
import GlobalSpinner from '@/components/GlobalSpinner/GlobalSpinner';
import { onWeeklyPickChange } from './WeekHelper';
Expand All @@ -44,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<IEntryHistoryTeam[]>([]);
const [pickHistory, setPickHistory] = useState<IPickHistoryTeam[]>([]);
const [entryName, setEntryName] = useState<string>('');
const [error, setError] = useState<string | null>(null);
const [schedule, setSchedule] = useState<ISchedule[]>([]);
Expand Down Expand Up @@ -162,17 +162,15 @@ const Week = ({ entry, league, NFLTeams, week }: IWeekProps): JSX.Element => {

setEntryName(currentEntry.name);
const entryHistory = currentEntry?.selectedTeams || [];

let entryHistoryObject: IEntryHistoryTeam[] = [];

if (entryHistory.length > 0) {
entryHistoryObject = entryHistory.map((teamName) => ({
if (currentEntry?.selectedTeams.length > 0) {
const entryHistoryObject = entryHistory.map((teamName) => ({
teamName: teamName,
teamLogo: getNFLTeamLogo(NFLTeams, teamName),
}));
setPickHistory(entryHistoryObject);
}

setPickHistory(entryHistoryObject);
} catch (error) {
throw new Error("Error fetching user's pick history");
} finally {
Expand Down
11 changes: 5 additions & 6 deletions app/(main)/league/[leagueId]/entry/[entryId]/week/WeekTeams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ const WeekTeams = ({
homeAway={competition.homeAway}
team={competition.team.name}
src={competition.team.logo}
isDisabled={false}
// isDisabled={
// disableGame ||
// Boolean(loadingTeamName) ||
// hasTeamBeenPicked(competition.team.name, selectedTeams)
// }
isDisabled={
disableGame ||
Boolean(loadingTeamName) ||
hasTeamBeenPicked(competition.team.name, selectedTeams)
}
/>
</FormControl>
</FormItem>
Expand Down

0 comments on commit 192ad24

Please sign in to comment.