fixed tag apis to use new context logic

This commit is contained in:
Carter 2025-05-28 10:32:19 -06:00
parent dd2d24c357
commit 6a6334da6a
4 changed files with 17 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import { useGlobalState } from "providers";
import moment from "moment";
import { or } from "utils/types";
import { dateRange } from "providers/http";
import { getContextKeys, getContextTypes } from "pbHelpers/Context";
export interface IDeviceAPIContext {
add: (name: string, description: string, backpack: pond.BackpackSettings, otherTeam?: string) => Promise<AxiosResponse<pond.AddDeviceResponse>>;
@ -725,8 +726,12 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
};
const tag = (id: number, tag: string) => {
const keys = getContextKeys()
const types = getContextTypes()
let url = "/devices/" + id + "/tags/" + tag + "?keys=" + keys + "&types=" + types
if (as && !keys.includes(as)) url += "&as=" + as
return new Promise<AxiosResponse>((resolve, reject) => {
put(pondURL("/devices/" + id + "/tags/" + tag), {}).then(resp => {
put(pondURL(url), {}).then(resp => {
return resolve(resp)
}).catch(err => {
return reject(err)