import 'package:flutter/material.dart';

import 'package:pshared/models/payment/type.dart';

import 'package:pweb/pages/payment_methods/icon.dart';


class PaymentMethodPanelHeader extends StatelessWidget {
  final PaymentType selectedType;
  final String title;
  final String deleteLabel;
  final bool showDelete;
  final VoidCallback? onDelete;

  const PaymentMethodPanelHeader({
    super.key,
    required this.selectedType,
    required this.title,
    required this.deleteLabel,
    required this.showDelete,
    this.onDelete,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return Row(
      children: [
        Icon(
          iconForPaymentType(selectedType),
          size: 18,
          color: theme.colorScheme.primary,
        ),
        const SizedBox(width: 8),
        Expanded(
          child: Text(
            title,
            style: theme.textTheme.titleSmall?.copyWith(
              fontWeight: FontWeight.w600,
            ),
          ),
        ),
        if (showDelete && onDelete != null)
          TextButton.icon(
            onPressed: onDelete,
            icon: Icon(Icons.delete, color: theme.colorScheme.error),
            label: Text(
              deleteLabel,
              style: TextStyle(color: theme.colorScheme.error),
            ),
          ),
      ],
    );
  }
}
