'use client';

/**
 * 단가 목록 페이지 (Client Component)
 *
 * 경로: /sales/pricing-management
 * API:
 *   - GET /api/v1/items - 품목 목록 (품목기준관리에서 등록한 전체 품목)
 *   - GET /api/v1/pricing - 단가 목록 (등록된 단가 정보)
 *
 * 데이터 흐름:
 *   품목 목록 + 단가 목록 → 병합 → 품목별 단가 현황 표시
 */

import { useEffect, useState } from 'react';
import { PricingListClient } from '@/components/pricing';
import { getPricingListData, type PricingListItem } from '@/components/pricing/actions';
import { GenericPageSkeleton } from '@/components/ui/skeleton';

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

  useEffect(() => {
    getPricingListData()
      .then(result => {
        setData(result);
      })
      .finally(() => setIsLoading(false));
  }, []);

  if (isLoading) return <GenericPageSkeleton />;

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