Fixes from review
This commit is contained in:
@@ -292,13 +292,13 @@ export const VehicleProvider = ({ children }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAllFlashpacks = async (options, token) => {
|
const getAllFlashpacks = async (options, token) => {
|
||||||
let result;
|
|
||||||
try {
|
try {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
|
||||||
result = await api.getAllFlashpacks(options, token);
|
const result = await api.getAllFlashpacks(options, token);
|
||||||
if (result.error)
|
if (result.error) {
|
||||||
throw new Error(`Get all flashpacks error. ${result.message}`);
|
throw new Error(`Get all flashpacks error. ${result.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
setFlashpacks(result.data);
|
setFlashpacks(result.data);
|
||||||
if (options && options.offset === 0 && result.total) {
|
if (options && options.offset === 0 && result.total) {
|
||||||
@@ -312,13 +312,13 @@ export const VehicleProvider = ({ children }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getFlashpackECUMappings = async (model, year, flashpack, options, token) => {
|
const getFlashpackECUMappings = async (model, year, flashpack, options, token) => {
|
||||||
let result;
|
|
||||||
try {
|
try {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
|
||||||
result = await api.getFlashpackECUMappings(model, year, flashpack, options, token);
|
const result = await api.getFlashpackECUMappings(model, year, flashpack, options, token);
|
||||||
if (result.error)
|
if (result.error) {
|
||||||
throw new Error(`Get flashpack ecu mappings error. ${result.message}`);
|
throw new Error(`Get flashpack ecu mappings error. ${result.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
setFlashpackECUMappings(result.data);
|
setFlashpackECUMappings(result.data);
|
||||||
if (options && options.offset === 0 && result.total) {
|
if (options && options.offset === 0 && result.total) {
|
||||||
@@ -343,8 +343,9 @@ export const VehicleProvider = ({ children }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await api.addFlashpackVersion(data, token)
|
const result = await api.addFlashpackVersion(data, token)
|
||||||
if (result.error)
|
if (result.error) {
|
||||||
throw new Error(`Add flashpack version error. ${result.message}`);
|
throw new Error(`Add flashpack version error. ${result.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -353,7 +354,6 @@ export const VehicleProvider = ({ children }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteFlashpackVersion = async (model, year, flashpack, token) => {
|
const deleteFlashpackVersion = async (model, year, flashpack, token) => {
|
||||||
let result;
|
|
||||||
try {
|
try {
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
|
|
||||||
@@ -363,9 +363,10 @@ export const VehicleProvider = ({ children }) => {
|
|||||||
"flashpack": flashpack,
|
"flashpack": flashpack,
|
||||||
}
|
}
|
||||||
|
|
||||||
result = await api.deleteFlashpackVersion(data, token);
|
const result = await api.deleteFlashpackVersion(data, token);
|
||||||
if (result.error)
|
if (result.error) {
|
||||||
throw new Error(`Delete flashpack ecu mappings error. ${result.message}`);
|
throw new Error(`Delete flashpack ecu mappings error. ${result.message}`);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -187,6 +187,44 @@ export const useVehicleContext = () => ({
|
|||||||
total: 2,
|
total: 2,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
getAllFlashpacks: jest.fn((options, token) => {
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
flashpack: "44.4",
|
||||||
|
car_model: "Ocean",
|
||||||
|
car_year: "2023",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
flashpack: "38.4",
|
||||||
|
car_model: "Ocean",
|
||||||
|
car_year: "2023",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
total: 2,
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
getFlashpackECUMappings: jest.fn((model, year, flashpack, options, token) => {
|
||||||
|
return {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
flashpack: "44.4",
|
||||||
|
car_model: "Ocean",
|
||||||
|
car_year: "2023",
|
||||||
|
car_ecu_name: "ADAS",
|
||||||
|
car_ecu_version: "99",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
flashpack: "44.4",
|
||||||
|
car_model: "Ocean",
|
||||||
|
car_year: "2023",
|
||||||
|
car_ecu_name: "PDI",
|
||||||
|
car_ecu_version: "11",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
total: 2,
|
||||||
|
}
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const setBusy = (val) => {
|
export const setBusy = (val) => {
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ const MainForm = () => {
|
|||||||
) : (
|
) : (
|
||||||
<TablePagination
|
<TablePagination
|
||||||
rowsPerPageOptions={[5, 10, 25, 100]}
|
rowsPerPageOptions={[5, 10, 25, 100]}
|
||||||
colSpan={1}
|
colSpan={2}
|
||||||
count={totalFlashpackECUMappings}
|
count={totalFlashpackECUMappings}
|
||||||
rowsPerPage={pageSize}
|
rowsPerPage={pageSize}
|
||||||
page={pageIndex}
|
page={pageIndex}
|
||||||
|
|||||||
@@ -122,6 +122,29 @@ exports[`Flashpack Render 1`] = `
|
|||||||
</svg>
|
</svg>
|
||||||
</span>
|
</span>
|
||||||
</th>
|
</th>
|
||||||
|
<th
|
||||||
|
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
|
||||||
|
scope="col"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-disabled="false"
|
||||||
|
class="MuiButtonBase-root MuiTableSortLabel-root"
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
|
||||||
|
focusable="false"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody
|
<tbody
|
||||||
|
|||||||
@@ -36,6 +36,10 @@ const tableColumns = [
|
|||||||
id: "car_year",
|
id: "car_year",
|
||||||
label: "Year",
|
label: "Year",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "delete",
|
||||||
|
label: "Delete",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const PAGE_SIZE = "FLASHPACKS_TABLE_PAGE_SIZE";
|
const PAGE_SIZE = "FLASHPACKS_TABLE_PAGE_SIZE";
|
||||||
@@ -144,7 +148,7 @@ const MainForm = () => {
|
|||||||
/>
|
/>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{flashpacks && flashpacks.map((row, index) => (
|
{flashpacks && flashpacks.map((row, index) => (
|
||||||
<TableRow key={index}>
|
<TableRow key={row.flashpack + row.car_model}>
|
||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
<Link to={`/tools/flashpack/${row.car_model}/${row.car_year}/${row.flashpack}`}>
|
<Link to={`/tools/flashpack/${row.car_model}/${row.car_year}/${row.flashpack}`}>
|
||||||
{row.flashpack}
|
{row.flashpack}
|
||||||
@@ -156,7 +160,7 @@ const MainForm = () => {
|
|||||||
<TableCell align="center">
|
<TableCell align="center">
|
||||||
{row.car_year}
|
{row.car_year}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell align="center">
|
||||||
<RoleWrap
|
<RoleWrap
|
||||||
groups={groups}
|
groups={groups}
|
||||||
providers={providers}
|
providers={providers}
|
||||||
@@ -182,7 +186,7 @@ const MainForm = () => {
|
|||||||
) : (
|
) : (
|
||||||
<TablePagination
|
<TablePagination
|
||||||
rowsPerPageOptions={[5, 10, 25, 100]}
|
rowsPerPageOptions={[5, 10, 25, 100]}
|
||||||
colSpan={1}
|
colSpan={4}
|
||||||
count={totalFlashpacks}
|
count={totalFlashpacks}
|
||||||
rowsPerPage={pageSize}
|
rowsPerPage={pageSize}
|
||||||
page={pageIndex}
|
page={pageIndex}
|
||||||
|
|||||||
Reference in New Issue
Block a user