Skip to content

Commit 1fccf4d

Browse files
committed
improv: Add the ability to pass a custom footer to specific components
The change is required by the captcha plugin in order to have a place to render the captcha input.
1 parent 92c7c1e commit 1fccf4d

File tree

4 files changed

+58
-30
lines changed

4 files changed

+58
-30
lines changed

lib/ts/recipe/emailpassword/components/themes/resetPasswordUsingToken/resetPasswordEmail.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import GeneralError from "../../library/generalError";
2525

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

28-
const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
28+
const EmailPasswordResetPasswordEmail: React.FC<
29+
EnterEmailProps & {
30+
footer?: JSX.Element;
31+
}
32+
> = (props) => {
2933
const t = useTranslation();
3034
const userContext = useUserContext();
3135
const [status, setStatus] = useState<EnterEmailStatus>("READY");
@@ -117,6 +121,7 @@ const EmailPasswordResetPasswordEmail: React.FC<EnterEmailProps> = (props) => {
117121
}}
118122
showLabels={true}
119123
validateOnBlur={true}
124+
footer={props.footer}
120125
/>
121126
</div>
122127
</div>

lib/ts/recipe/emailpassword/components/themes/resetPasswordUsingToken/submitNewPassword.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import GeneralError from "../../library/generalError";
2929

3030
import type { SubmitNewPasswordProps, SubmitNewPasswordStatus } from "../../../types";
3131

32-
const EmailPasswordSubmitNewPassword: React.FC<SubmitNewPasswordProps> = (props) => {
32+
const EmailPasswordSubmitNewPassword: React.FC<
33+
SubmitNewPasswordProps & {
34+
footer?: JSX.Element;
35+
}
36+
> = (props) => {
3337
const t = useTranslation();
3438
const userContext = useUserContext();
3539
const [status, setStatus] = useState<SubmitNewPasswordStatus>("READY");
@@ -120,6 +124,7 @@ const EmailPasswordSubmitNewPassword: React.FC<SubmitNewPasswordProps> = (props)
120124
};
121125
}}
122126
showLabels={true}
127+
footer={props.footer}
123128
/>
124129
</div>
125130
</div>

lib/ts/recipe/passwordless/components/themes/signInUpEPCombo/emailForm.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ import type { SignInUpEPComboEmailFormProps } from "../../../types";
3030

3131
export const EPComboEmailForm = withOverride(
3232
"PasswordlessEPComboEmailForm",
33-
function PasswordlessEPComboEmailForm(props: SignInUpEPComboEmailFormProps): JSX.Element {
33+
function PasswordlessEPComboEmailForm(
34+
props: SignInUpEPComboEmailFormProps & {
35+
footer?: JSX.Element;
36+
}
37+
): JSX.Element {
3438
const t = useTranslation();
3539

3640
const formFields: FormFieldThemeProps[] = [
@@ -46,6 +50,19 @@ export const EPComboEmailForm = withOverride(
4650
},
4751
];
4852

53+
let footer = props.footer;
54+
if (!footer && props.showContinueWithPasswordlessLink) {
55+
footer = (
56+
<ContinueWithPasswordlessFooter
57+
isPhoneNumber={false}
58+
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
59+
onError={props.onError}
60+
config={props.config}
61+
validatePhoneNumber={props.validatePhoneNumber}
62+
/>
63+
);
64+
}
65+
4966
if (props.showPasswordField) {
5067
formFields.push({
5168
id: "password",
@@ -67,7 +84,8 @@ export const EPComboEmailForm = withOverride(
6784
props.navigate
6885
)
6986
}
70-
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink">
87+
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink"
88+
>
7189
{t("PWLESS_COMBO_FORGOT_PW_LINK")}
7290
</a>
7391
</div>
@@ -100,17 +118,7 @@ export const EPComboEmailForm = withOverride(
100118
}}
101119
validateOnBlur={false}
102120
showLabels={true}
103-
footer={
104-
props.showContinueWithPasswordlessLink ? (
105-
<ContinueWithPasswordlessFooter
106-
isPhoneNumber={false}
107-
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
108-
onError={props.onError}
109-
config={props.config}
110-
validatePhoneNumber={props.validatePhoneNumber}
111-
/>
112-
) : undefined
113-
}
121+
footer={footer}
114122
/>
115123
);
116124
}

lib/ts/recipe/passwordless/components/themes/signInUpEPCombo/emailOrPhoneForm.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ import type { SignInUpEPComboEmailOrPhoneFormProps } from "../../../types";
3434

3535
export const EPComboEmailOrPhoneForm = withOverride(
3636
"PasswordlessEPComboEmailOrPhoneForm",
37-
function PasswordlessEPComboEmailOrPhoneForm(props: SignInUpEPComboEmailOrPhoneFormProps): JSX.Element {
37+
function PasswordlessEPComboEmailOrPhoneForm(
38+
props: SignInUpEPComboEmailOrPhoneFormProps & {
39+
footer?: JSX.Element;
40+
}
41+
): JSX.Element {
3842
const t = useTranslation();
3943

4044
useEffect(() => {
@@ -48,6 +52,19 @@ export const EPComboEmailOrPhoneForm = withOverride(
4852
}),
4953
[props.config.signInUpFeature.defaultCountry]
5054
);
55+
56+
let footer = props.footer;
57+
if (!footer && props.showContinueWithPasswordlessLink) {
58+
footer = (
59+
<ContinueWithPasswordlessFooter
60+
isPhoneNumber={props.isPhoneNumber}
61+
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
62+
validatePhoneNumber={props.validatePhoneNumber}
63+
onError={props.onError}
64+
config={props.config}
65+
/>
66+
);
67+
}
5168
const formFields: FormFieldThemeProps[] = props.isPhoneNumber
5269
? [
5370
{
@@ -59,7 +76,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
5976
<Label value={"PWLESS_SIGN_IN_UP_PHONE_LABEL"} />
6077
<a
6178
onClick={() => props.setIsPhoneNumber(false)}
62-
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher">
79+
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher"
80+
>
6381
{t("PWLESS_SIGN_IN_UP_SWITCH_TO_EMAIL")}
6482
</a>
6583
</div>
@@ -82,7 +100,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
82100
<Label value={"PWLESS_SIGN_IN_UP_EMAIL_LABEL"} />
83101
<a
84102
onClick={() => props.setIsPhoneNumber(true)}
85-
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher">
103+
data-supertokens="link linkButton formLabelLinkBtn contactMethodSwitcher"
104+
>
86105
{t("PWLESS_SIGN_IN_UP_SWITCH_TO_PHONE")}
87106
</a>
88107
</div>
@@ -117,7 +136,8 @@ export const EPComboEmailOrPhoneForm = withOverride(
117136
props.navigate
118137
)
119138
}
120-
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink">
139+
data-supertokens="link linkButton formLabelLinkBtn forgotPasswordLink"
140+
>
121141
{t("PWLESS_COMBO_FORGOT_PW_LINK")}
122142
</a>
123143
</div>
@@ -165,17 +185,7 @@ export const EPComboEmailOrPhoneForm = withOverride(
165185
validateOnBlur={false}
166186
showLabels={true}
167187
onSuccess={props.onSuccess}
168-
footer={
169-
props.showContinueWithPasswordlessLink ? (
170-
<ContinueWithPasswordlessFooter
171-
isPhoneNumber={props.isPhoneNumber}
172-
onContinueWithPasswordlessClick={props.onContinueWithPasswordlessClick}
173-
validatePhoneNumber={props.validatePhoneNumber}
174-
onError={props.onError}
175-
config={props.config}
176-
/>
177-
) : undefined
178-
}
188+
footer={footer}
179189
/>
180190
);
181191
}

0 commit comments

Comments
 (0)