back button, error handling

This commit is contained in:
peintnermax
2024-09-11 09:56:58 +02:00
parent 0b07a71bfa
commit 48291ca6ed
3 changed files with 5 additions and 8 deletions

View File

@@ -55,13 +55,13 @@ export default function ChangePasswordForm({
userId: userId,
password: values.password,
}).catch((error: Error) => {
setError(error.message ?? "Could not register user");
setError(error.message ?? "Could not change password");
});
setLoading(false);
if (!response) {
setError("Could not register user");
setError("Could not change password");
return;
}

View File

@@ -89,9 +89,7 @@ export default function RegisterFormWithoutPassword({
if (withPassword) {
return router.push(`/register?` + new URLSearchParams(registerParams));
} else {
const session = await submitAndRegister(value).catch((error) => {
setError(error.message ?? "Could not register user");
});
const session = await submitAndRegister(value);
const params = new URLSearchParams({});
if (session?.factors?.user?.loginName) {

View File

@@ -12,6 +12,7 @@ import { useRouter } from "next/navigation";
import { useState } from "react";
import { FieldValues, useForm } from "react-hook-form";
import Alert from "./Alert";
import BackButton from "./BackButton";
import { Button, ButtonVariants } from "./Button";
import { TextInput } from "./Input";
import PasswordComplexity from "./PasswordComplexity";
@@ -150,9 +151,7 @@ export default function SetPasswordForm({
{error && <Alert>{error}</Alert>}
<div className="mt-8 flex w-full flex-row items-center justify-between">
<Button type="button" variant={ButtonVariants.Secondary}>
back
</Button>
<BackButton />
<Button
type="submit"
variant={ButtonVariants.Primary}