works, and looks good
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
IconButton,
|
||||||
TextField
|
TextField
|
||||||
} from "@material-ui/core";
|
} from "@material-ui/core";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
import AddCircleIcon from "@material-ui/icons/AddCircle";
|
||||||
|
import DeleteIcon from "@material-ui/icons/Delete";
|
||||||
import { Redirect } from "react-router";
|
import { Redirect } from "react-router";
|
||||||
import { logger } from "../../../services/monitoring";
|
import { logger } from "../../../services/monitoring";
|
||||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||||
@@ -31,9 +34,16 @@ const MainForm = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle(`Add Flashpack Version`);
|
setTitle(`Add Flashpack Version`);
|
||||||
setSitePath([
|
setSitePath([
|
||||||
|
{
|
||||||
|
label: "Tools",
|
||||||
|
link: "/tools/flashpacks",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Flashpack Versions",
|
||||||
|
link: "/tools/flashpacks",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: `Add Flashpack Version`,
|
label: `Add Flashpack Version`,
|
||||||
link: `/tools/flashpack/add`,
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -57,20 +67,21 @@ const MainForm = () => {
|
|||||||
|
|
||||||
const carFlashpackVersions = []
|
const carFlashpackVersions = []
|
||||||
for (let i = 0; i < mappingInputs.length; i++) {
|
for (let i = 0; i < mappingInputs.length; i++) {
|
||||||
carFlashpackVersions.push({
|
mappingInputs[i] && mappingInputs[i].ecuName && mappingInputs[i].ecuVersion &&
|
||||||
"car_model": carModel,
|
carFlashpackVersions.push({
|
||||||
"car_year": parseInt(carYear),
|
"car_model": carModel,
|
||||||
"flashpack": flashpack,
|
"car_year": parseInt(carYear),
|
||||||
"car_ecu_name": mappingInputs[i].ecuName,
|
"flashpack": flashpack,
|
||||||
"car_ecu_version": mappingInputs[i].ecuVersion,
|
"car_ecu_name": mappingInputs[i].ecuName,
|
||||||
})
|
"car_ecu_version": mappingInputs[i].ecuVersion,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await addFlashpackVersion(carModel, parseInt(carYear), flashpack, carFlashpackVersions, token);
|
const result = await addFlashpackVersion(carModel, parseInt(carYear), flashpack, carFlashpackVersions, token);
|
||||||
if (!result || result.error) return;
|
if (!result || result.error) return;
|
||||||
|
|
||||||
setMessage(`Added ${carYear} ${carModel} ${flashpack}`);
|
setMessage(`Added ${carYear} ${carModel} ${flashpack}`);
|
||||||
setRedirect(`/tools/flashpacks`);
|
setRedirect(`/tools/flashpack/${carModel}/${carYear}/${flashpack}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setMessage(e.message);
|
setMessage(e.message);
|
||||||
logger.warn(e.stack);
|
logger.warn(e.stack);
|
||||||
@@ -180,14 +191,27 @@ const MainForm = () => {
|
|||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
{mappingInputs.length > 1 && (
|
{mappingInputs.length > 1 && (
|
||||||
<button onClick={() => handleDeleteMappingInput(index)}>Delete</button>
|
<IconButton
|
||||||
|
onClick={() => handleDeleteMappingInput(index)}
|
||||||
|
aria-label={`Delete`}
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
<DeleteIcon aria-label={`Delete`} />
|
||||||
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
{index === mappingInputs.length - 1 && (
|
{index === mappingInputs.length - 1 && (
|
||||||
<button onClick={() => handleAddMappingInput()}>Add</button>
|
<IconButton
|
||||||
|
onClick={() => handleAddMappingInput()}
|
||||||
|
aria-label={`Add`}
|
||||||
|
size="small"
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
<AddCircleIcon aria-label={`Add`} />
|
||||||
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
<div className="body"> {JSON.stringify(mappingInputs)} </div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -49,11 +49,18 @@ const MainForm = () => {
|
|||||||
} = useUserContext();
|
} = useUserContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle(`Flashpack ${flashpack}`);
|
setTitle(`${year} ${model} Flashpack Version ${flashpack}`);
|
||||||
setSitePath([
|
setSitePath([
|
||||||
|
{
|
||||||
|
label: "Tools",
|
||||||
|
link: "/tools/flashpacks",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Flashpack Versions",
|
||||||
|
link: "/tools/flashpacks",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: `Flashpack ${flashpack}`,
|
label: `Flashpack ${flashpack}`,
|
||||||
link: `/flashpack/${model}/${year}/${flashpack}`,
|
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
@@ -62,12 +62,15 @@ const MainForm = () => {
|
|||||||
} = useUserContext();
|
} = useUserContext();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle("Flashpacks");
|
setTitle("Flashpack Versions");
|
||||||
setSitePath([
|
setSitePath([
|
||||||
{
|
{
|
||||||
label: "Flashpacks",
|
label: "Tools",
|
||||||
link: "/tools/flashpacks",
|
link: "/tools/flashpacks",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Flashpack Versions",
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user