CEC-5752 - Define trim as well as model for Flashpack mappings

This commit is contained in:
padamsen_fisker
2024-02-13 18:11:00 -05:00
parent 00adee9b58
commit 27d7a5ad05
8 changed files with 118 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ const MainForm = () => {
const [redirect, setRedirect] = useState(null);
const { setMessage, setTitle, setSitePath } = useStatusContext();
const [carModel, setCarModel] = useState("");
const [carTrim, setCarTrim] = useState("");
const [carYear, setCarYear] = useState();
const [flashpack, setFlashpack] = useState();
const [mappingInputs, setMappingInputs] = useState([{ ecuName: "", ecuVersion: "" }]);
@@ -53,6 +54,10 @@ const MainForm = () => {
setCarModel(event.target.value);
}
const onCarTrimChange = (event) => {
setCarTrim(event.target.value);
}
const onCarYearChange = (event) => {
setCarYear(event.target.value);
}
@@ -74,11 +79,11 @@ const MainForm = () => {
})
}
const result = await addFlashpackVersion(carModel, parseInt(carYear), flashpack, carFlashpackVersions, token);
const result = await addFlashpackVersion(carModel, carTrim, parseInt(carYear), flashpack, carFlashpackVersions, token);
if (!result || result.error) return;
setMessage(`Added ${carYear} ${carModel} ${flashpack}`);
setRedirect(`/tools/flashpack/${carModel}/${carYear}/${flashpack}`);
setMessage(`Added ${carYear} ${carModel} ${carTrim} ${flashpack}`);
setRedirect(`/tools/flashpack/${carModel}/${carTrim}/${carYear}/${flashpack}`);
} catch (e) {
setMessage(e.message);
logger.warn(e.stack);
@@ -128,6 +133,21 @@ const MainForm = () => {
onChange={onCarModelChange}
type="text"
/>
<TextField
id="carTrim"
name="carTrim"
label="Trim"
variant="outlined"
margin="normal"
inputProps={{
maxLength: "255",
}}
required
fullWidth
value={carTrim}
onChange={onCarTrimChange}
type="text"
/>
<TextField
id="carYear"
name="carYear"