excalidraw/src/components/ErrorDialog.tsx
David Luzar b997e69ebc
improvement: Tweak error message on image import (#2619)
* improvement: tweak error message on image import

* tweak copy
2020-12-20 16:11:44 +01:00

44 lines
812 B
TypeScript

import React, { useState } from "react";
import { t } from "../i18n";
import { Dialog } from "./Dialog";
export const ErrorDialog = ({
message,
onClose,
}: {
message: string;
onClose?: () => void;
}) => {
const [modalIsShown, setModalIsShown] = useState(!!message);
const handleClose = React.useCallback(() => {
setModalIsShown(false);
if (onClose) {
onClose();
}
}, [onClose]);
return (
<>
{modalIsShown && (
<Dialog
maxWidth={500}
onCloseRequest={handleClose}
title={t("errorDialog.title")}
>
<div>
{message.split("\n").map((line) => (
<>
{line}
<br />
</>
))}
</div>
</Dialog>
)}
</>
);
};