import { onMounted, ref } from 'vue';
import { CountType, RecordType, getCount, getUserRecord } from '@/api/home/home-panel';

export function usePanelInfo() {
  const panelData = ref<CountType>();
  const clickData = ref<RecordType>();

  const getPanelCount = () => {
    getCount().then((res) => {
      panelData.value = res;
    });
  };

  const getPanelUserRecord = () => {
    getUserRecord().then((res) => {
      clickData.value = res;
    });
  };

  // onMounted(() => {
  //   getPanelCount();
  //   getPanelUserRecord();
  // });

  return {
    panelData,
    clickData,
    getPanelCount,
    getPanelUserRecord,
  };
}

export default usePanelInfo;
