import { type FC } from 'react' import Button from '@/components/Button' import { Edit2, ShoppingCart, TickSquare, Trash } from 'iconsax-react' import { useGetProducts } from '../hooks/useRequestData' import type { RequestItemType } from '../type/Types' import { clx } from '@/helpers/utils' type Props = { items: RequestItemType[] editingIndex: number | null onEdit: (index: number) => void onRemove: (index: number) => void onSubmit: () => void isPending: boolean } const RequestItemsList: FC = ({ items, editingIndex, onEdit, onRemove, onSubmit, isPending, }) => { const { data: productsData } = useGetProducts() const getProductTitle = (productId?: string) => productsData?.data?.find((p) => p.id === productId)?.title ?? 'محصول' return (
{/* Header */}
اقلام درخواست {items.length > 0 && ( {items.length} قلم )}
{/* Items */}
{items.length === 0 ? (

هنوز قلمی اضافه نشده. فرم را پر کنید و روی «افزودن به لیست» بزنید.

) : (
    {items.map((item, index) => (
  • {getProductTitle(item.productId)} #{index + 1}
  • ))}
)}
{/* Submit footer */}
{items.length === 0 && (

حداقل یک قلم برای ثبت لازم است

)}
) } export default RequestItemsList