diff --git a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx index 120a507..675c02e 100644 --- a/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx +++ b/src/components/BulkActions/actions/UpdateFlashpackNumbers.jsx @@ -6,6 +6,8 @@ import vehiclesAPI from "../../../services/vehiclesAPI"; export default forwardRef(({ ids, idCSV, + fleet, + selectAll, }, ref) => { const { setMessage } = useStatusContext(); const { token: { idToken: { jwtToken: token } } } = useUserContext(); @@ -13,10 +15,12 @@ export default forwardRef(({ useImperativeHandle(ref, () => ({ async submit() { return vehiclesAPI - .flashpackVersionBulkUpdate(ids, token) + .flashpackVersionBulkUpdate(selectAll, fleet, ids, token) .then((data) => { if (data.error) { setMessage(`${data.error}: ${data.message}`); + } else if (selectAll) { + setMessage(`Updating flashpack number all VINs in ${fleet}`); } else if (ids.length === 1) { setMessage(`Updating flashpack number for ${ids[0]}`); } else { @@ -26,11 +30,21 @@ export default forwardRef(({ }, })); - return ( -
-

- You are updating flashpack numbers for the following VINs: {idCSV}. -

-
- ); -}); \ No newline at end of file + 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}. +

+ + ) + } +}); diff --git a/src/components/BulkActions/index.jsx b/src/components/BulkActions/index.jsx index 1f1d62b..9c5e0e2 100644 --- a/src/components/BulkActions/index.jsx +++ b/src/components/BulkActions/index.jsx @@ -21,6 +21,7 @@ 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,6 +93,7 @@ export default function BulkActions({ ids, idCSV: (ids && ids.length > 0) ? truncateCSV(ids, 10) : "N/A", fleet, + selectAll, ref: activeRef }; @@ -112,7 +114,7 @@ export default function BulkActions({ setEmbedded(action?.embedded); }, [active, filteredActions]); - if (!ids || ids.length === 0) return <>; + if (!selectAll && (!ids || ids.length === 0)) return <>; return ( <> diff --git a/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap b/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap index f828335..3dbb472 100644 --- a/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap +++ b/src/components/Fleets/Status/Vehicles/Table/__snapshots__/index.test.jsx.snap @@ -38,12 +38,53 @@ exports[`FleetVehiclesTable Render 1`] = ` +
+ +
{ const [order, setOrder] = useState("desc"); const [search, setSearch] = useState(""); const [selected, setSelected] = useState([]); + const [selectAllSelected, setSelectAllSelected] = useState(false); const componentMounted = useRef(true); const classes = useStyles(); const { setMessage } = useStatusContext(); @@ -174,15 +176,28 @@ const MainForm = ({ name }) => { + + setSelectAllSelected(selectAllSelected => !selectAllSelected)} + /> + } label="Select All Vehicles" /> + - + diff --git a/src/components/Fleets/Status/__snapshots__/VehiclesTab.test.jsx.snap b/src/components/Fleets/Status/__snapshots__/VehiclesTab.test.jsx.snap index 70ce3b3..aae862c 100644 --- a/src/components/Fleets/Status/__snapshots__/VehiclesTab.test.jsx.snap +++ b/src/components/Fleets/Status/__snapshots__/VehiclesTab.test.jsx.snap @@ -37,12 +37,53 @@ exports[`VehiclesTab Render 1`] = `
+
+ +
{ - return fetch(`${API_ENDPOINT}/flashpack_version_bulk_update`, { + flashpackVersionBulkUpdate: async (selectAll, fleet, vins, token) => { + var url = `${API_ENDPOINT}/flashpack_version_bulk_update` + const queryParams = { + fleet, + }; + if (selectAll) { + url = addQueryParams(url, queryParams); + } + + return fetch(url, { method: "PUT", headers: Object.assign( { "Content-Type": "application/json" },