Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reset-password)!: move the overridden components inside auth container #868

Open
wants to merge 3 commits into
base: 0.49
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## [0.49.0] 2024-12-13

### Breaking changes

- Moved the overridden components UI inside auth container which was earlier being rendered outside the auth container

## [0.48.0] - 2024-10-07

### Fixes
Expand Down
289 changes: 135 additions & 154 deletions lib/build/emailpasswordprebuiltui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/build/genericComponentOverrideContext.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/build/recipe/emailpassword/types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/build/version.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
import { useState } from "react";
import { Fragment, useState } from "react";

import { withOverride } from "../../../../../components/componentOverride/withOverride";
import { useTranslation } from "../../../../../translation/translationContext";
Expand All @@ -25,48 +25,44 @@ import GeneralError from "../../library/generalError";

import type { EnterEmailProps, EnterEmailStatus } from "../../../types";

const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
const t = useTranslation();
const userContext = useUserContext();
const [status, setStatus] = useState<EnterEmailStatus>("READY");
const [emailFieldValue, setEmailFieldValue] = useState<string>("");

const onSuccess = (): void => {
setStatus("SENT");
};

const resend = (): void => {
setStatus("READY");
};
const { formFields } = props;
export const EmailPasswordResetPasswordEmail = withOverride(
"EmailPasswordResetPasswordEmail",
(
props: EnterEmailProps & {
status: EnterEmailStatus;
onSuccess: () => void;
resend: () => void;
}
) => {
const t = useTranslation();
const userContext = useUserContext();
const [emailFieldValue, setEmailFieldValue] = useState<string>("");
const { formFields } = props;

const emailSuccessText =
t("EMAIL_PASSWORD_RESET_SEND_BEFORE_EMAIL") +
(emailFieldValue !== undefined && emailFieldValue.length > 0
? emailFieldValue
: t("EMAIL_PASSWORD_RESET_SEND_FALLBACK_EMAIL")) +
t("EMAIL_PASSWORD_RESET_SEND_AFTER_EMAIL");
const emailSuccessText =
t("EMAIL_PASSWORD_RESET_SEND_BEFORE_EMAIL") +
(emailFieldValue !== undefined && emailFieldValue.length > 0
? emailFieldValue
: t("EMAIL_PASSWORD_RESET_SEND_FALLBACK_EMAIL")) +
t("EMAIL_PASSWORD_RESET_SEND_AFTER_EMAIL");

if (status === "SENT") {
return (
<div data-supertokens="container">
<div data-supertokens="row">
if (props.status === "SENT") {
return (
<Fragment>
<div data-supertokens="primaryText enterEmailSuccessMessage">
{emailSuccessText}
<span data-supertokens="link resendEmailLink" onClick={resend}>
<span data-supertokens="link resendEmailLink" onClick={props.resend}>
{t("EMAIL_PASSWORD_RESET_RESEND_LINK")}
</span>
</div>
<BackToSignInButton onClick={props.onBackButtonClicked} />
</div>
</div>
);
}
</Fragment>
);
}

// Otherwise, return Form.
return (
<div data-supertokens="container resetPasswordEmailForm">
<div data-supertokens="row">
// Otherwise, return Form.
return (
<Fragment>
<div data-supertokens="headerTitle withBackButton">
<BackButton onClick={props.onBackButtonClicked} />
{t("EMAIL_PASSWORD_RESET_HEADER_TITLE")}
Expand All @@ -81,7 +77,7 @@ const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
onError={props.onError}
formFields={formFields}
buttonLabel={"EMAIL_PASSWORD_RESET_SEND_BTN"}
onSuccess={onSuccess}
onSuccess={props.onSuccess}
callAPI={async (formFields) => {
const validationErrors = await validateForm(
formFields,
Expand Down Expand Up @@ -118,9 +114,26 @@ const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
showLabels={true}
validateOnBlur={true}
/>
</Fragment>
);
}
);

export const ResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
const [status, setStatus] = useState<EnterEmailStatus>("READY");
const onSuccess = (): void => {
setStatus("SENT");
};

const resend = (): void => {
setStatus("READY");
};

return (
<div data-supertokens={`container ${status === "SENT" ? "" : "resetPasswordEmailForm"}`}>
<div data-supertokens="row">
<EmailPasswordResetPasswordEmail {...props} status={status} onSuccess={onSuccess} resend={resend} />
</div>
</div>
);
};

export const ResetPasswordEmail = withOverride("EmailPasswordResetPasswordEmail", EmailPasswordResetPasswordEmail);
4 changes: 2 additions & 2 deletions lib/ts/recipe/emailpassword/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import type { InputProps } from "./components/library/input";
import type { ResetPasswordEmail } from "./components/themes/resetPasswordUsingToken/resetPasswordEmail";
import type { EmailPasswordResetPasswordEmail } from "./components/themes/resetPasswordUsingToken/resetPasswordEmail";
import type { SubmitNewPassword } from "./components/themes/resetPasswordUsingToken/submitNewPassword";
import type { SignInForm } from "./components/themes/signIn";
import type { SignUpForm } from "./components/themes/signUp";
Expand Down Expand Up @@ -43,7 +43,7 @@ import type { User } from "supertokens-web-js/types";
export type ComponentOverrideMap = {
EmailPasswordSignInForm_Override?: ComponentOverride<typeof SignInForm>;
EmailPasswordSignUpForm_Override?: ComponentOverride<typeof SignUpForm>;
EmailPasswordResetPasswordEmail_Override?: ComponentOverride<typeof ResetPasswordEmail>;
EmailPasswordResetPasswordEmail_Override?: ComponentOverride<typeof EmailPasswordResetPasswordEmail>;
EmailPasswordSubmitNewPassword_Override?: ComponentOverride<typeof SubmitNewPassword>;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/ts/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
export const package_version = "0.48.0";
export const package_version = "0.49.0";
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "supertokens-auth-react",
"version": "0.48.0",
"version": "0.49.0",
"description": "ReactJS SDK that provides login functionality with SuperTokens.",
"main": "./index.js",
"engines": {
Expand Down