Created
March 11, 2021 18:14
-
-
Save rasikag/34945dc68a3dc96369ec321812f56178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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