// composables/useDeviceRanking.ts
import { ref } from 'vue'
import { request } from '/@/utils/service';

export function useDeviceRanking() {
  const borrowCountData = ref([])
  const borrowDurationData = ref([])

  const fetchRanking = async (tag?: string) => {
    const res = await request({
		url: '/api/system/dashboard/device_rankings/',
		method: 'get',
	});

    if (res.code === 2000) {
      borrowCountData.value = res.data.borrow_count_ranking
      borrowDurationData.value = res.data.borrow_duration_ranking
    }
  }

  return {
    borrowCountData,
    borrowDurationData,
    fetchRanking
  }
}
