import 'package:flutter/material.dart';

enum ProviderRole {
  landline('Fisso', Colors.blue),
  mobile('Mobile', Colors.green),
  energy('Energia', Colors.orange),
  insurance('Assicurazioni', Colors.purple),
  financing('Finanziamenti', Colors.teal),
  entertainment('Intrattenimento', Colors.red),
  telepass('Telepass', Colors.amber),
  repairCenter('Centro Riparazioni', Colors.cyan),
  partsSupplier('Fornitore Ricambi', Colors.indigo),
  merchandiseSupplier('Fornitore Merce', Colors.brown);

  final String displayValue;
  final Color color; // <-- Il nostro tocco magico

  const ProviderRole(this.displayValue, this.color);

  static ProviderRole? fromString(String? value) {
    if (value == null) return null;
    try {
      return ProviderRole.values.firstWhere((e) => e.name == value);
    } catch (_) {
      return null;
    }
  }
}
