import 'package:flutter/material.dart';
import 'package:niogu_app/features/online_store/presentation/widgets/status_filter_item.dart';
import 'package:sizer/sizer.dart';

class OrderOnlineHeader extends StatelessWidget {
  final List<String> statuses;
  final String selectedStatus;
  final Map<String, int> orderCounts;
  final void Function(String) onTap;
  const OrderOnlineHeader({
    super.key,
    required this.statuses,
    required this.selectedStatus,
    required this.orderCounts,
    required this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 7.h,
      decoration: const BoxDecoration(
        color: Colors.white,
        boxShadow: [BoxShadow(color: Colors.white, spreadRadius: 2)],
      ),
      child: ListView.builder(
        scrollDirection: Axis.horizontal,
        padding: EdgeInsets.symmetric(horizontal: 4.w),
        itemCount: statuses.length,
        itemBuilder: (context, index) {
          final status = statuses[index];

          final bool isSelected = selectedStatus == status;

          final int count = orderCounts[status] ?? 0;

          return StatusFilterItem(
            label: status,
            isSelected: isSelected,
            count: count,
            onTap: () => onTap(status),
          );
        },
      ),
    );
  }
}
