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

import '../../domain/governance_status.dart';

/// A chip that displays the [GovernanceStatus] of a policy check using the
/// design-system [KcStatusChip].
class GovernanceStatusChip extends StatelessWidget {
  final GovernanceStatus status;

  const GovernanceStatusChip({super.key, required this.status});

  @override
  Widget build(BuildContext context) {
    final (label, bg, fg) = _style(status);
    return KcStatusChip(label: label, background: bg, foreground: fg);
  }

  static (String, Color, Color) _style(GovernanceStatus status) {
    switch (status) {
      case GovernanceStatus.compliant:
        return ('Compliant', const Color(0xFFE8F5E9), KcColors.success);
      case GovernanceStatus.nonCompliant:
        return ('Non-compliant', const Color(0xFFFFEBEE), KcColors.danger);
      case GovernanceStatus.needsReview:
        return ('Needs review', const Color(0xFFFFF8E1), KcColors.warning);
      case GovernanceStatus.notApplicable:
        return ('N/A', const Color(0xFFECEFF1), KcColors.neutral);
    }
  }
}
