-
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
Alex/bug bash: add alert when pick is updated #415
Alex/bug bash: add alert when pick is updated #415
Conversation
Gridiron Survivor Application
Project name: Gridiron Survivor Application
Only deployments on the production branch are activated automatically. If you'd like to activate this deployment, navigate to your deployments. Learn more about Appwrite Function deployments.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
* @returns {void} | ||
*/ | ||
const onWeeklyPickChange = async ( | ||
const handleWeeklyPickChange = async ( |
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 was this name changed?
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.
i changed the name because the onWeeklyPickChange was decoupled and then imported. i didnt want to have:
const onWeeklyPickChange = async () => {
await onWeeklyPickChange(params);
}
won't that cause confusion to vs code?
i did the same with loginAccount
I even changed it back to 'onWeeklyPickChange' and it just breaks things. I have to name the parent something different than the decoupled function I have inside
I can do a few things depending on what you want. Keep it as onWeeklyPickChange BUT I would have to change the decoupled function name. or I can leave it as it is
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.
Makes sense.
console.error('Submission error:', error); | ||
} | ||
const params = { | ||
data, |
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.
Alphabetize the list
* @returns {void} | ||
*/ | ||
export const onWeeklyPickChange = async ({ | ||
data, |
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.
Alphabetize the list
updateWeeklyPicks, | ||
setUserPick, | ||
}: { | ||
data: ChangeEvent<HTMLInputElement>; |
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.
Make this an Interface
import { AlertVariants } from '@/components/AlertNotification/Alerts.enum'; | ||
import { toast } from 'react-hot-toast'; | ||
import { onWeeklyPickChange } from './WeekHelper'; | ||
import { createWeeklyPicks } from '../../../../../../api/apiFunctions'; |
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.
This should work. Test it out for all paths.
import { createWeeklyPicks } from '../../../../../../api/apiFunctions'; | |
import { createWeeklyPicks } from '@/api/apiFunctions'; |
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.
sweet it works now for that path
[key: string]: any; // Adjust the 'any' to match the structure of your user results | ||
} | ||
|
||
interface IWeeklyPicks { |
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 are we recreating the interfaces in a test?
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.
I had to create mock ones to define everything else in the tests
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.
oh sorry i understand now and fixed it. I keep thinking that in tests you have to explain EVERYTHING to it. I didn't realize you can easily import IWeeklyPicks and use it inside the test easily
preventDefault: jest.fn(), | ||
stopPropagation: jest.fn(), | ||
} as any; | ||
const NFLTeams = [{ teamName: 'Browns', teamId: 'mockId' }]; |
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.
For the ID, use a string number, just like the DB. It doens't have to be long, but it should be numbers.
}, | ||
}); | ||
|
||
jest.mock('../../../../../../utils/utils', () => ({ |
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 not put this in the parent so other test can use it too?
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.
I had it inside the test itself because it was only used for that test and defined inside it. I changed things and moved it all in the parent
parseUserPick: mockParseUserPick, | ||
})); | ||
|
||
const currentUserPick = mockParseUserPick(user.id, entry, teamID || ''); |
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.
const currentUserPick = mockParseUserPick(user.id, entry, teamID || ''); | |
const currentUserPick = mockParseUserPick(user.id, entry, teamID); |
expect(mockParseUserPick).toHaveBeenCalledWith( | ||
user.id, | ||
entry, | ||
teamID || '', |
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.
teamID || '', | |
teamID, |
app/(main)/league/[leagueId]/entry/[entryId]/week/Week.test.tsx
Outdated
Show resolved
Hide resolved
…://github.com/LetsGetTechnical/gridiron-survivor into alex/414-bug-bash-add-alert-when-pick-is-upda
…add-alert-when-pick-is-upda
IUser, | ||
} from '@/api/apiFunctions.interface'; | ||
|
||
export interface IData { |
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.
Make this more specific. IData is a generic name that could be for anything. Match the data structure. IWeekData is a much clearer name.
updateWeeklyPicks: ({}: IWeeklyPicks) => void; | ||
user: IUser; | ||
weeklyPicks: IWeeklyPicks; | ||
week: string; |
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.
Do we have an ENUM for the weeks?
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.
we do not. when i looked into it, it is just something that gets passed in as a string
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.
nit: We should look to adding it later. There's only week 1-18 available.
weeklyPicks, | ||
week, | ||
}; | ||
await onWeeklyPickChange(params); |
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.
Add a try/catch here.
/>, | ||
); | ||
} catch (error) { | ||
console.error('Submission error:', error); |
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.
Change this to throw a new error and allow the function to catch the error.
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.
Is this basically so that we can more easily catch where the issue lies when it errors? So, the trycatch() being added into handleWeeklyPickChange() and then changing this console.error() will allow us to figure out where an issue lies?
…r inside onWeeklyPickChange(), and updated IData to IWeekData
updateWeeklyPicks: ({}: IWeeklyPicks) => void; | ||
user: IUser; | ||
weeklyPicks: IWeeklyPicks; | ||
week: string; |
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.
nit: We should look to adding it later. There's only week 1-18 available.
Added in Alert notifications for when users pick/update their teams
Closes: #414