Skip to content

Instantly share code, notes, and snippets.

@rasikag
Created March 11, 2021 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rasikag/34945dc68a3dc96369ec321812f56178 to your computer and use it in GitHub Desktop.
Save rasikag/34945dc68a3dc96369ec321812f56178 to your computer and use it in GitHub Desktop.
// add below code lines above from return method
const router = useRouter();
const [, changePassword] = useChangePasswordMutation();
// ...
onSubmit={async (values, { setErrors }) => {
const response = await changePassword({
newPassword: values.newPassword,
token,
});
if (response.data?.changePassword.errors) {
// the graphql errors like this
// [{filed: "username", message: "value empty"}]
setErrors(toErrorMap(response.data.changePassword.errors));
} else if (response.data?.changePassword.user) {
// TODO: try to move this else if block
// user log in successfully
router.push("/");
}
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment