using System.ComponentModel.DataAnnotations;

namespace SilverLabs.Website.Models;

public class DeveloperApplication
{
    [Required(ErrorMessage = "Full name is required")]
    [StringLength(100, MinimumLength = 2)]
    public string FullName { get; set; } = string.Empty;

    [Required(ErrorMessage = "Email is required")]
    [EmailAddress(ErrorMessage = "Invalid email address")]
    public string Email { get; set; } = string.Empty;

    [Required(ErrorMessage = "Username is required")]
    [RegularExpression(@"^[a-zA-Z0-9_-]{3,30}$", ErrorMessage = "Username must be 3-30 characters, letters, numbers, hyphens and underscores only")]
    public string DesiredUsername { get; set; } = string.Empty;

    [Required(ErrorMessage = "Timezone is required")]
    public string Timezone { get; set; } = string.Empty;

    [Required(ErrorMessage = "Please select a role")]
    public ApplicationRole Role { get; set; }

    [Required(ErrorMessage = "Please select at least one platform")]
    [MinLength(1, ErrorMessage = "Please select at least one platform")]
    public List<string> Platforms { get; set; } = new();

    public string? Skills { get; set; }

    [Required(ErrorMessage = "Password is required")]
    [StringLength(100, MinimumLength = 8, ErrorMessage = "Password must be at least 8 characters")]
    public string Password { get; set; } = string.Empty;

    [Required(ErrorMessage = "Please confirm your password")]
    [Compare("Password", ErrorMessage = "Passwords do not match")]
    public string ConfirmPassword { get; set; } = string.Empty;

    [Required(ErrorMessage = "Please tell us how you'll contribute")]
    [StringLength(2000, MinimumLength = 20, ErrorMessage = "Please write at least 20 characters")]
    public string Motivation { get; set; } = string.Empty;
}

public enum ApplicationRole
{
    Tester,
    Developer
}
