import 'package:flutter/material.dart';
import 'package:design_system/design_system.dart';
import 'package:krow_domain/krow_domain.dart';
import 'package:flutter_modular/flutter_modular.dart';
import '../../navigation/shifts_navigator.dart';
import '../my_shift_card.dart';
import '../shared/empty_state_view.dart';

class HistoryShiftsTab extends StatelessWidget {
  final List<Shift> historyShifts;

  const HistoryShiftsTab({
    super.key,
    required this.historyShifts,
  });

  @override
  Widget build(BuildContext context) {
    if (historyShifts.isEmpty) {
      return EmptyStateView(
        icon: UiIcons.clock,
        title: "No shift history",
        subtitle: "Completed shifts appear here",
      );
    }

    return SingleChildScrollView(
      padding: const EdgeInsets.symmetric(horizontal: 20),
      child: Column(
        children: [
          const SizedBox(height: 20),
          ...historyShifts.map(
            (shift) => Padding(
              padding: const EdgeInsets.only(bottom: 12),
              child: GestureDetector(
                onTap: () => Modular.to.pushShiftDetails(shift),
                child: MyShiftCard(
                  shift: shift,
                ),
              ),
            ),
          ),
          const SizedBox(height: 40),
        ],
      ),
    );
  }
}
