package fr.titionfire.ffsaf.domain.entity;

import fr.titionfire.ffsaf.data.model.MembreModel;
import fr.titionfire.ffsaf.utils.Categorie;
import fr.titionfire.ffsaf.utils.Genre;
import fr.titionfire.ffsaf.utils.GradeArbitrage;
import fr.titionfire.ffsaf.utils.RoleAsso;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@RegisterForReflection
public class MembreEntity {
    private long id;
    private String lname = "";
    private String fname = "";
    private Categorie categorie;
    private ClubEntity club;
    private Genre genre;
    private Integer licence;
    private String country;
    private Date birth_date;
    private String email;
    private RoleAsso role;
    private GradeArbitrage grade_arbitrage;
    private String url_photo;


    public static MembreEntity fromModel(MembreModel model) {
        if (model == null)
            return null;

        return new MembreEntityBuilder()
                .id(model.getId())
                .lname(model.getLname())
                .fname(model.getFname())
                .categorie(model.getCategorie())
                .club(ClubEntity.fromModel(model.getClub()))
                .genre(model.getGenre())
                .licence(model.getLicence())
                .country(model.getCountry())
                .birth_date(model.getBirth_date())
                .email(model.getEmail())
                .role(model.getRole())
                .grade_arbitrage(model.getGrade_arbitrage())
                .url_photo(model.getUrl_photo())
                .build();
    }

    public static String getFullName(MembreModel model) {
        return model.getFname() + " " + model.getLname();
    }
    public String getFullName() {
        return this.fname + " " + this.lname;
    }


}
