const Layout = (props: any) => {
//Row First
const [rows, setRow] = useState({
rowFirst: "",
columnFirst: "",
columnSecond: 0
});
const handleChangeRowFirst = (e: { target: { name: any; value: any; }; }) => {
setRow({ ...rows, [e.target.name]: e.target.value });
console.log("row", rows);
props.dispatch({
type: "setRow",
payload: rows
});
};
const onSubmitForm = (e: any) => {
e.preventDefault();
if (!rows.rowFirst) {
alert("rowFirst is empty.")
}
else if (!rows.columnFirst) {
alert("columnFirst or rowFirst is empty.")
}
else if (!rows.columnSecond) {
alert("columnSecond is empty.")
}
}
return (
<>
<Grid container className="containerMatrix">
<form onSubmit={onSubmitForm} className="formMatrix">
<Grid item xs={6} md={5}>
<Box id="test" className="martixNum">
<Typography variant="h5" gutterBottom className="nameColMatrix">
Enter Numbers First Matrix
</Typography>
<Box className="martixFirst">
<TextField
type="number"
InputProps={{
inputProps: {
max: 99, min: 0
}
}}
label="Row" onChange={handleChangeRowFirst} name="rowFirst" id="num1" value={rows.rowFirst}
/>
<TextField
type="number"
InputProps={{
inputProps: {
max: 99, min: 0
}
}}
label="Column" onChange={handleChangeRowFirst} name="columnFirst" id="num2" value={rows.columnFirst}
/>
</Box>
</Box>
</Grid>
<Grid item xs={6} md={5}>
<Box id="test" className="martixNum">
<Typography variant="h5" gutterBottom className="nameColMatrix">
Enter Numbers Second Matrix
</Typography>
<Box className="martixFirst">
<TextField
type="number"
InputProps={{
inputProps: {
max: 99, min: 0
}
}}
label="Row" onChange={handleChangeRowFirst} name="columnFirst" id="num3" value={rows.columnFirst}
/>
<TextField
type="number"
InputProps={{
inputProps: {
max: 99, min: 0
}
}}
label="Column" onChange={handleChangeRowFirst} name="columnSecond" id="num4"
/>
</Box>
</Box>
</Grid>
<Grid item xs={6} md={5}>
<Box>
<Button variant="contained" color="primary" type="submit">
Primary
</Button>
</Box>
</Grid>
</form>
</Grid>
</>
)
}