2022-11-22 07:58:37 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
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 { _t } from "../../../../languageHandler";
|
|
|
|
|
import AccessibleButton from "../../../views/elements/AccessibleButton";
|
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 { Icon as EmailPromptIcon } from "../../../../../res/img/element-icons/email-prompt.svg";
|
|
|
|
|
import { useTimeoutToggle } from "../../../../hooks/useTimeoutToggle";
|
|
|
|
|
import { ErrorMessage } from "../../ErrorMessage";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
email: string;
|
2023-02-28 10:31:48 +00:00
|
|
|
errorText: ReactNode | null;
|
|
|
|
|
onFinished(): void; // This modal is weird in that the way you close it signals intent
|
2022-12-06 10:01:25 +01:00
|
|
|
onCloseClick: () => void;
|
|
|
|
|
onReEnterEmailClick: () => void;
|
2022-11-22 07:58:37 +01:00
|
|
|
onResendClick: () => Promise<boolean>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const VerifyEmailModal: React.FC<Props> = ({
|
|
|
|
|
email,
|
|
|
|
|
errorText,
|
2022-12-06 10:01:25 +01:00
|
|
|
onCloseClick,
|
|
|
|
|
onReEnterEmailClick,
|
2022-11-22 07:58:37 +01:00
|
|
|
onResendClick,
|
|
|
|
|
}) => {
|
|
|
|
|
const { toggle: toggleTooltipVisible, value: tooltipVisible } = useTimeoutToggle(false, 2500);
|
|
|
|
|
|
|
|
|
|
const onResendClickFn = async (): Promise<void> => {
|
|
|
|
|
await onResendClick();
|
|
|
|
|
toggleTooltipVisible();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<EmailPromptIcon className="mx_AuthBody_emailPromptIcon" />
|
2023-09-19 07:17:31 +01:00
|
|
|
<h1>{_t("auth|verify_email_heading")}</h1>
|
2022-11-22 07:58:37 +01:00
|
|
|
<p>
|
|
|
|
|
{_t(
|
2023-09-19 07:17:31 +01:00
|
|
|
"auth|verify_email_explainer",
|
2022-11-22 07:58:37 +01:00
|
|
|
{
|
|
|
|
|
email,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
b: (sub) => <b>{sub}</b>,
|
|
|
|
|
},
|
|
|
|
|
)}
|
|
|
|
|
</p>
|
2022-12-12 12:24:14 +01:00
|
|
|
|
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-04-12 14:56:23 +02:00
|
|
|
<Tooltip label={_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-11-22 07:58:37 +01:00
|
|
|
{errorText && <ErrorMessage message={errorText} />}
|
2022-12-12 12:24:14 +01:00
|
|
|
</div>
|
|
|
|
|
|
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-11-22 07:58:37 +01:00
|
|
|
</AccessibleButton>
|
2022-12-12 12:24:14 +01:00
|
|
|
</div>
|
2022-12-06 10:01:25 +01:00
|
|
|
|
2022-11-22 07:58:37 +01:00
|
|
|
<AccessibleButton
|
|
|
|
|
onClick={onCloseClick}
|
2022-12-06 10:01:25 +01:00
|
|
|
className="mx_Dialog_cancelButton"
|
2023-10-03 19:17:26 +01:00
|
|
|
aria-label={_t("dialog_close_label")}
|
2022-12-06 10:01:25 +01:00
|
|
|
/>
|
|
|
|
|
</>
|
2022-11-22 07:58:37 +01:00
|
|
|
);
|
|
|
|
|
};
|