CEC-2601 Fix cancel update handler (#211)

This commit is contained in:
John Wu
2022-09-29 11:58:51 -07:00
committed by GitHub
parent f3d0b523d8
commit d2a467d22b

View File

@@ -36,6 +36,21 @@ export const CarUpdatesProvider = ({ children }) => {
const [delayCount, setDelayCount] = useState(0);
let progressTimer = 0;
const cancelUpdate = async (id, token) => {
let result;
try {
setBusy(true);
result = await api.cancelCarUpdate(id, token);
if (result.error)
throw new Error(`Cancel car update error. ${result.message}`);
} finally {
setBusy(false);
}
return result;
};
const deployCarUpdates = async (data, token) => {
let result;
@@ -228,6 +243,7 @@ export const CarUpdatesProvider = ({ children }) => {
busy,
carUpdates,
totalCarUpdates,
cancelUpdate,
deployCarUpdates,
deployFleetUpdates,
getCarUpdates,