import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, } from "@mui/material"; import { ReactNode, useState } from "react"; type Props = { message?: string; onClose?: VoidFunction; onAgree?: VoidFunction; onDisagree?: VoidFunction; }; export type UseDialogReturn = { show: boolean; open: VoidFunction; close: VoidFunction; setShow: (show: boolean) => void; element: ReactNode; }; export function useDialog({ message, onClose, onAgree, onDisagree, }: Props = {}): UseDialogReturn { const [show, setShow] = useState(false); const open = () => { setShow(true); }; const close = () => { if (onClose) { onClose(); } setShow(false); }; const agree = () => { if (onAgree) { onAgree(); } setShow(false); }; const disagree = () => { if (onDisagree) { onDisagree(); } setShow(false); }; const element = ( 確認 {message && ( {message} )} ); return { // param show, // Element element, // function open, close, setShow, }; }