CEC-2281 Update certificate form (#190)

This commit is contained in:
John Wu
2022-08-23 08:51:05 -07:00
committed by GitHub
parent 59a8c934d6
commit f0b2a4f217
3 changed files with 75 additions and 13 deletions

View File

@@ -11,9 +11,14 @@ import {
import useStyles from "../../useStyles";
import { CertTypes } from "../../Contexts/CertificateContext";
const getCertTypeLabel = (certtype) => {
if (certtype === CertTypes.Aftersales) return "Service Tool ID";
return "VIN";
};
const CreateForm = ({ onCreate, busy }) => {
const classes = useStyles();
const vinEl = useRef(null);
const commonnameEl = useRef(null);
const [certType, setCertType] = useState(CertTypes.TBOX);
const onSubmit = async (event) => {
@@ -21,7 +26,7 @@ const CreateForm = ({ onCreate, busy }) => {
if (onCreate)
onCreate({
vin: vinEl.current.value,
common_name: commonnameEl.current.value,
type: certType,
});
};
@@ -34,9 +39,9 @@ const CreateForm = ({ onCreate, busy }) => {
<div className={classes.paper}>
<form className={classes.form} noValidate action="{onSubmit}">
<TextField
id="vin"
name="vin"
label="VIN"
id="common_name"
name="common_name"
label={`Common Name (${getCertTypeLabel(certType)})`}
variant="outlined"
margin="normal"
inputProps={{
@@ -44,7 +49,7 @@ const CreateForm = ({ onCreate, busy }) => {
}}
required
fullWidth
inputRef={vinEl}
inputRef={commonnameEl}
/>
<FormLabel id="cert-type-group-label">Type</FormLabel>
<RadioGroup
@@ -70,6 +75,11 @@ const CreateForm = ({ onCreate, busy }) => {
control={<Radio />}
label="Charging"
/>
<FormControlLabel
value={CertTypes.Aftersales}
control={<Radio />}
label="Aftersales"
/>
</RadioGroup>
<Button
type="submit"