diff --git a/src/components/Contexts/VehicleContext.jsx b/src/components/Contexts/VehicleContext.jsx
index 713aba5..96dc6df 100644
--- a/src/components/Contexts/VehicleContext.jsx
+++ b/src/components/Contexts/VehicleContext.jsx
@@ -311,11 +311,11 @@ export const VehicleProvider = ({ children }) => {
}
};
- const getFlashpackECUMappings = async (model, year, flashpack, options, token) => {
+ const getFlashpackECUMappings = async (model, trim, year, flashpack, options, token) => {
try {
setBusy(true);
- const result = await api.getFlashpackECUMappings(model, year, flashpack, options, token);
+ const result = await api.getFlashpackECUMappings(model, trim, year, flashpack, options, token);
if (result.error) {
throw new Error(`Get flashpack ecu mappings error. ${result.message}`);
}
@@ -331,12 +331,13 @@ export const VehicleProvider = ({ children }) => {
}
};
- const addFlashpackVersion = async (model, year, flashpack, carFlashpackVersions, token) => {
+ const addFlashpackVersion = async (model, trim, year, flashpack, carFlashpackVersions, token) => {
try {
setBusy(true);
const data = {
"car_model": model,
+ "car_trim": trim,
"car_year": year,
"flashpack": flashpack,
"ecu_versions": carFlashpackVersions,
@@ -353,12 +354,13 @@ export const VehicleProvider = ({ children }) => {
}
}
- const deleteFlashpackVersion = async (model, year, flashpack, token) => {
+ const deleteFlashpackVersion = async (model, trim, year, flashpack, token) => {
try {
setBusy(true);
const data = {
"car_model": model,
+ "car_trim": trim,
"car_year": year,
"flashpack": flashpack,
}
diff --git a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap
index bcb5f26..cf1f846 100644
--- a/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap
+++ b/src/components/Flashpack/Add/__snapshots__/index.test.jsx.snap
@@ -69,6 +69,52 @@ exports[`FlashpackAdd Render 1`] = `
+
+
+
+
+
+
+
diff --git a/src/components/Flashpack/Add/index.jsx b/src/components/Flashpack/Add/index.jsx
index 73e5a43..9b54882 100644
--- a/src/components/Flashpack/Add/index.jsx
+++ b/src/components/Flashpack/Add/index.jsx
@@ -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"
/>
+
{
- const { model, year, flashpack } = useParams();
+ const { model, trim, year, flashpack } = useParams();
const classes = useStyles();
const { setMessage, setTitle, setSitePath } = useStatusContext();
const [pageSize, setPageSize] = useLocalStorage(PAGE_SIZE, 10);
@@ -49,7 +49,7 @@ const MainForm = () => {
} = useUserContext();
useEffect(() => {
- setTitle(`${year} ${model} Flashpack Version ${flashpack}`);
+ setTitle(`${year} ${model} ${trim} Flashpack Version ${flashpack}`);
setSitePath([
{
label: "Tools",
@@ -76,6 +76,7 @@ const MainForm = () => {
if (!token) return;
await getFlashpackECUMappings(
model,
+ trim,
year,
flashpack,
{
diff --git a/src/components/Flashpack/__snapshots__/index.test.jsx.snap b/src/components/Flashpack/__snapshots__/index.test.jsx.snap
index 02b2c42..50e5114 100644
--- a/src/components/Flashpack/__snapshots__/index.test.jsx.snap
+++ b/src/components/Flashpack/__snapshots__/index.test.jsx.snap
@@ -99,6 +99,29 @@ exports[`Flashpack Render 1`] = `
+
+
+ Trim
+
+
+ |
{
const sendDelete = async () => {
if (rowToDelete) {
try {
- const result = await deleteFlashpackVersion(rowToDelete.car_model, rowToDelete.car_year, rowToDelete.flashpack, token);
+ const result = await deleteFlashpackVersion(rowToDelete.car_model, rowToDelete.car_trim, rowToDelete.car_year, rowToDelete.flashpack, token);
if (!result || result.error) return;
- setMessage(`Deleted ${rowToDelete.car_year} ${rowToDelete.car_model} ${rowToDelete.flashpack}`);
+ setMessage(`Deleted ${rowToDelete.car_year} ${rowToDelete.car_model} ${rowToDelete.car_trim} ${rowToDelete.flashpack}`);
loadFlashpacks();
} catch (e) {
setMessage(e.message);
@@ -150,13 +154,16 @@ const MainForm = () => {
{flashpacks && flashpacks.map((row, index) => (
-
+
{row.flashpack}
{row.car_model}
+
+ {row.car_trim}
+
{row.car_year}
@@ -168,11 +175,11 @@ const MainForm = () => {
>
onDeleteClick(row)}
- aria-label={`Send delete for ${row.car_year} ${row.car_model} ${row.flashpack}`}
+ aria-label={`Send delete for ${row.car_year} ${row.car_model} ${row.car_trim} ${row.flashpack}`}
size="small"
color="primary"
>
-
+
@@ -186,7 +193,7 @@ const MainForm = () => {
) : (
{
setShowDeleteModal(false)}
deleteFunction={sendDelete}
diff --git a/src/components/Routes/SiteRoutes.jsx b/src/components/Routes/SiteRoutes.jsx
index 52f9eae..ada8471 100644
--- a/src/components/Routes/SiteRoutes.jsx
+++ b/src/components/Routes/SiteRoutes.jsx
@@ -289,7 +289,7 @@ const SiteRoutes = () => {
providers={providers}
/>
}
type={TYPES.PROTECTED}
token={token}
diff --git a/src/services/vehiclesAPI.js b/src/services/vehiclesAPI.js
index cc485bc..4a86259 100644
--- a/src/services/vehiclesAPI.js
+++ b/src/services/vehiclesAPI.js
@@ -272,8 +272,8 @@ const vehiclesAPI = {
.catch(errorHandler)
},
- getFlashpackECUMappings: async (model, year, flashpack, options, token) => {
- return fetch(addQueryParams(`${API_ENDPOINT}/flashpack_version_ecu_mappings/${model}/${year}/${flashpack}`, options), {
+ getFlashpackECUMappings: async (model, trim, year, flashpack, options, token) => {
+ return fetch(addQueryParams(`${API_ENDPOINT}/flashpack_version_ecu_mappings/${model}/${trim}/${year}/${flashpack}`, options), {
method: "GET",
headers: Object.assign(
{ "Content-Type": "application/json" },
|