package com.lesingle.edu.common.enums;

import lombok.Getter;

/**
 * User Role Enum
 */
@Getter
public enum UserRole {

    ADMIN("admin", "Super Admin"),
    SCHOOL("school", "School Admin"),
    TEACHER("teacher", "Teacher"),
    PARENT("parent", "Parent");

    private final String code;
    private final String description;

    UserRole(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static UserRole fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Role code cannot be null");
        }
        for (UserRole role : values()) {
            if (role.getCode().equalsIgnoreCase(code)) {
                return role;
            }
        }
        throw new IllegalArgumentException("Unknown role code: " + code);
    }

}
