fix(frontend): bad handling on error prompts (#9754)

<!-- Clearly explain the need for these changes: -->

I oopsed and had an extra unneeded parameter (as @majdyz pointed out)
and wasn't respected everywhere it was used.

### Changes 🏗️

<!-- Concisely describe all of the changes made in this pull request:
-->
- Remove parameter
- update all the places AuthFeedback is called

### Checklist 📋

#### For code changes:
- [ ] I have clearly listed my changes in the PR description
- [ ] I have made a test plan
- [ ] I have tested my changes according to the test plan:
  <!-- Put your test plan here: -->
  - [ ] Test all pages with authfeedback on it

Co-authored-by: Bently <tomnoon9@gmail.com>
This commit is contained in:
Nicholas Tindle
2025-04-03 17:16:39 -05:00
committed by GitHub
parent 8ceb03ce1a
commit 2e871b0761
4 changed files with 19 additions and 11 deletions

View File

@@ -26,6 +26,7 @@ import {
PasswordInput,
} from "@/components/auth";
import { loginFormSchema } from "@/types/auth";
import { getBehaveAs } from "@/lib/utils";
export default function LoginPage() {
const { supabase, user, isUserLoading } = useSupabase();
@@ -147,7 +148,11 @@ export default function LoginPage() {
Login
</AuthButton>
</form>
<AuthFeedback message={feedback} isError={true} />
<AuthFeedback
message={feedback}
isError={!!feedback}
behaveAs={getBehaveAs()}
/>
</Form>
<AuthBottomText
text="Don't have an account?"

View File

@@ -24,6 +24,7 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
import { changePassword, sendResetEmail } from "./actions";
import Spinner from "@/components/Spinner";
import { getBehaveAs } from "@/lib/utils";
export default function ResetPasswordPage() {
const { supabase, user, isUserLoading } = useSupabase();
@@ -151,7 +152,11 @@ export default function ResetPasswordPage() {
>
Update password
</AuthButton>
<AuthFeedback message={feedback} isError={isError} />
<AuthFeedback
message={feedback}
isError={isError}
behaveAs={getBehaveAs()}
/>
</Form>
</form>
) : (
@@ -178,7 +183,11 @@ export default function ResetPasswordPage() {
>
Send reset email
</AuthButton>
<AuthFeedback message={feedback} isError={isError} />
<AuthFeedback
message={feedback}
isError={isError}
behaveAs={getBehaveAs()}
/>
</Form>
</form>
)}

View File

@@ -36,7 +36,6 @@ export default function SignupPage() {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
//TODO: Remove after closed beta
const [showErrorPrompt, setShowErrorPrompt] = useState(false);
const form = useForm<z.infer<typeof signupFormSchema>>({
resolver: zodResolver(signupFormSchema),
@@ -64,13 +63,11 @@ export default function SignupPage() {
setFeedback("User with this email already exists");
return;
} else {
setShowErrorPrompt(true);
setFeedback(error);
}
return;
}
setFeedback(null);
setShowErrorPrompt(false);
},
[form],
);
@@ -193,7 +190,6 @@ export default function SignupPage() {
<AuthFeedback
message={feedback}
isError={!!feedback}
showErrorPrompt={showErrorPrompt}
behaveAs={getBehaveAs()}
/>

View File

@@ -7,14 +7,12 @@ import { BehaveAs } from "@/lib/utils";
interface Props {
message?: string | null;
isError?: boolean;
showErrorPrompt?: boolean;
behaveAs?: BehaveAs;
}
export default function AuthFeedback({
message = "",
isError = false,
showErrorPrompt = false,
behaveAs = BehaveAs.CLOUD,
}: Props) {
// If there's no message but isError is true, show a default error message
@@ -41,7 +39,7 @@ export default function AuthFeedback({
)}
{/* Cloud-specific help */}
{showErrorPrompt && behaveAs === BehaveAs.CLOUD && (
{isError && behaveAs === BehaveAs.CLOUD && (
<div className="mt-2 space-y-2 text-sm">
<span className="block text-center font-medium text-red-500">
The provided email may not be allowed to sign up.
@@ -85,7 +83,7 @@ export default function AuthFeedback({
)}
{/* Local-specific help */}
{showErrorPrompt && behaveAs === BehaveAs.LOCAL && (
{isError && behaveAs === BehaveAs.LOCAL && (
<Card className="overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm">
<CardContent className="p-0">
<div className="space-y-4 divide-y divide-slate-100">