First public commit

This commit is contained in:
Luke Vella 2022-04-12 07:14:28 +01:00
commit e05cd62e53
228 changed files with 17717 additions and 0 deletions

View file

@ -0,0 +1,27 @@
import React from "react";
import Modal, { ModalProps } from "./modal";
type OpenModalFn = () => void;
type CloseModalFn = () => void;
export const useModal = (
props?: ModalProps,
): [React.ReactElement<ModalProps>, OpenModalFn, CloseModalFn] => {
const [visible, setVisible] = React.useState(false);
const modal = (
<Modal
{...props}
visible={visible}
onOk={() => {
props?.onOk?.();
setVisible(false);
}}
onCancel={() => {
props?.onCancel?.();
setVisible(false);
}}
/>
);
return [modal, () => setVisible(true), () => setVisible(false)];
};