2022-11-22 07:58:37 +01:00
|
|
|
/*
|
2024-09-09 14:57:16 +01:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2022-11-22 07:58:37 +01:00
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
2024-09-09 14:57:16 +01:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-11-22 07:58:37 +01:00
|
|
|
*/
|
|
|
|
|
|
2024-01-09 11:46:27 +00:00
|
|
|
import React, { ReactNode } from "react";
|
|
|
|
|
import { Tooltip } from "@vector-im/compound-web";
|
2022-11-22 07:58:37 +01:00
|
|
|
|
|
|
|
|
import AccessibleButton from "../../../views/elements/AccessibleButton";
|
|
|
|
|
import { Icon as EMailPromptIcon } from "../../../../../res/img/element-icons/email-prompt.svg";
|
2023-03-08 11:11:01 +01:00
|
|
|
import { Icon as RetryIcon } from "../../../../../res/img/compound/retry-16px.svg";
|
2022-11-22 07:58:37 +01:00
|
|
|
import { _t } from "../../../../languageHandler";
|
|
|
|
|
import { useTimeoutToggle } from "../../../../hooks/useTimeoutToggle";
|
|
|
|
|
import { ErrorMessage } from "../../ErrorMessage";
|
|
|
|
|
|
|
|
|
|
interface CheckEmailProps {
|
|
|
|
|
email: string;
|
|
|
|
|
errorText: string | ReactNode | null;
|
2022-12-06 10:01:25 +01:00
|
|
|
onReEnterEmailClick: () => void;
|
2022-11-22 07:58:37 +01:00
|
|
|
onResendClick: () => Promise<boolean>;
|
|
|
|
|
onSubmitForm: (ev: React.FormEvent) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This component renders the email verification view of the forgot password flow.
|
|
|
|
|
*/
|
|
|
|
|
export const CheckEmail: React.FC<CheckEmailProps> = ({
|
|
|
|
|
email,
|
|
|
|
|
errorText,
|
2022-12-06 10:01:25 +01:00
|
|
|
onReEnterEmailClick,
|
2022-11-22 07:58:37 +01:00
|
|
|
onSubmitForm,
|
|
|
|
|
onResendClick,
|
|
|
|
|
}) => {
|
|
|
|
|
const { toggle: toggleTooltipVisible, value: tooltipVisible } = useTimeoutToggle(false, 2500);
|
|
|
|
|
|
|
|
|
|
const onResendClickFn = async (): Promise<void> => {
|
|
|
|
|
await onResendClick();
|
|
|
|
|
toggleTooltipVisible();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<EMailPromptIcon className="mx_AuthBody_emailPromptIcon--shifted" />
|
2023-09-21 18:16:04 +01:00
|
|
|
<h1>{_t("auth|uia|email_auth_header")}</h1>
|
2022-12-06 10:01:25 +01:00
|
|
|
<div className="mx_AuthBody_text">
|
2024-09-13 12:09:41 +01:00
|
|
|
<p>{_t("auth|check_email_explainer", { email: email }, { b: (t) => <strong>{t}</strong> })}</p>
|
2022-12-06 10:01:25 +01:00
|
|
|
<div className="mx_AuthBody_did-not-receive">
|
2023-09-19 07:17:31 +01:00
|
|
|
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_wrong_email_prompt")}</span>
|
2022-12-06 10:01:25 +01:00
|
|
|
<AccessibleButton className="mx_AuthBody_resend-button" kind="link" onClick={onReEnterEmailClick}>
|
2023-09-19 07:17:31 +01:00
|
|
|
{_t("auth|check_email_wrong_email_button")}
|
2022-12-06 10:01:25 +01:00
|
|
|
</AccessibleButton>
|
2022-12-12 12:24:14 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-12-06 10:01:25 +01:00
|
|
|
{errorText && <ErrorMessage message={errorText} />}
|
2023-08-22 20:55:15 +01:00
|
|
|
<input onClick={onSubmitForm} type="button" className="mx_Login_submit" value={_t("action|next")} />
|
2022-12-06 10:01:25 +01:00
|
|
|
<div className="mx_AuthBody_did-not-receive">
|
2023-09-19 07:17:31 +01:00
|
|
|
<span className="mx_VerifyEMailDialog_text-light">{_t("auth|check_email_resend_prompt")}</span>
|
2024-10-14 21:41:58 +05:30
|
|
|
<Tooltip description={_t("auth|check_email_resend_tooltip")} placement="top" open={tooltipVisible}>
|
2024-01-09 11:46:27 +00:00
|
|
|
<AccessibleButton className="mx_AuthBody_resend-button" kind="link" onClick={onResendClickFn}>
|
|
|
|
|
<RetryIcon className="mx_Icon mx_Icon_16" />
|
|
|
|
|
{_t("action|resend")}
|
|
|
|
|
</AccessibleButton>
|
|
|
|
|
</Tooltip>
|
2022-12-06 10:01:25 +01:00
|
|
|
</div>
|
2022-11-22 07:58:37 +01:00
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|