namespace TaxBaik.Application.Services;

using TaxBaik.Domain.Enums;

public static class InquiryStatusMapper
{
    // Status storage values (database)
    public const string StatusNew = "new";
    public const string StatusConsulting = "consulting";
    public const string StatusContracted = "contracted";
    public const string StatusRejected = "rejected";
    public const string StatusClosed = "closed";

    public static readonly Dictionary<string, string> Labels = new()
    {
        ["new"] = "신규",
        ["consulting"] = "상담중",
        ["contracted"] = "계약완료",
        ["rejected"] = "거절",
        ["closed"] = "종결",
    };

    public static string ToStorageValue(InquiryStatus status) => status switch
    {
        InquiryStatus.New => "new",
        InquiryStatus.Consulting => "consulting",
        InquiryStatus.Contracted => "contracted",
        InquiryStatus.Rejected => "rejected",
        InquiryStatus.Closed => "closed",
        _ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
    };

    public static bool TryParse(string? value, out InquiryStatus status)
    {
        var key = value?.Trim().ToLowerInvariant();
        status = key switch
        {
            "new" => InquiryStatus.New,
            "consulting" => InquiryStatus.Consulting,
            "contracted" => InquiryStatus.Contracted,
            "rejected" => InquiryStatus.Rejected,
            "closed" => InquiryStatus.Closed,
            _ => default
        };
        return key is "new" or "consulting" or "contracted" or "rejected" or "closed";
    }
}
