<script setup>
import AlertSubList from "./AlertSubList.vue";
import AlertOutliersTable from "./AlertOutliersTable.vue";
import AlertTimeTable from "./AlertTimeTable.vue";
import AlertNotifyTable from "./AlertNotifyTable.vue";
import { ref, provide, onMounted } from "vue";
import { getAlarmScheduleList, getNoticeList } from "@/apis/alert";
const timesList = ref([]);
const noticeList = ref([]);

const timesListData = async () => {
  const res = await getAlarmScheduleList();
  timesList.value = res.data.map((items) => ({
    ...items,
    key: items.id,
    schedule_array: JSON.parse(items.schedule_json).map((time, index) => ({
      day: index + 1,
      time,
    })),
  }));
};

const NoticeListData = async () => {
  const res = await getNoticeList();
  noticeList.value = res.data;
};

onMounted(() => {
  timesListData();
  NoticeListData();
});

provide("notify_table", { timesList, noticeList, timesListData });
</script>

<template>
  <AlertSubList />
  <AlertOutliersTable />
  <!-- <AlertTimeTable /> -->
  <AlertNotifyTable />
</template>

<style lang="scss" scoped></style>
