-
Notifications
You must be signed in to change notification settings - Fork 9
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
Restart Challenge #37
base: development
Are you sure you want to change the base?
Conversation
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.
Looks very good. There are some minor nits to take care of, and you will need to write tests for the code you've added. See the comments that I added to each file for more details. That's about all I see, so once you take care of those things, we'll be able to merge this :)
|
||
try { | ||
const data = await request.json(); | ||
const { userId } = restartChallengeSchema.parse(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.
^ I don't think this route actualy needs a schema, or to read any data from the request body, for that matter. I think you can just use the Auth class to get the user from cookies.
|
||
const user = await auth.loadSessionUser(); | ||
// impossible that frontend and cookie issue. | ||
if (!user || user.uid !== userId) { |
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.
^ Please remove vestigial comments such as this one and the one on line 24
return NextResponse.json({ error: e.message }, { status: e.statusCode }); | ||
} | ||
|
||
return NextResponse.json({ error: 'Bad data.' }, { status: 400 }); |
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.
Because this route will no longer be parsing a request body, this catch all statement should probably be a 500 error code with a more general error message.
try{ | ||
setLoading(true); | ||
await restartChallenge(); | ||
} catch (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.
Maybe use the AlertsContext to show the user an error message if this fails?
} | ||
|
||
return updatedChallengeEndTimestamp; | ||
//follow the style of getUserById AND supabase->throw an 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.
^ Please remove this comment.
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.
Could you tidy up the vertical whitespace in this file, please?
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.
The button component has been moved to src/components/utils/button
, so all the folder src/components/button
and all its contents can safely be deleted.
Checklist
Overview
Test Plan
Follow ups