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,92 @@
|
||||
import { forwardRef, Fragment, Ref, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { Dialog, DialogBackdrop, DialogPanel, DialogTitle, Transition, TransitionChild } from "@headlessui/react";
|
||||
import clsx from "clsx";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CheckCircleIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
export interface RefSuccessModal {
|
||||
show: (title?: string, description?: string) => void;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
onClosed?: () => void;
|
||||
}
|
||||
|
||||
const SuccessModal = ({ className, onClosed }: Props, ref: Ref<RefSuccessModal>) => {
|
||||
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.success").toString());
|
||||
setCloseText(t("shared.close"));
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
function close() {
|
||||
setOpen(false);
|
||||
if (onClosed) {
|
||||
onClosed();
|
||||
}
|
||||
}
|
||||
|
||||
useImperativeHandle(ref, () => ({ show }));
|
||||
|
||||
function show(_title?: string, _description?: string) {
|
||||
if (_title) {
|
||||
setTitle(_title);
|
||||
}
|
||||
if (_description) {
|
||||
setDescription(_description);
|
||||
}
|
||||
setOpen(true);
|
||||
}
|
||||
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">
|
||||
{/* <TransitionChild
|
||||
as={Fragment}
|
||||
enter="ease-out duration-300"
|
||||
enterFrom="opacity-0"
|
||||
enterTo="opacity-100"
|
||||
leave="ease-in duration-200"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
</TransitionChild> */}
|
||||
<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-green-100">
|
||||
<CheckCircleIcon className="h-6 w-6 text-green-600" />
|
||||
</div>
|
||||
<div className="flex w-full flex-col items-center gap-2 text-center">
|
||||
<DialogTitle as="h3" className="text-text-neutral-primary text-lg leading-6 font-medium">
|
||||
{title}
|
||||
</DialogTitle>
|
||||
<p className="text-text-neutral-tertiary text-sm">{description}</p>
|
||||
</div>
|
||||
<div className="w-full">
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-full justify-center rounded-md border border-transparent bg-teal-600 px-4 py-2 text-base font-medium text-white shadow-2xs hover:bg-teal-700 focus:ring-2 focus:ring-teal-500 focus:ring-offset-2 focus:outline-hidden sm:text-sm"
|
||||
onClick={close}
|
||||
>
|
||||
{closeText}
|
||||
</button>
|
||||
</div>
|
||||
</DialogPanel>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(SuccessModal);
|
||||
Reference in new issue
Block a user