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({ backendRegister({
payload: { payload: {
firstname: parsedData.data.name.split(" ")[0], 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, username: parsedData.data.phone_number,
address: parsedData.data.address, address: parsedData.data.address,
id_card: parsedData.data.id_card, id_card: parsedData.data.id_card,

View File

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

View File

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