namespace ComputerSalesApp.Data;

internal enum FieldKind
{
    Text,
    Integer,
    Decimal,
    Date,
    Boolean,
    Combo,
    Status,
    Role,
    Password
}

internal sealed class FieldDefinition
{
    public string ColumnName { get; init; } = string.Empty;
    public string Header { get; init; } = string.Empty;
    public FieldKind Kind { get; init; }
    public bool Required { get; init; }
    public bool Nullable { get; init; }
    public int MaxLength { get; init; } = 0;
    public decimal? MinValue { get; init; }
    public decimal? MaxValue { get; init; }
    public string? ReferenceSql { get; init; }
    public string? DisplayColumnName { get; init; }
    public string[]? Items { get; init; }

    public bool IsPassword => Kind == FieldKind.Password;
}

internal sealed class TableDefinition
{
    public string TableName { get; init; } = string.Empty;
    public string DisplayName { get; init; } = string.Empty;
    public string IdColumn { get; init; } = string.Empty;
    public string SelectSql { get; init; } = string.Empty;
    public string OrderBy { get; init; } = string.Empty;
    public bool AdminOnly { get; init; }
    public bool ReadOnly { get; init; }
    public bool IsUsersTable => TableName == "app_users";
    public List<FieldDefinition> Fields { get; init; } = new();
    public Dictionary<string, string> Headers { get; init; } = new();
    public HashSet<string> HiddenColumns { get; init; } = new();

    public override string ToString() => DisplayName;
}
