0c9459e9e5
* add error dialog * show error modal on file dnd * add locales * Update src/locales/en.json Co-Authored-By: Lipis <lipiridis@gmail.com> * Update src/data/blob.ts * Update src/data/blob.ts * fix titles, update snapshots * make modal smaller * fix dnd wrong file type * reset errorMessage Co-authored-by: Faustino Kialungila <faustino.kialungila@gmail.com> Co-authored-by: Lipis <lipiridis@gmail.com>
37 lines
660 B
TypeScript
37 lines
660 B
TypeScript
import React, { useState } from "react";
|
|
import { t } from "../i18n";
|
|
|
|
import { Dialog } from "./Dialog";
|
|
|
|
export function 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}</div>
|
|
</Dialog>
|
|
)}
|
|
</>
|
|
);
|
|
}
|