package fr.titionfire.ffsaf.rest.from;

import fr.titionfire.ffsaf.utils.RoleAsso;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.core.MediaType;
import lombok.Getter;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.jboss.resteasy.reactive.PartType;
import org.jboss.resteasy.reactive.multipart.FileUpload;

@Getter
public class AffiliationRequestSaveForm {
    @Schema(description = "L'identifiant de l'affiliation.", examples = "1", required = true)
    @FormParam("id")
    private Long id = null;

    @Schema(description = "Le nom de l'association.", examples = "Association sportive", required = true)
    @FormParam("name")
    private String name = null;

    @Schema(description = "Le numéro SIRET ou RNA de l'association.", examples = "12345678901234", required = true)
    @FormParam("state_id")
    private String state_id = null;

    @Schema(description = "L'adresse de l'association.", examples = "1 rue de l'exemple, 75000 Paris", required = true)
    @FormParam("address")
    private String address = null;

    @Schema(description = "Email de contact de l'association", examples = "test@test.fr")
    @FormParam("contact")
    private String contact = null;

    @Schema(description = "Le statut de l'association.")
    @FormParam("status")
    @PartType(MediaType.APPLICATION_OCTET_STREAM)
    private FileUpload status = null;

    @Schema(description = "Le logo de l'association.")
    @FormParam("logo")
    @PartType(MediaType.APPLICATION_OCTET_STREAM)
    private FileUpload logo = null;

    @Schema(description = "Mode utiliser pour la sauvegarde du membre 1 (0 = licence mode, 2 = nom, prénom)", examples = "0", required = true)
    @FormParam("m1_mode")
    private Integer m1_mode = null;

    @Schema(description = "Le rôle du premier membre de l'association.", examples = "PRÉSIDENT", required = true)
    @FormParam("m1_role")
    private RoleAsso m1_role = null;

    @Schema(description = "Le numéro de licence du premier membre de l'association. (null si non licencié)", examples = "1234567", required = true)
    @FormParam("m1_licence")
    private String m1_lincence = null;

    @Schema(description = "Le nom du premier membre de l'association.", examples = "Dupont", required = true)
    @FormParam("m1_lname")
    private String m1_lname = null;

    @Schema(description = "Le prénom du premier membre de l'association.", examples = "Jean", required = true)
    @FormParam("m1_fname")
    private String m1_fname = null;

    @Schema(description = "L'adresse e-mail du premier membre de l'association.", examples = "jean.dupont@examples.com", required = true)
    @FormParam("m1_email")
    private String m1_email = null;

    @Schema(name = "keep_email",
            description = "Conserver l'email de la base de donner (1 = conserve, 0 = replacer par 'm1_email')", examples = "1", required = true)
    @FormParam("m1_email_mode")
    private Integer m1_email_mode = null;

    @Schema(description = "Mode utiliser pour la sauvegarde du membre 2 (0 = licence mode, 2 = nom, prénom)", examples = "0", required = true)
    @FormParam("m2_mode")
    private Integer m2_mode = null;

    @Schema(description = "Le rôle du deuxième membre de l'association.", examples = "TRÉSORIER", required = true)
    @FormParam("m2_role")
    private RoleAsso m2_role = null;

    @Schema(description = "Le numéro de licence du deuxième membre de l'association. (null si non licencié)", examples = "2345678", required = true)
    @FormParam("m2_licence")
    private String m2_lincence = null;

    @Schema(description = "Le nom du deuxième membre de l'association.", examples = "Durand", required = true)
    @FormParam("m2_lname")
    private String m2_lname = null;

    @Schema(description = "Le prénom du deuxième membre de l'association.", examples = "Paul", required = true)
    @FormParam("m2_fname")
    private String m2_fname = null;

    @Schema(description = "L'adresse e-mail du deuxième membre de l'association.", examples = "paul.durand@examples.com", required = true)
    @FormParam("m2_email")
    private String m2_email = null;

    @Schema(name = "keep_email",
            description = "Conserver l'email de la base de donner (1 = conserve, 0 = replacer par 'm2_email')", examples = "1", required = true)
    @FormParam("m2_email_mode")
    private Integer m2_email_mode = null;

    @Schema(description = "Mode utiliser pour la sauvegarde du membre 3 (0 = licence mode, 2 = nom, prénom)", examples = "0", required = true)
    @FormParam("m3_mode")
    private Integer m3_mode = null;

    @Schema(description = "Le rôle du troisième membre de l'association.", examples = "SECRÉTAIRE", required = true)
    @FormParam("m3_role")
    private RoleAsso m3_role = null;

    @Schema(description = "Le numéro de licence du troisième membre de l'association. (null si non licencié)", examples = "3456789", required = true)
    @FormParam("m3_licence")
    private String m3_lincence = null;

    @Schema(description = "Le nom du troisième membre de l'association.", examples = "Martin", required = true)
    @FormParam("m3_lname")
    private String m3_lname = null;

    @Schema(description = "Le prénom du troisième membre de l'association.", examples = "Pierre", required = true)
    @FormParam("m3_fname")
    private String m3_fname = null;

    @Schema(description = "L'adresse e-mail du troisième membre de l'association.", examples = "pierre.martin@examples.com", required = true)
    @FormParam("m3_email")
    private String m3_email = null;

    @Schema(name = "keep_email",
            description = "Conserver l'email de la base de donner (1 = conserve, 0 = replacer par 'm3_email')", examples = "1", required = true)
    @FormParam("m3_email_mode")
    private Integer m3_email_mode = null;


    @Getter
    public class Member {
        private Integer mode;
        private RoleAsso role;
        private String licence;
        private String lname;
        private String fname;
        private String email;
        private Integer email_mode;

        public Member(int n) {
            if (n == 1) {
                mode = m1_mode;
                role = m1_role;
                licence = m1_lincence;
                lname = m1_lname;
                fname = m1_fname;
                email = m1_email;
                email_mode = m1_email_mode;
            } else if (n == 2) {
                mode = m2_mode;
                role = m2_role;
                licence = m2_lincence;
                lname = m2_lname;
                fname = m2_fname;
                email = m2_email;
                email_mode = m2_email_mode;
            } else if (n == 3) {
                mode = m3_mode;
                role = m3_role;
                licence = m3_lincence;
                lname = m3_lname;
                fname = m3_fname;
                email = m3_email;
                email_mode = m3_email_mode;
            }
        }
    }

    @Override
    public String toString() {
        return "AffiliationRequestSaveForm{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", state_id=" + state_id +
                ", address='" + address + '\'' +
                ", contact='" + contact + '\'' +
                ", m1_mode=" + m1_mode +
                ", m1_role=" + m1_role +
                ", m1_lincence='" + m1_lincence + '\'' +
                ", m1_lname='" + m1_lname + '\'' +
                ", m1_fname='" + m1_fname + '\'' +
                ", m1_email='" + m1_email + '\'' +
                ", m1_email_mode=" + m1_email_mode +
                ", m2_mode=" + m2_mode +
                ", m2_role=" + m2_role +
                ", m2_lincence='" + m2_lincence + '\'' +
                ", m2_lname='" + m2_lname + '\'' +
                ", m2_fname='" + m2_fname + '\'' +
                ", m2_email='" + m2_email + '\'' +
                ", m2_email_mode=" + m2_email_mode +
                ", m3_mode=" + m3_mode +
                ", m3_role=" + m3_role +
                ", m3_lincence='" + m3_lincence + '\'' +
                ", m3_lname='" + m3_lname + '\'' +
                ", m3_fname='" + m3_fname + '\'' +
                ", m3_email='" + m3_email + '\'' +
                ", m3_email_mode=" + m3_email_mode +
                '}';
    }
}
