'use client';

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

import { useEffect, useState } from 'react';
import { ForkliftList } from '@/components/vehicle-management/ForkliftList';
import { getForklifts } from '@/components/vehicle-management/ForkliftList/actions';
import type { Forklift } from '@/components/vehicle-management/types';
import { GenericPageSkeleton } from '@/components/ui/skeleton';

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

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

  if (isLoading) return <GenericPageSkeleton />;

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