Skip to content

Commit e765077

Browse files
committed
refactor(react): Align ForgotPasswordAuth{Screen,Form} with API spec
1 parent a366371 commit e765077

File tree

6 files changed

+15
-13
lines changed

6 files changed

+15
-13
lines changed

packages/react/src/auth/forms/forgot-password-form.test.tsx renamed to packages/react/src/auth/forms/forgot-password-auth-form.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { describe, it, expect, vi, beforeEach, Mock } from "vitest";
1818
import { render, screen, fireEvent } from "@testing-library/react";
19-
import { ForgotPasswordForm } from "./forgot-password-form";
19+
import { ForgotPasswordForm } from "./forgot-password-auth-form";
2020
import { act } from "react";
2121

2222
// Mock the dependencies

packages/react/src/auth/forms/forgot-password-form.tsx renamed to packages/react/src/auth/forms/forgot-password-auth-form.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ import { Button } from "../../components/button";
3030
import { FieldInfo } from "../../components/field-info";
3131
import { Policies } from "../../components/policies";
3232

33-
interface ForgotPasswordFormProps {
33+
export type ForgotPasswordAuthFormProps = {
34+
onPasswordSent?: () => void;
3435
onBackToSignInClick?: () => void;
3536
}
3637

37-
export function ForgotPasswordForm({ onBackToSignInClick }: ForgotPasswordFormProps) {
38+
export function ForgotPasswordAuthForm({ onBackToSignInClick, onPasswordSent }: ForgotPasswordAuthFormProps) {
3839
const ui = useUI();
3940

4041
const [formError, setFormError] = useState<string | null>(null);
@@ -55,6 +56,7 @@ export function ForgotPasswordForm({ onBackToSignInClick }: ForgotPasswordFormPr
5556
try {
5657
await sendPasswordResetEmail(ui, value.email);
5758
setEmailSent(true);
59+
onPasswordSent?.();
5860
} catch (error) {
5961
if (error instanceof FirebaseUIError) {
6062
setFormError(error.message);

packages/react/src/auth/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export { SignUpAuthScreen, type SignUpAuthScreenProps } from "./screens/sign-up-
2424

2525
export { OAuthScreen, type OAuthScreenProps } from "./screens/oauth-screen";
2626

27-
export { PasswordResetScreen, type PasswordResetScreenProps } from "./screens/password-reset-screen";
27+
export { ForgotPasswordAuthScreen, type ForgotPasswordAuthScreenProps } from "./screens/forgot-password-auth-screen";
2828

2929
/** Export forms */
3030
export { EmailPasswordForm, type EmailPasswordFormProps } from "./forms/email-password-form";

packages/react/src/auth/screens/password-reset-screen.test.tsx renamed to packages/react/src/auth/screens/forgot-password-auth-screen.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { describe, it, expect, vi, afterEach } from "vitest";
1818
import { render, fireEvent } from "@testing-library/react";
19-
import { PasswordResetScreen } from "~/auth/screens/password-reset-screen";
19+
import { PasswordResetScreen } from "~/auth/screens/forgot-password-auth-screen";
2020
import * as hooks from "~/hooks";
2121

2222
// Mock the hooks

packages/react/src/auth/screens/password-reset-screen.tsx renamed to packages/react/src/auth/screens/forgot-password-auth-screen.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
import { getTranslation } from "@firebase-ui/core";
1818
import { useUI } from "~/hooks";
19-
import { Card, CardHeader, CardSubtitle, CardTitle } from "../../components/card";
20-
import { ForgotPasswordForm } from "../forms/forgot-password-form";
19+
import { Card, CardContent, CardHeader, CardSubtitle, CardTitle } from "../../components/card";
20+
import { ForgotPasswordAuthForm, type ForgotPasswordAuthFormProps } from "../forms/forgot-password-auth-form";
2121

22-
export type PasswordResetScreenProps = {
23-
onBackToSignInClick?: () => void;
24-
};
22+
export type ForgotPasswordAuthScreenProps = ForgotPasswordAuthFormProps;
2523

26-
export function PasswordResetScreen({ onBackToSignInClick }: PasswordResetScreenProps) {
24+
export function ForgotPasswordAuthScreen(props: ForgotPasswordAuthScreenProps) {
2725
const ui = useUI();
2826

2927
const titleText = getTranslation(ui, "labels", "resetPassword");
@@ -36,7 +34,9 @@ export function PasswordResetScreen({ onBackToSignInClick }: PasswordResetScreen
3634
<CardTitle>{titleText}</CardTitle>
3735
<CardSubtitle>{subtitleText}</CardSubtitle>
3836
</CardHeader>
39-
<ForgotPasswordForm onBackToSignInClick={onBackToSignInClick} />
37+
<CardContent>
38+
<ForgotPasswordAuthForm {...props} />
39+
</CardContent>
4040
</Card>
4141
</div>
4242
);

packages/react/tests/integration/auth/forgot-password.integration.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { describe, it, expect, afterAll, beforeEach } from "vitest";
1818
import { fireEvent, waitFor, act, render } from "@testing-library/react";
19-
import { ForgotPasswordForm } from "../../../src/auth/forms/forgot-password-form";
19+
import { ForgotPasswordForm } from "../../../src/auth/forms/forgot-password-auth-form";
2020
import { initializeApp } from "firebase/app";
2121
import {
2222
getAuth,

0 commit comments

Comments
 (0)