'use client';

/**
 * 차량일지/월간사진기록 리스트 페이지
 */

import { useEffect, useState } from 'react';
import { VehicleLogList } from '@/components/vehicle-management/VehicleLogList';
import { getVehicleLogs } from '@/components/vehicle-management/VehicleLogList/actions';
import type { VehicleLog } from '@/components/vehicle-management/types';
import { GenericPageSkeleton } from '@/components/ui/skeleton';

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

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

  if (isLoading) return <GenericPageSkeleton />;

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