import { ref, onMounted } from 'vue';
import {
  ScoreType,
  getDailyScore,
  getWeeklyScore,
  getMonthlyScore,
  getQuarterlyScore,
} from '@/api/home/home-score.ts';

export function useScoreInfo() {
  const scoreInfoList = ref<ScoreType[]>([]);

  const getDailyScoreList = () => {
    getDailyScore().then((res) => {
      scoreInfoList.value = res;
    });
  };

  const getWeeklyScoreList = () => {
    getWeeklyScore().then((res) => {
      scoreInfoList.value = res;
    });
  };

  const getMonthlyScoreList = () => {
    getMonthlyScore().then((res) => {
      scoreInfoList.value = res;
    });
  };

  const getQuarterlyScoreList = () => {
    getQuarterlyScore().then((res) => {
      scoreInfoList.value = res;
    });
  };

  onMounted(() => {
    getDailyScoreList();
  });
  return {
    scoreInfoList,
    getDailyScoreList,
    getWeeklyScoreList,
    getMonthlyScoreList,
    getQuarterlyScoreList,
  };
}

export default useScoreInfo;
