import 'package:flutter/material.dart';
import 'package:niogu_app/features/stock_in/domain/entities/stock_in.dart';
import 'package:niogu_app/features/stock_in/presentation/widgets/item_input_card.dart';
import 'package:sizer/sizer.dart';

class BodyForm extends StatelessWidget {
  final List<SelectedItem> selectedItems;
  final String label;
  final void Function(SelectedItem) onDecrementTap;
  final void Function(SelectedItem) onIncrementTap;
  final void Function(SelectedItem) onEditPressed;
  final void Function(SelectedItem) onDeletePressed;

  const BodyForm({
    super.key,
    required this.selectedItems,
    required this.label,
    required this.onDecrementTap,
    required this.onIncrementTap,
    required this.onEditPressed,
    required this.onDeletePressed,
  });

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      shrinkWrap: true,
      physics: const NeverScrollableScrollPhysics(),
      itemCount: selectedItems.length,
      separatorBuilder: (c, i) => SizedBox(height: 2.h),
      itemBuilder: (context, index) {
        final item = selectedItems[index];
        return ItemInputCard(
          item: item,
          label: label,
          onDecrementTap: () => item.quantity > 1 ? onDecrementTap(item) : null,
          onIncrementTap: () => onIncrementTap(item),
          onEditPressed: () => onEditPressed(item),
          onDeletePressed: () => onDeletePressed(item),
        );
      },
    );
  }
}
