import { Dialog, DialogTitle, DialogContent, DialogActions, Button, TextField, } from "@mui/material"; import { useState, useEffect } from "react"; interface StatusChangeDialogProps { open: boolean; newStatus: string; reason: string; setReason: React.Dispatch>; handleClose: () => void; handleSave: () => void; } const StatusChangeDialog = ({ open, newStatus, reason, setReason, handleClose, handleSave, }: StatusChangeDialogProps) => { const [isValid, setIsValid] = useState(false); useEffect(() => { const noSpaces = reason.replace(/\s/g, ""); // remove all spaces const length = noSpaces.length; setIsValid(length >= 12 && length <= 400); }, [reason]); return ( Change Status You want to change the status to {newStatus}. Please provide a reason for the change. setReason(e.target.value)} helperText="Reason must be between 12 and 400 characters" sx={{ mt: 2 }} /> ); }; export default StatusChangeDialog;