'use client';

/**
 * 차량 관리 리스트 페이지
 */

import { useEffect, useState } from 'react';
import { VehicleList } from '@/components/vehicle-management/VehicleList';
import { getVehicles } from '@/components/vehicle-management/VehicleList/actions';
import type { Vehicle } from '@/components/vehicle-management/types';
import { GenericPageSkeleton } from '@/components/ui/skeleton';

export default function VehiclePage() {
  const [data, setData] = useState<Vehicle[]>([]);
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    getVehicles()
      .then((result) => {
        if (result.success) {
          setData(result.data);
        }
      })
      .finally(() => setIsLoading(false));
  }, []);

  if (isLoading) return <GenericPageSkeleton />;

  return <VehicleList initialData={data} />;
}
