fix: update error messages and statuses in VerifyRegistrationOTP function for clarity
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m45s

This commit is contained in:
i701 2025-04-18 18:53:20 +05:00
parent cd2cff7926
commit e0e3de064a
Signed by: i701
GPG Key ID: 54A0DA1E26D8E587
3 changed files with 17 additions and 7 deletions

View File

@ -152,7 +152,7 @@ export async function signup(_actionState: ActionState, formData: FormData) {
backendRegister({
payload: {
firstname: parsedData.data.name.split(" ")[0],
lastname: parsedData.data.name.split(" ")[1],
lastname: parsedData.data.name.split(" ").slice(1).join(" "),
username: parsedData.data.phone_number,
address: parsedData.data.address,
id_card: parsedData.data.id_card,

View File

@ -43,7 +43,7 @@ export default function VerifyRegistrationOTPForm({
hidden
/>
<Input
disabled={isPending}
disabled={isPending || state.status === "verify_error"}
id="otp-number"
name="otp"
maxLength={6}
@ -58,7 +58,11 @@ export default function VerifyRegistrationOTPForm({
<p className="text-red-500 text-sm">{state.message}</p>
)}
</div>
<Button className="w-full" disabled={isPending} type="submit">
<Button
className="w-full"
disabled={isPending || state.status === "verify_error"}
type="submit"
>
{isPending ? (
<Loader2 className="animate-spin" />
) : (

View File

@ -174,8 +174,9 @@ export async function VerifyRegistrationOTP(
if (error) {
return {
message: "Your account could not be verified. Please contact support.",
status: "verify_error",
message:
"There was an error fetching your account information. Please contact support.",
status: "user_check_error",
};
}
if (userVerified.verified) {
@ -184,13 +185,18 @@ export async function VerifyRegistrationOTP(
);
if (mobileLoginError) {
return {
message: "Your account could not be verified. Please contact support.",
status: "verify_error",
message: "Login Failed. Please contact support.",
status: "login_error",
};
}
if (mobileLoginResponse) {
redirect(`/auth/verify-otp?phone_number=${mobile}`);
}
} else {
return {
message: "Your account could not be verified. Please contact support.",
status: "verify_error",
};
}
return {