using SeaHaven.DataServices.Interfaces; namespace SeaHaven.Services.Helpers; public static class DashboardRegions { public static readonly IReadOnlyList Names = ["East", "Central", "West", "California", "Unmapped/Other"]; public static string Resolve(string? state) { var code = UsStateCodes.ToCode(state); if (code is null) return "Unmapped/Other"; return StateToRegion.TryGetValue(code, out var region) ? region : "Unmapped/Other"; } public static IReadOnlyDictionary Count( IReadOnlyList workOrders) { var counts = Names.ToDictionary(name => name, _ => 0, StringComparer.Ordinal); foreach (var workOrder in workOrders) counts[Resolve(workOrder.LocationState)]++; return counts; } private static readonly IReadOnlyDictionary StateToRegion = new Dictionary(StringComparer.Ordinal) { ["CT"] = "East", ["DE"] = "East", ["GA"] = "East", ["ME"] = "East", ["MD"] = "East", ["MA"] = "East", ["NH"] = "East", ["NJ"] = "East", ["NY"] = "East", ["NC"] = "East", ["PA"] = "East", ["RI"] = "East", ["SC"] = "East", ["VT"] = "East", ["VA"] = "East", ["WV"] = "East", ["AL"] = "Central", ["AR"] = "Central", ["FL"] = "Central", ["IL"] = "Central", ["IN"] = "Central", ["IA"] = "Central", ["KS"] = "Central", ["KY"] = "Central", ["LA"] = "Central", ["MI"] = "Central", ["MN"] = "Central", ["MS"] = "Central", ["MO"] = "Central", ["NE"] = "Central", ["ND"] = "Central", ["OH"] = "Central", ["OK"] = "Central", ["SD"] = "Central", ["TN"] = "Central", ["WI"] = "Central", ["AK"] = "West", ["AZ"] = "West", ["CO"] = "West", ["HI"] = "West", ["ID"] = "West", ["MT"] = "West", ["NV"] = "West", ["NM"] = "West", ["OR"] = "West", ["TX"] = "West", ["UT"] = "West", ["WA"] = "West", ["WY"] = "West", ["CA"] = "California" }; }