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:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user