import { requestClient } from '#/api/request';

export namespace configAlarmApi {
  export interface Alarm {
    id: number;
    org_id: string;
    type: string;
    key: string;
    value: string;
    created_at: string;
    updated_at: string;
  }
  export interface CreateAlarm {
    org_id: string;
    list: [{ key: string; value: string }];
    type: string;
  }
  export interface UpdateAlarm {
    // id: number;
    // org_id: string;
    config: { key: string; value: string };
    // type: string;
  }
}

export const getAlarmConfigList = (org_id: string, type: string) => {
  return requestClient.get<configAlarmApi.Alarm[]>(
    '/device-management/devices/config',
    {
      params: {
        org_id,
        type,
      },
    },
  );
};

export const createAlarmConfig = (data: configAlarmApi.CreateAlarm) => {
  return requestClient.post('/device-management/devices/config', data);
};

export const updateAlarmConfig = (
  id: number,
  data: configAlarmApi.UpdateAlarm,
) => {
  return requestClient.put(`/device-management/devices/config/${id}`, data);
};

export const deleteAlarmConfig = async (id: number) => {
  return requestClient.delete(`/device-management/devices/config/${id}`);
};
