import 'package:core_localization/core_localization.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'coverage_dashboard.dart';

/// A widget that displays live activity information.
class LiveActivityWidget extends StatelessWidget {
  /// Callback when "View all" is pressed.
  final VoidCallback onViewAllPressed;

  /// Creates a [LiveActivityWidget].
  const LiveActivityWidget({super.key, required this.onViewAllPressed});

  @override
  Widget build(BuildContext context) {
    final TranslationsClientHomeEn i18n = t.client_home;

    // Mock data
    final List<Map<String, Object>> shifts = <Map<String, Object>>[
      <String, Object>{
        'workersNeeded': 5,
        'filled': 4,
        'hourlyRate': 20.0,
        'status': 'OPEN',
        'date': DateTime.now().toIso8601String().split('T')[0],
      },
      <String, Object>{
        'workersNeeded': 5,
        'filled': 5,
        'hourlyRate': 22.0,
        'status': 'FILLED',
        'date': DateTime.now().toIso8601String().split('T')[0],
      },
    ];
    final List<Map<String, String>> applications = <Map<String, String>>[
      <String, String>{'status': 'CONFIRMED', 'checkInTime': '09:00'},
      <String, String>{'status': 'CONFIRMED', 'checkInTime': '09:05'},
      <String, String>{'status': 'CONFIRMED'},
      <String, String>{'status': 'LATE'},
    ];

    return Column(
      children: <Widget>[
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Text(
              i18n.widgets.live_activity.toUpperCase(),
              style: UiTypography.footnote1b.textSecondary.copyWith(
                letterSpacing: 0.5,
              ),
            ),
            GestureDetector(
              onTap: onViewAllPressed,
              child: Text(
                i18n.dashboard.view_all,
                style: UiTypography.footnote1m.copyWith(
                  color: UiColors.primary,
                ),
              ),
            ),
          ],
        ),
        const SizedBox(height: UiConstants.space2),
        CoverageDashboard(shifts: shifts, applications: applications),
      ],
    );
  }
}
