//
//  EducationHelpers.swift
//  lichunWebsocket
//
//  Education qualification and formatting utilities
//

import Foundation

/// Checks if a user with a given education level qualifies for a requirement
/// - Parameters:
///   - userEducation: The user's current education level (e.g., "1st", "high_school", "bachelors")
///   - requirement: The required education level
/// - Returns: True if the user qualifies, false otherwise
func doesUserQualify(userEducation: String, for requirement: String) -> Bool {
    // Mapping user's grade levels to "none"
    let gradeLevels = ["1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th"]
    if gradeLevels.contains(userEducation) {
        return requirement == "none"
    }

    // For other education types, simply check if the requirement matches
    return userEducation == requirement
}

/// Formats an education string by replacing underscores with spaces and capitalizing words
/// - Parameter str: The education string to format (e.g., "high_school")
/// - Returns: The formatted string (e.g., "High School")
func formatEducationString(_ str: String) -> String {
    return str.split(separator: "_")
        .map { $0.capitalized }
        .joined(separator: " ")
}
