CEC-758 Add SMS send page and result (#173)
* Add SMS send and result pages * Update snapshot Co-authored-by: jwu-fisker <jwu@fiskerinc.com>
This commit is contained in:
92
src/components/SMS/Send/SendForm.jsx
Normal file
92
src/components/SMS/Send/SendForm.jsx
Normal file
@@ -0,0 +1,92 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
FormControlLabel,
|
||||
Checkbox,
|
||||
TextField,
|
||||
} from "@material-ui/core";
|
||||
|
||||
import useStyles from "../../useStyles";
|
||||
import { SMS } from "../../Contexts/SMSContext";
|
||||
|
||||
const SendForm = ({ onSend, busy }) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const iccidEl = useRef(null);
|
||||
|
||||
const [message, setMessage] = useState(null);
|
||||
const [isAwaited, setAwait] = useState(false);
|
||||
|
||||
const onSubmit = async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (onSend) onSend(new SMS(message, iccidEl.current.value, isAwaited));
|
||||
};
|
||||
|
||||
const onMessageChange = (event) => {
|
||||
setMessage(event.target.value);
|
||||
};
|
||||
|
||||
const onAwaitChange = (event) => {
|
||||
setAwait(event.target.checked);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classes.paper}>
|
||||
<form className={classes.form} noValidate action="{onSubmit}">
|
||||
<TextField
|
||||
id="iccid"
|
||||
name="iccid"
|
||||
label="ICCID"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "50",
|
||||
minLength: "15",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
inputRef={iccidEl}
|
||||
/>
|
||||
<TextField
|
||||
id="message"
|
||||
name="message"
|
||||
label="Message"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "320",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
onChange={onMessageChange}
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={isAwaited}
|
||||
onChange={onAwaitChange}
|
||||
value="isAwaited"
|
||||
color="primary"
|
||||
/>
|
||||
}
|
||||
label="Await delivery"
|
||||
/>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={busy}
|
||||
fullWidth
|
||||
variant="contained"
|
||||
color="primary"
|
||||
className={classes.submit}
|
||||
onClick={onSubmit}
|
||||
>
|
||||
{busy ? "Sending..." : "Send"}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SendForm;
|
||||
Reference in New Issue
Block a user