Files
element-call/src/room/RageshakeRequestModal.tsx
T

66 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-05-04 17:09:48 +01:00
/*
Copyright 2022-2024 New Vector Ltd.
2022-05-04 17:09:48 +01:00
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
2022-05-04 17:09:48 +01:00
*/
import { FC, useEffect } from "react";
2022-10-10 09:19:10 -04:00
import { useTranslation } from "react-i18next";
import { Button } from "@vector-im/compound-web";
2022-08-02 00:46:16 +02:00
2023-09-22 18:05:13 -04:00
import { Modal, Props as ModalProps } from "../Modal";
2022-02-04 16:55:57 -08:00
import { FieldRow, ErrorMessage } from "../input/Input";
2022-04-07 14:22:36 -07:00
import { useSubmitRageshake } from "../settings/submit-rageshake";
2022-02-04 16:55:57 -08:00
import { Body } from "../typography/Typography";
2022-08-05 16:16:59 -04:00
interface Props extends Omit<ModalProps, "title" | "children"> {
2022-08-02 00:46:16 +02:00
rageshakeRequestId: string;
2023-07-04 18:46:27 +01:00
roomId: string;
2023-09-17 14:35:35 -04:00
open: boolean;
onDismiss: () => void;
2022-08-05 16:16:59 -04:00
}
export const RageshakeRequestModal: FC<Props> = ({
2022-07-27 16:14:05 -04:00
rageshakeRequestId,
2023-07-04 18:46:27 +01:00
roomId,
2023-09-17 14:35:35 -04:00
open,
onDismiss,
2022-08-05 16:16:59 -04:00
}) => {
2022-10-10 09:19:10 -04:00
const { t } = useTranslation();
2022-02-04 16:55:57 -08:00
const { submitRageshake, sending, sent, error } = useSubmitRageshake();
useEffect(() => {
2023-09-17 14:35:35 -04:00
if (sent) onDismiss();
}, [sent, onDismiss]);
2022-02-04 16:55:57 -08:00
return (
2023-11-20 13:38:01 +00:00
<Modal
title={t("rageshake_request_modal.title")}
open={open}
onDismiss={onDismiss}
>
2023-11-20 13:00:43 +00:00
<Body>{t("rageshake_request_modal.body")}</Body>
2023-09-17 14:35:35 -04:00
<FieldRow>
<Button
onClick={(): void =>
2023-09-22 18:05:13 -04:00
void submitRageshake({
2023-09-17 14:35:35 -04:00
sendLogs: true,
rageshakeRequestId,
roomId,
})
}
disabled={sending}
>
2023-11-20 13:00:43 +00:00
{sending ? t("rageshake_sending_logs") : t("rageshake_send_logs")}
2023-09-17 14:35:35 -04:00
</Button>
</FieldRow>
{error && (
2022-02-04 16:55:57 -08:00
<FieldRow>
2023-09-17 14:35:35 -04:00
<ErrorMessage error={error} />
2022-02-04 16:55:57 -08:00
</FieldRow>
2023-09-17 14:35:35 -04:00
)}
2022-02-04 16:55:57 -08:00
</Modal>
);
2022-08-05 16:16:59 -04:00
};