import { useEffect, useState } from "react"; import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, } from "@mui/material"; import Notice from "../base/base-notice"; interface Props { open: boolean; onClose: () => void; onSubmit: (name: string, desc: string) => void; } const ProfileNew = (props: Props) => { const { open, onClose, onSubmit } = props; const [name, setName] = useState(""); const [desc, setDesc] = useState(""); const onCreate = () => { if (!name.trim()) { Notice.error("`Name` should not be null"); return; } onSubmit(name, desc); }; useEffect(() => { if (!open) { setName(""); setDesc(""); } }, [open]); return ( Create Profile setName(e.target.value)} /> setDesc(e.target.value)} /> ); }; export default ProfileNew;