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

const { t } = useI18n();
const statisticsList = ref([
  {
    key: "enterpriseCount",
    label: computed(() => t("admin.statistics.enterpriseCount")),
    value: 0,
    unit: "家",
  },
  {
    key: "runDemandCount",
    label: computed(() => t("admin.statistics.serviceDemandCount")),
    value: 0,
    unit: "个",
  },
  {
    key: "orderTotal",
    label: computed(() => t("admin.statistics.orderCount")),
    value: 0,
    unit: "元",
  },
  {
    key: "demandCount",
    label: computed(() => t("admin.statistics.demandCount")),
    value: 0,
    unit: "个",
  },
]);

const loadStatistics = async () => {
  const { data } = await getBrokerStatistic();
  statisticsList.value.forEach((item) => {
    item.value = data[item.key] ?? 0;
  });
};
loadStatistics();
</script>

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

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