CEC-4525: add support for /tags endpoint and implement a new action for it (#361)

* add action for adding tags
This commit is contained in:
Tristan Timblin
2023-06-16 11:48:48 -07:00
committed by GitHub
parent 9ae3ef0e2e
commit 7c358a6052
10 changed files with 308 additions and 10 deletions

View File

@@ -61,6 +61,22 @@ export const VehicleProvider = ({ children }) => {
}
};
const addTags = async (vins, tags, token) => {
try {
setBusy(true);
vins.forEach(vin => validateVIN(vin));
const validateTags = tags.every(tag => typeof tag === "string");
if (!validateTags)
throw new Error("Invalid Tag");
const result = await api.addTags(vins, tags, token)
if (result.error)
throw new Error(`Add tags error. ${result.message}`);
} finally {
setBusy(false)
}
}
const getConnections = async (vins, token) => {
try {
setBusy(true);
@@ -301,6 +317,7 @@ export const VehicleProvider = ({ children }) => {
getFleets,
getVersionLog,
uploadConfig,
addTags,
}}
>
{children}