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

Alex/bug bash: add alert when pick is updated #415

Merged
merged 27 commits into from
Jul 29, 2024

Conversation

alexappleget
Copy link
Contributor

@alexappleget alexappleget commented Jul 15, 2024

Added in Alert notifications for when users pick/update their teams

Closes: #414

Copy link

appwrite bot commented Jul 15, 2024

Gridiron Survivor Application 6616ea581ef9f5521c7d

Function ID Status Action
Your function deployment has failed. Please check the logs for more details and retry.

Project name: Gridiron Survivor Application
Project ID: 6616ea581ef9f5521c7d

Function ID Status Action
userAuth 6626fef885a9f630442b failed Failed View Logs

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.

💡 Did you know?
You can use Avatars API to generate QR code for any text or URLs

Copy link

vercel bot commented Jul 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gridiron-survivor ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 1:55pm
gridiron-survivor-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 1:55pm

@alexappleget alexappleget changed the title Alex/414 bug bash add alert when pick is upda Alex/414 bug bash add alert when pick is updated Jul 16, 2024
* @returns {void}
*/
const onWeeklyPickChange = async (
const handleWeeklyPickChange = async (
Copy link
Collaborator

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?

Copy link
Contributor Author

@alexappleget alexappleget Jul 17, 2024

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

Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

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>;
Copy link
Collaborator

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';
Copy link
Collaborator

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.

Suggested change
import { createWeeklyPicks } from '../../../../../../api/apiFunctions';
import { createWeeklyPicks } from '@/api/apiFunctions';

Copy link
Contributor Author

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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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' }];
Copy link
Collaborator

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', () => ({
Copy link
Collaborator

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?

Copy link
Contributor Author

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 || '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const currentUserPick = mockParseUserPick(user.id, entry, teamID || '');
const currentUserPick = mockParseUserPick(user.id, entry, teamID);

expect(mockParseUserPick).toHaveBeenCalledWith(
user.id,
entry,
teamID || '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
teamID || '',
teamID,

ryandotfurrer
ryandotfurrer previously approved these changes Jul 22, 2024
IUser,
} from '@/api/apiFunctions.interface';

export interface IData {
Copy link
Collaborator

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;
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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);
Copy link
Collaborator

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);
Copy link
Collaborator

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.

Copy link
Contributor Author

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?

updateWeeklyPicks: ({}: IWeeklyPicks) => void;
user: IUser;
weeklyPicks: IWeeklyPicks;
week: string;
Copy link
Collaborator

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.

@alexappleget alexappleget merged commit d928a5b into develop Jul 29, 2024
5 checks passed
@alexappleget alexappleget deleted the alex/414-bug-bash-add-alert-when-pick-is-upda branch July 29, 2024 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Bash: Add alert when pick is updated
4 participants