Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,84 @@
|
||||
import { forwardRef, Fragment, Ref, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { Dialog, DialogBackdrop, DialogPanel, Transition, TransitionChild } from "@headlessui/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import clsx from "~/utils/shared/ClassesUtils";
|
||||
import { AlertTriangleIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
export interface RefErrorModal {
|
||||
show: (title?: string, description?: string) => void;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
onClosed?: () => void;
|
||||
}
|
||||
|
||||
const ErrorModal = ({ className, onClosed }: Props, ref: Ref<RefErrorModal>) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const [title, setTitle] = useState<string>();
|
||||
const [description, setDescription] = useState<string>();
|
||||
const [closeText, setCloseText] = useState<string>();
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t("shared.error").toString());
|
||||
setCloseText(t("shared.close"));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
function show(_title?: string, _description?: string) {
|
||||
if (_title) {
|
||||
setTitle(_title);
|
||||
}
|
||||
if (_description) {
|
||||
setDescription(_description);
|
||||
} else if (_title) {
|
||||
setTitle(t("shared.error").toString());
|
||||
setDescription(_title);
|
||||
}
|
||||
setOpen(true);
|
||||
}
|
||||
|
||||
useImperativeHandle(ref, () => ({ show }));
|
||||
|
||||
function close() {
|
||||
setOpen(false);
|
||||
if (onClosed) {
|
||||
onClosed();
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={setOpen} className="fixed inset-0 z-50 overflow-y-auto transition duration-300 ease-out data-[closed]:opacity-0" transition>
|
||||
<div className="flex min-h-screen items-end justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
|
||||
<DialogBackdrop className="fixed inset-0 bg-gray-500/75 transition-opacity" />
|
||||
|
||||
<div className="fixed inset-0 flex w-screen items-center justify-center p-4">
|
||||
{/* Subframe ResultDialog layout: flex-col items-center gap-6, rounded-lg, px-6 py-8, icon badge h-14 w-14 rounded-round, content gap-2, full-width button. */}
|
||||
<DialogPanel className="bg-surface-neutral-modal flex w-full max-w-full transform flex-col items-center gap-6 overflow-hidden rounded-lg px-6 py-8 text-left align-bottom shadow-xl transition-all sm:my-8 sm:w-96 sm:align-middle">
|
||||
<div className="flex h-14 w-14 flex-none items-center justify-center rounded-round bg-red-100">
|
||||
<AlertTriangleIcon className="h-6 w-6 text-red-600" />
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-center gap-2 text-center">
|
||||
<h3 className="text-text-neutral-primary text-lg leading-6 font-medium">{title}</h3>
|
||||
<p className="text-text-neutral-tertiary text-sm">{description}</p>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<button
|
||||
type="button"
|
||||
className="bg-brand-brand-surface-solid-default text-text-neutral-on-solid hover:bg-brand-brand-surface-solid-hover mt-0 inline-flex w-full justify-center rounded-md border border-transparent px-4 py-2 text-sm font-medium shadow-2xs focus:shadow-focus focus:outline-hidden"
|
||||
onClick={close}
|
||||
>
|
||||
{closeText}
|
||||
</button>
|
||||
</div>
|
||||
</DialogPanel>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(ErrorModal);
|
||||
Reference in new issue
Block a user