Skip to content
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

Mai/feat 310 add make pick button functionali #376

Merged
merged 37 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8e23935
feat #352: updating the entry page logic
shashilo Jul 3, 2024
a4118e7
Fixing failed linting
shashilo Jul 3, 2024
2374f91
Merge remote-tracking branch 'origin/develop' into shashi/entries-page
shashilo Jul 3, 2024
db2aca9
Merge branch 'develop' into shashi/entries-page
shashilo Jul 3, 2024
cfd953b
Update failing unit test
shashilo Jul 3, 2024
2975439
Merge branch 'shashi/entries-page' of https://github.com/LetsGetTechn…
shashilo Jul 3, 2024
c40febb
Merge branch 'develop' into shashi/entries-page
shashilo Jul 4, 2024
ec05b49
Update unit tests from merge conflict
shashilo Jul 6, 2024
21ceca0
feat #374: adding ability to create new entry for a user
shashilo Jul 6, 2024
1ddaffe
Fixing linting errors
shashilo Jul 6, 2024
511fc4f
added in isPickSet
vmaineng Jul 7, 2024
bb98c59
thoughts
vmaineng Jul 7, 2024
b2655b0
added in isPickSet and isEliminated
vmaineng Jul 7, 2024
39184a8
Merge remote-tracking branch 'origin/shashi/add-entry-logic' into mai…
vmaineng Jul 7, 2024
7dd7a40
Merge branch 'develop' of github.com:LetsGetTechnical/gridiron-surviv…
vmaineng Jul 7, 2024
6d542e7
add change
vmaineng Jul 9, 2024
ca0c821
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 11, 2024
56db007
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 16, 2024
5bac0ef
added in team logo
vmaineng Jul 16, 2024
211fb5e
fixing due to esLint rules
vmaineng Jul 16, 2024
e92213d
added in unit test for teamlogo
vmaineng Jul 16, 2024
f962596
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 17, 2024
38a0fa3
updated code from ryan review
vmaineng Jul 17, 2024
4abbda0
made adjustments according to shashi comments
vmaineng Jul 18, 2024
3a0a2f4
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 19, 2024
06aa565
added in changes
vmaineng Jul 19, 2024
4ada0da
added in leagueLink attribute test
vmaineng Jul 19, 2024
6800fae
Merge branch 'mai/feat-310-add-make-pick-button-functionali' of githu…
vmaineng Jul 19, 2024
c9e85d6
leaving teamLogo as required
vmaineng Jul 19, 2024
ede4210
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 19, 2024
76d2799
reverted teamlogo back to optional
vmaineng Jul 23, 2024
32b056f
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 23, 2024
8b41c9d
updated docs
vmaineng Jul 23, 2024
6964c13
updated notes
vmaineng Jul 23, 2024
fbb86a1
fixed closing paraenthesis
vmaineng Jul 23, 2024
6813b62
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 25, 2024
f6e93a0
Merge branch 'develop' into mai/feat-310-add-make-pick-button-functio…
vmaineng Jul 29, 2024
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
1 change: 1 addition & 0 deletions api/apiFunctions.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IWeeklyPicks {
}
export interface INFLTeam {
teamId: string;
teamLogo: string;
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
teamName: string;
}
export interface IUserPicksData extends IUserPick {}
Expand Down
1 change: 1 addition & 0 deletions api/apiFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const getNFLTeams = async (): Promise<INFLTeam[]> => {

const nflTeams = response.documents.map((team) => ({
teamId: team.$id,
teamLogo: team.teamLogo,
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
teamName: team.teamName,
}));

Expand Down
5 changes: 4 additions & 1 deletion app/(main)/league/[leagueId]/entry/all/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

'use client';

import {
createEntry,
getCurrentUserEntries,
Expand Down Expand Up @@ -87,13 +86,17 @@ const Entry = ({
<>
{entries.map((entry) => {
const linkUrl = `/${LEAGUE_URL}/${leagueId}/${ENTRY_URL}/${entry.$id}/${WEEK_URL}/${currentWeek}`;
const isPickSet = entry.selectedTeams.length > 0;
const teamLogo = isPickSet ? entry.selectedTeams[0].teamLogo : '';

return (
<section key={entry.$id}>
<LeagueEntries
key={entry.$id}
entryName={entry.name}
isPickSet={isPickSet}
linkUrl={linkUrl}
teamLogo={teamLogo}
shashilo marked this conversation as resolved.
Show resolved Hide resolved
/>
</section>
);
Expand Down
1 change: 1 addition & 0 deletions components/LeagueEntries/LeagueEntries.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export interface ILeagueEntriesProps {
linkUrl: string;
isEliminated?: boolean;
isPickSet?: boolean;
teamLogo?: string;
shashilo marked this conversation as resolved.
Show resolved Hide resolved
}
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
34 changes: 33 additions & 1 deletion components/LeagueEntries/LeagueEntries.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ describe('LeagueEntries', () => {
render(
<LeagueEntries
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
entryName="Entry 3"
linkUrl=""
isEliminated
isPickSet={false}
linkUrl=""
/>,
);

Expand All @@ -61,4 +61,36 @@ describe('LeagueEntries', () => {
);
expect(leagueEntryNumber).toHaveTextContent('Entry 3');
});

it('renders teamLogo when user makes a pick', () => {
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
const teamLogoUrl = 'https://example.com/logo.png';
const linkUrl = '/change-pick';

render(
<LeagueEntries
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
entryName="Entry 2"
isPickSet={true}
linkUrl={linkUrl}
teamLogo={teamLogoUrl}
/>,
);

const leagueEntryContainerCard = screen.getByTestId(
'league-entry-container-card',
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
);
const leagueEntryNumber = screen.getByTestId('league-entry-number');
const entryStatus = screen.getByTestId('entry-status');
const leagueEntryPickButton = screen.getByTestId(
'league-entry-pick-button',
ryandotfurrer marked this conversation as resolved.
Show resolved Hide resolved
);
const leagueLink = screen.getByTestId('league-entry-pick-button-link');
const leagueEntryLogo = screen.getByTestId('league-entry-logo');

expect(entryStatus).toHaveTextContent('alive');
expect(leagueEntryNumber).toHaveTextContent('Entry 2');
expect(leagueEntryPickButton).toHaveTextContent('Change Pick');
expect(leagueLink).toHaveAttribute('href', linkUrl);
expect(leagueEntryLogo).toBeInTheDocument();
expect(leagueEntryLogo).toHaveAttribute('src', teamLogoUrl);
});
});
8 changes: 5 additions & 3 deletions components/LeagueEntries/LeagueEntries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import Link from 'next/link';
* @param props.linkUrl - the url to the user's entry page
* @param props.isEliminated - If true, the user is flagged as eliminat4ed
* @param props.isPickSet - if true, the team logo of the picked team shows up on the LeagueEntries card and the button changes from "make a pick" to "chagne pick"
* @param props.teamLogo - the team logo
* @returns {React.JSX.Element} - A div element that contains the user's entry information
*/
const LeagueEntries = ({
entryName,
linkUrl,
isEliminated = false,
isPickSet = false,
teamLogo = '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not default this to an empty string. Make it required. We will need to update our DB with the remaining NFL team logos.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to not default to an empty string.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's still empty.

Suggested change
teamLogo = '',
teamLogo,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shashilo the reason why I made it empty is because if teamLogo is optional, it will default to an empty string, similar to isPickSet and isEliminated. Please let me know what your thoughts are. Thanks!

}: ILeagueEntriesProps): JSX.Element => (
<div
data-testid="league-entry-container-card"
Expand Down Expand Up @@ -53,8 +55,8 @@ const LeagueEntries = ({
<img
className="league-entry-logo h-12 w-12"
data-testid="league-entry-logo"
src="https://ryanfurrer.com/_astro/logo-dark-theme.CS8e9u7V_JfowQ.svg"
alt="League name"
src={teamLogo}
alt="teamLogo"
/>
)}

Expand All @@ -63,7 +65,7 @@ const LeagueEntries = ({
data-testid="league-entry-pick-button-container"
>
{!isEliminated && (
<Link href={linkUrl}>
<Link href={linkUrl} data-testid="league-entry-pick-button-link">
<Button
className="league-entry-pick-button"
data-testid="league-entry-pick-button"
Expand Down