<script setup>
import StatisticsPanel from "@/views/components/StatisticsPanel.vue";
import { computed, ref } from "vue";
import { getResearchStatistic } from "@/api/admin/research/home";
import { useI18n } from "vue-i18n";

const { t } = useI18n();
const statisticsList = ref([
  {
    key: "patentCount",
    label: computed(() => t("admin.statistics.patentCount")),
    value: 0,
    unit: "项",
  },
  {
    key: "achievementCount",
    label: computed(() => t("admin.statistics.achievementCount")),
    value: 0,
    unit: "个",
  },
  {
    key: "expertCount",
    label: computed(() => t("admin.statistics.expertCount")),
    value: 0,
    unit: "位",
  },
  {
    key: "laboratoryCount",
    label: computed(() => t("admin.statistics.laboratoryCount")),
    value: 0,
    unit: "家",
  },
]);

const loadResearchStatisticsData = () => {
  getResearchStatistic().then((resp) => {
    const { data } = resp;
    statisticsList.value.forEach((item) => {
      item.value = data[item.key] ?? 0;
    });
  });
};

loadResearchStatisticsData();
</script>

<template>
  <div class="app-container">
    <statistics-panel :list="statisticsList" />
  </div>
</template>

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