<script setup>
import StatisticsPanel from "@/views/components/StatisticsPanel.vue";
import { computed, ref } from "vue";
import { getLaboratoryStatistic } from "@/api/admin/laboratory/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: "demandCount",
    label: computed(() => t("admin.statistics.demandCount")),
    value: 0,
    unit: "个",
  },
  {
    key: "paperCount",
    label: computed(() => t("admin.statistics.paperCount")),
    value: 0,
    unit: "篇",
  },
]);

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

loadLabStatisticsData();
</script>

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

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