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

import '../../domain/publish_status.dart';

/// A chip that displays the [PublishStatus] of a product draft using the
/// design-system [KcStatusChip].
class PublishStatusChip extends StatelessWidget {
  final PublishStatus status;

  const PublishStatusChip({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(PublishStatus status) {
    switch (status) {
      case PublishStatus.draft:
        return ('Draft', const Color(0xFFECEFF1), KcColors.neutral);
      case PublishStatus.pendingReview:
        return ('Pending Review', const Color(0xFFFFF8E1), KcColors.warning);
      case PublishStatus.published:
        return ('Published', const Color(0xFFE8F5E9), KcColors.success);
      case PublishStatus.unpublished:
        return ('Unpublished', const Color(0xFFFFEBEE), KcColors.danger);
    }
  }
}
