using Core.Models;
using Core.Notes;
using Microsoft.Extensions.Configuration;
namespace WebApp.Models;
///
/// Configuration for chapter-specific information
///
public class ChapterSettings
{
///
/// Full chapter name (e.g., "Your Chapter Name")
///
public string Name { get; set; } = "Your Chapter Name";
///
/// Short chapter name abbreviation (e.g., "YCN")
///
public string ShortName { get; set; } = "YCN";
///
/// National chapter ID (4 digits, e.g., "0000")
///
public string NationalId { get; set; } = "0000";
///
/// State chapter ID (5 digits, e.g., "00000")
///
public string StateId { get; set; } = "00000";
///
/// Regional chapter ID (5 digits, e.g., "00000")
///
public string RegionalId { get; set; } = "00000";
///
/// Competition year (e.g., "2026")
///
public string CompetitionYear { get; set; } = "2026";
///
/// National TSA yearly theme (e.g., "Unity Through Community")
///
public string YearlyTheme { get; set; } = "Unity Through Community";
///
/// Postal state abbreviation for printed schedules (example placeholder: "ST").
///
public string StateAbbrev { get; set; } = "ST";
///
/// School level for the chapter (null = import both MS and HS events)
///
public SchoolLevel? SchoolLevel { get; set; }
///
/// Field names from student note ## Imported fields tables to show as Students index columns.
///
public List StudentIndexNoteFields { get; set; } = [.. StudentNoteFieldDefaults.IndexColumns];
public static ChapterSettings FromConfiguration(IConfiguration configuration)
{
var settings = configuration.GetSection("ChapterSettings").Get()
?? new ChapterSettings();
settings.StudentIndexNoteFields = ReadIndexNoteFields(configuration);
return settings;
}
public static List ReadIndexNoteFields(IConfiguration configuration)
{
var fields = configuration.GetSection("ChapterSettings:StudentIndexNoteFields").Get>();
if (fields is null)
return [.. StudentNoteFieldDefaults.IndexColumns];
return [.. fields.Where(f => !string.IsNullOrWhiteSpace(f)).Select(f => f.Trim())];
}
}