import { getPersonOverview, getVehicleOverview } from '@/api/security-confidentiality-overview';
import type { PersonOverview, PieChartData, VehicleOverview, BarChartData } from './types';

export async function getPersonOverviewChartData() {
  const personOverview: PersonOverview = await getPersonOverview();
  return [
    { name: '非外籍访客', value: personOverview.nonForeignVisitorCount, id: 1, color: '#3777FD' },
    { name: '外籍访客', value: personOverview.foreignVisitorCount, id: 2, color: '#F1C7A3' },
  ] as PieChartData[];
}

export async function getVehicleOverviewChartData() {
  const vehicleOverview: VehicleOverview = await getVehicleOverview();
  return {
    category: vehicleOverview.vehicleEntryRecordList.map((item) => item.date),
    value: vehicleOverview.vehicleEntryRecordList.map((item) => item.vehicleCount),
  } as BarChartData;
}
