import {
  GET_SYSTEM_FLOOR_LIST_API,
  GET_SYSTEM_DEVICE_LIST_API,
  GET_SYSTEM_REALTIME_API,
} from "./api";
import instance from "@/util/request";
import apihandler from "@/util/apihandler";

export const getSystemFloors = async (building_tag, sub_system_tag) => {
  const res = await instance.post(GET_SYSTEM_FLOOR_LIST_API, {
    building_tag,
    sub_system_tag,
  });

  return apihandler(res.code, res.data, {
    msg: res.msg,
    code: res.code,
  });
};

export const getSystemDevices = async ({
  sub_system_tag,
  building_tag,
  floor_tag,
}) => {
  const res = await instance.post(GET_SYSTEM_DEVICE_LIST_API, {
    sub_system_tag,
    building_tag,
    floor_tag,
  });

  return apihandler(res.code, res.data, {
    msg: res.msg,
    code: res.code,
  });
};

export const getSystemRealTime = async (device_list) => {
  const res = await instance.post(GET_SYSTEM_REALTIME_API, { device_list });
  return apihandler(res.code, res.data, {
    msg: res.msg,
    code: res.code,
  });
};
