Switch to tRPC (#173)

This commit is contained in:
Luke Vella 2022-05-18 10:22:40 +01:00 committed by GitHub
parent 3d7e7e8a95
commit 2c4157ea24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
245 changed files with 1585 additions and 1755 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)];
};