import { getActiveAlarmTotal } from '@/api/faultManage/actAlarm';
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
import { defineStore } from 'pinia';

/**告警数据信息类型 */
type Alarm = {
  /**活动告警数据值 */
  activeAlarmTotal: number;
};

const useAlarmStore = defineStore('alarm', {
  state: (): Alarm => ({
    activeAlarmTotal: 0,
  }),
  getters: {},
  actions: {
    // 获取活动告警数
    async fnGetActiveAlarmInfo() {
      const res = await getActiveAlarmTotal();
      if (res.code === RESULT_CODE_SUCCESS) {
        this.activeAlarmTotal = res.data;
      }
      return res;
    },
  },
});

export default useAlarmStore;
