diff --git a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx
index 07e6318..71ce44d 100644
--- a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx
+++ b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx
@@ -6,8 +6,6 @@ import vehiclesAPI from "../../../services/vehiclesAPI";
export default forwardRef(({
ids,
idCSV,
- fleet,
- selectAll,
}, ref) => {
const { setMessage } = useStatusContext();
const { token: { idToken: { jwtToken: token } } } = useUserContext();
@@ -15,12 +13,10 @@ export default forwardRef(({
useImperativeHandle(ref, () => ({
async submit() {
return vehiclesAPI
- .flashpackVersionBulkUpdate(selectAll, fleet, ids, token)
+ .flashpackVersionBulkUpdate(ids, token)
.then((data) => {
if (data.error) {
setMessage(`${data.error}: ${data.message}`);
- } else if (selectAll) {
- setMessage(`Updating flashpack numbers for all VINs in fleet: ${fleet}`);
} else if (ids.length === 1) {
setMessage(`Updating flashpack number for ${ids[0]}`);
} else {
@@ -30,21 +26,11 @@ export default forwardRef(({
},
}));
- if (selectAll) {
- return (
-
-
- You are updating flashpack numbers for all VINs in the following fleet: {fleet}.
-
-
- )
- } else {
- return (
- < div >
-
- You are updating flashpack numbers for the following VINs: {idCSV}.
-
-
- )
- }
+ return (
+ < div >
+
+ You are updating flashpack numbers for the following VINs: {idCSV}.
+
+
+ )
});
diff --git a/src/components/BulkActions/index.jsx b/src/components/BulkActions/index.jsx
index 9c5e0e2..2715c12 100644
--- a/src/components/BulkActions/index.jsx
+++ b/src/components/BulkActions/index.jsx
@@ -20,8 +20,6 @@ const UpdateFlashpackNumbers = lazy(() => import("./actions/UpdateFlashpackNumbe
export default function BulkActions({
ids = [],
actions = [],
- fleet = undefined,
- selectAll = false,
callback = (active, ids, context) => { }, // context is raised from the action itself
}) {
const [open, setOpen] = useState(false);
@@ -92,8 +90,6 @@ export default function BulkActions({
const payload = {
ids,
idCSV: (ids && ids.length > 0) ? truncateCSV(ids, 10) : "N/A",
- fleet,
- selectAll,
ref: activeRef
};
@@ -114,7 +110,7 @@ export default function BulkActions({
setEmbedded(action?.embedded);
}, [active, filteredActions]);
- if (!selectAll && (!ids || ids.length === 0)) return <>>;
+ if (!ids || ids.length === 0) return <>>;
return (
<>
diff --git a/src/components/Contexts/FleetContext.jsx b/src/components/Contexts/FleetContext.jsx
index a231bc6..da03bf0 100644
--- a/src/components/Contexts/FleetContext.jsx
+++ b/src/components/Contexts/FleetContext.jsx
@@ -163,6 +163,23 @@ export const FleetProvider = ({ children }) => {
}
};
+ const getFleetVINs = async (name, token) => {
+ try {
+ setBusy(true);
+
+ const result = await api.getFleetVehicles(name, null, token);
+ if (result.error) {
+ throw new Error(`Get fleet vehicles error. ${result.message}`);
+ }
+
+ const vins = result.data?.map(vehicle => vehicle.vin);
+
+ return vins;
+ } finally {
+ setBusy(false);
+ }
+ };
+
const watchFleetVehicles = new Polling(async ({ token }) => {
if (carUpdateIdsRef.current.length === 0) {
return;
@@ -396,6 +413,7 @@ export const FleetProvider = ({ children }) => {
totalFleetVehicles,
watchFleetVehicles,
getFleetVehicles,
+ getFleetVINs,
addFleetVehicles,
deleteFleetVehicles,
removeFleetVehiclesLocal,
diff --git a/src/components/Controls/DropDownButton/index.jsx b/src/components/Controls/DropDownButton/index.jsx
index e5c572d..49ef692 100644
--- a/src/components/Controls/DropDownButton/index.jsx
+++ b/src/components/Controls/DropDownButton/index.jsx
@@ -18,7 +18,7 @@ const DropDownButton = ({ actions = [], payload = [], onClick = () => { } }) =>
const handleClick = () => {
onClick()
- actions[selectedIndex].trigger(...payload);
+ actions[selectedIndex] ? actions[selectedIndex].trigger(...payload) : actions[0].trigger(...payload)
};
const handleMenuItemClick = (event, index) => {
@@ -55,9 +55,9 @@ const DropDownButton = ({ actions = [], payload = [], onClick = () => { } }) =>
>