import React, { useRef, useState, useEffect } from "react";
import TextField from '@mui/material/TextField';
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css
import Button from '@mui/material/Button';
import axios from "axios";
import { getCookie, setCookie } from 'react-use-cookie';
import { useHistory } from "react-router-dom";
import { DataGrid, GridToolbar, frFR } from '@mui/x-data-grid';
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
import 'react-tooltip/dist/react-tooltip.css'
import Popup from 'reactjs-popup';
import 'reactjs-popup/dist/index.css';
import "react-datepicker/dist/react-datepicker.css";
import Box from '@mui/material/Box';
import { CiTrash } from "react-icons/ci";
import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif";
import { IoAddCircleOutline, IoCloseCircleOutline } from "react-icons/io5";
import Link from '@mui/material/Link';
import { PiDotsThree } from "react-icons/pi";
import Module_Alert_Confirmation from "./Module_Alert_Confirmation";

const Partner_Config_Ftion_Initiale = (props) => {

    const history = useHistory();
    const [submenu, setsubmenu] = useState("type_eval");
    const [rowss, setRows] = useState([]);

    const [selectionModel_type_eval, setselectionModel_type_eval] = React.useState([]);

    const [selectionModel_referentiel_padagogique, setselectionModel_referentiel_padagogique] = React.useState([]);
    var date_today_90j = new Date();
    date_today_90j.setDate(date_today_90j.getDate() + 90);

    function ExpandableCell_50({ value }) {
        const [expanded, setExpanded] = React.useState(false);

        return (
            <nav>
                {value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>

                    {expanded ? value : String(value).slice(0, 50)}&nbsp;
                    {value.length > 50 && (
                        // eslint-disable-next-line jsx-a11y/anchor-is-valid
                        <Link
                            type="button"
                            component="button"
                            sx={{ fontSize: 'inherit' }}
                            onClick={() => setExpanded(!expanded)}
                        >
                            {expanded ? <nav>  <PiDotsThree />Réduire</nav> : <nav> <PiDotsThree />Voir</nav>}
                        </Link>
                    )}
                </div>}

                {!value && <div style={{ paddingLeft: "5px", paddingRight: "15px", "display": "block", wordBreak: "break-all" }}>
                    &nbsp;
                </div>
                }
            </nav>
        );
    }

    function Annule_Mise_A_jour() {

    }

    const columns_type_evaluation = [
        { field: '_id', headerName: '_id', hide: true },
        { field: 'id', headerName: 'id', hide: true },
        { field: 'code', headerName: 'Code', fminWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'nom', headerName: 'Nom', minWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'description', headerName: 'Description', minWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        {
            field: "delete", headerName: 'Supprimer',
            renderCell: (cellValues) => {
                return (

                    <Popup
                        trigger={<Button
                        >
                            <CiTrash />

                        </Button>}
                        modal
                        nested
                        position="center center"
                    >
                        {close => (
                            <div>
                                <button className="gest_close" onClick={close}>
                                    &times;
                                </button>
                                <div className="gest_header"> MySy Information </div>
                                <div className="gest_content">
                                    {' '}

                                    En confirmant cette opération, le type d'évaluation sera <i><font color="red"> définitivement supprimé</font></i>. <br />

                                </div>
                                <div className="gest_actions">
                                    <div style={{ "width": "45%", "float": "left" }}>
                                        <button className="gest_bton_popup" onClick={(event) => {
                                            handleClick_delete_Type_Evaluation(event, cellValues);
                                            //console.log('modal closed ');
                                            close();
                                        }}> Valider </button>

                                    </div>
                                    <div style={{ "width": "45%", "float": "right" }}>
                                        <button
                                            className="gest_bton_popup"
                                            onClick={() => {
                                                //console.log('modal closed ');
                                                close();
                                            }}
                                        >
                                            Annuler
                                        </button>
                                    </div>
                                </div>
                            </div>
                        )}
                    </Popup>


                );
            }
        }
    ]

    const columns_referentiel_padagogique = [
        { field: '_id', headerName: '_id', hide: true },
        { field: 'id', headerName: 'id', hide: true },
        { field: 'code', headerName: 'Code', fminWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'description', headerName: 'Description', minWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        { field: 'commentaire', headerName: 'Commentaire', minWidth: 150, flex: 1, renderCell: (params) => <ExpandableCell_50 {...params} />, },
        {
            field: "delete", headerName: 'Supprimer',
            renderCell: (cellValues) => {
                return (

                    <Popup
                        trigger={<Button
                        >
                            <CiTrash />

                        </Button>}
                        modal
                        nested
                        position="center center"
                    >
                        {close => (
                            <div>
                                <button className="gest_close" onClick={close}>
                                    &times;
                                </button>
                                <div className="gest_header"> MySy Information </div>
                                <div className="gest_content">
                                    {' '}

                                    En confirmant cette opération, le référentiel sera <i><font color="red"> définitivement supprimé</font></i>. <br />

                                </div>
                                <div className="gest_actions">
                                    <div style={{ "width": "45%", "float": "left" }}>
                                        <button className="gest_bton_popup" onClick={(event) => {
                                            handleClick_delete_Ref_Ped(event, cellValues);
                                            //console.log('modal closed ');
                                            close();
                                        }}> Valider </button>

                                    </div>
                                    <div style={{ "width": "45%", "float": "right" }}>
                                        <button
                                            className="gest_bton_popup"
                                            onClick={() => {
                                                //console.log('modal closed ');
                                                close();
                                            }}
                                        >
                                            Annuler
                                        </button>
                                    </div>
                                </div>
                            </div>
                        )}
                    </Popup>


                );
            }
        }
    ]


    const [handleClick_delete_Type_Evaluation_api, sethandleClick_delete_Type_Evaluation_api] = useState();
    const [handleClick_delete_Type_Evaluation_message, sethandleClick_delete_Type_Evaluation_message] = useState();
    const [handleClick_delete_Type_Evaluation_result, sethandleClick_delete_Type_Evaluation_result] = useState();
    function handleClick_delete_Type_Evaluation(event, cellValues) {

        var type_eval = cellValues.row._id;

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("_id", type_eval);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_Type_Evaluation/";

        setLoading(true);
        axios.post(myurl, form).then(res => {

            setLoading(false);
            if (String(res.data.status) === String("true")) {
                //console.log(" In handleClick_delete_Type_Evaluation  res.data.status = " + res.data.status);
                //console.log(" In handleClick_delete_Type_Evaluation  res.data.message r_class = " + res.data.message);
                sethandleClick_delete_Type_Evaluation_api("true");
                sethandleClick_delete_Type_Evaluation_result(res.data.message);

                Getall_Parter_config_type_evaluation();

                setp_one_detail_config_code("");
                setp_one_detail_config_nom("");
                setp_one_detail_config_description("");
                setconfig_type_eval_edit_mode("");
                setconfig_type_eval_changed("");
                setdisplay_detail_type_eval("");
                setadd_config_type_eval("");
                setgridline_type_eval_id("");


                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");
                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }


            }
            else {
                sethandleClick_delete_Type_Evaluation_api("false");
                sethandleClick_delete_Type_Evaluation_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( handleClick_delete_Type_Evaluation = ', error);
            sethandleClick_delete_Type_Evaluation_api("false");
            alert(" Impossible de supprimer le type d'évaluation");
            //setmyApimyApiMessage("")
        })
    }

    const [handleClick_delete_Ref_Ped_api, sethandleClick_delete_Ref_Ped_api] = useState();
    const [handleClick_delete_Ref_Ped_message, sethandleClick_delete_Ref_Ped_message] = useState();
    const [handleClick_delete_Ref_Ped_result, sethandleClick_delete_Ref_Ped_result] = useState();
    function handleClick_delete_Ref_Ped(event, cellValues) {

        var type_eval = cellValues.row._id;

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("tab_id", type_eval);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Delete_List_Ref_Pedagogique/";

        setLoading(true);
        axios.post(myurl, form).then(res => {

            setLoading(false);
            if (String(res.data.status) === String("true")) {
                //console.log(" In handleClick_delete_Ref_Ped  res.data.status = " + res.data.status);
                //console.log(" In handleClick_delete_Ref_Ped  res.data.message r_class = " + res.data.message);
                sethandleClick_delete_Ref_Ped_api("true");
                sethandleClick_delete_Ref_Ped_result(res.data.message);

                Getall_Parter_referentiel_padagogique();

                setp_one_detail_ref_ped_code("");
                setp_one_detail_ref_ped_commentaire("");
                setp_one_detail_ref_ped_description("");

                setref_ped_edit_mode("");
                setref_ped_changed("");
                setdisplay_detail_ref_ped("");
                setadd_config_ref_ped("");
                setgridline_ref_ped_id("");


                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");
                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }


            }
            else {
                sethandleClick_delete_Ref_Ped_api("false");
                sethandleClick_delete_Ref_Ped_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( handleClick_delete_Ref_Ped = ', error);
            sethandleClick_delete_Ref_Ped_api("false");
            alert(" Impossible de supprimer le type d'évaluation");
            //setmyApimyApiMessage("")
        })
    }

    const [p_filtre1, setp_filtre1] = useState();
    const [p_filtre1_value, setp_filtre1_value] = useState();

    const [p_filtre2, setp_filtre2] = useState();
    const [p_filtre2_value, setp_filtre2_value] = useState();

    const [p_filtre3, setp_filtre3] = useState();
    const [p_filtre3_value, setp_filtre3_value] = useState();

    const [p_filtre4, setp_filtre4] = useState();
    const [p_filtre4_value, setp_filtre4_value] = useState();

    const [isLoading, setLoading] = useState();

    const [selected_type_eval_id, setselected_type_eval_id] = useState();


    const [New_Getall_Parter_config_type_evaluation_result, setNew_Getall_Parter_config_type_evaluation_result] = useState([]);

    const [Getall_Parter_config_type_evaluation_api, setGetall_Parter_config_type_evaluation_api] = useState();
    const [Getall_Parter_config_type_evaluation_message, setGetall_Parter_config_type_evaluation_message] = useState();
    const [Getall_Parter_config_type_evaluation_result, setGetall_Parter_config_type_evaluation_result] = useState([]);
    function Getall_Parter_config_type_evaluation(event) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_List_Type_Evaluation/";

        setLoading(true);
        axios.post(myurl, form).then(res => {
            setLoading(false);

            if (String(res.data.status) === String("true")) {
                //console.log(" In Getall_Parter_config_type_evaluation  res.data.status = " + res.data.status);
                //console.log(" In Getall_Parter_config_type_evaluation  res.data.message r_class = " + res.data.message);
                setGetall_Parter_config_type_evaluation_api("true");
                setGetall_Parter_config_type_evaluation_result(res.data.message);
                //setRows(res.data.message);

                var new_data2 = [];
                const new_data = res.data.message.map((x) => {

                    //---
                    var localid = JSON.parse(x).id;
                    var local_id = JSON.parse(x)._id;
                    var local_nom = JSON.parse(x).nom;
                    var local_code = JSON.parse(x).code;
                    var local_description = JSON.parse(x).description;


                    //---
                    var node = {
                        "_id": local_id,
                        "id": localid,
                        "label": local_code + " " + local_nom,
                        "nom": local_nom,
                        "code": local_code,
                        "description": local_description,

                    };
                    new_data2.push(node);
                });

                //---
                var node = {
                    "_id": "",
                    "id": "",
                    "label": "",
                    "nom": "",
                    "code": "",
                    "description": "",

                };
                new_data2.push(node);

                if (new_data2.length > 0)
                    setNew_Getall_Parter_config_type_evaluation_result(new_data2);

            }
            else {
                setGetall_Parter_config_type_evaluation_api("false");
                setGetall_Parter_config_type_evaluation_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( Getall_Parter_config_type_evaluation = ', error);
            setGetall_Parter_config_type_evaluation_api("false");
            alert(" Impossible de recuperer la liste des points de configuration");
            //setmyApimyApiMessage("")
        })
    }


    const [New_Getall_Parter_referentiel_padagogique_result, setNew_Getall_Parter_referentiel_padagogique_result] = useState([]);

    const [Getall_Parter_referentiel_padagogique_api, setGetall_Parter_referentiel_padagogique_api] = useState();
    const [Getall_Parter_referentiel_padagogique_message, setGetall_Parter_referentiel_padagogique_message] = useState();
    const [Getall_Parter_referentiel_padagogique_result, setGetall_Parter_referentiel_padagogique_result] = useState([]);
    function Getall_Parter_referentiel_padagogique(event) {

        var form = new FormData();


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Ref_Pedagogique_no_filter/";

        setLoading(true);
        axios.post(myurl, form).then(res => {
            setLoading(false);

            if (String(res.data.status) === String("true")) {
                //console.log(" In Getall_Parter_referentiel_padagogique  res.data.status = " + res.data.status);
                //console.log(" In Getall_Parter_referentiel_padagogique  res.data.message r_class = " + res.data.message);
                setGetall_Parter_referentiel_padagogique_api("true");
                setGetall_Parter_referentiel_padagogique_result(res.data.message);
                //setRows(res.data.message);

                var new_data2 = [];
                const new_data = res.data.message.map((x) => {

                    //---
                    var localid = JSON.parse(x).id;
                    var local_id = JSON.parse(x)._id;
                    var local_commentaire = JSON.parse(x).commentaire;
                    var local_code = JSON.parse(x).code;
                    var local_description = JSON.parse(x).description;


                    //---
                    var node = {
                        "_id": local_id,
                        "id": localid,
                        "label": local_code,
                        "commentaire": local_commentaire,
                        "code": local_code,
                        "description": local_description,

                    };
                    new_data2.push(node);
                });

                //---
                var node = {
                    "_id": "",
                    "id": "",
                    "label": "",
                    "commentaire": "",
                    "code": "",
                    "description": "",

                };
                new_data2.push(node);

                if (new_data2.length > 0)
                    setNew_Getall_Parter_referentiel_padagogique_result(new_data2);

            }
            else {
                setGetall_Parter_referentiel_padagogique_api("false");
                setGetall_Parter_referentiel_padagogique_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('Not good man :( Getall_Parter_referentiel_padagogique = ', error);
            setGetall_Parter_referentiel_padagogique_api("false");
            alert(" Impossible de recuperer la liste des référentiels pédagogiques");
            //setmyApimyApiMessage("")
        })
    }




    function submenu_calcul_note_finale() {
        setsubmenu("calcul_note_finale");

        submenu_color_management("calcul_note_finale");
    }

    function submenu_type_eval() {
        Getall_Parter_config_type_evaluation();
        setsubmenu("type_eval");

        submenu_color_management("type_eval");
    }

    function submenu_referentiel_padagogique() {
        Getall_Parter_referentiel_padagogique();
        setsubmenu("referentiel_padagogique");
        submenu_color_management("referentiel_padagogique");
    }


    function submenu_color_management(current_menu) {
        const list_sous_menu = ["type_eval", "calcul_note_finale"]

        for (let i = 0; i < list_sous_menu.length; i++) {

            var sous_menu = list_sous_menu[i];
            if (String(sous_menu) !== current_menu) {
                if (document.getElementById(sous_menu)) {
                    document.getElementById(sous_menu).style.backgroundColor = "#d8edfc";
                    document.getElementById(sous_menu).style.color = "black";
                    document.getElementById(sous_menu).style.fontWeight = "normal";
                }
            }



        }

        if (document.getElementById(current_menu)) {
            document.getElementById(current_menu).style.backgroundColor = "#107758";
            document.getElementById(current_menu).style.color = "white";
            document.getElementById(current_menu).style.fontWeight = "bold";
        }

        if (document.getElementById('myRef_head')) {
            var divh = document.getElementById('myRef_head').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }

    }

    const myRef_head = useRef(null);

    useEffect(() => {

        Getall_Parter_config_type_evaluation();

        if (document.getElementById('myRef_head')) {
            var divh = document.getElementById('myRef_head').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }
        submenu_type_eval();


    }, [])

    const [p_one_detail_config_code, setp_one_detail_config_code] = useState("");
    const [p_one_detail_config_nom, setp_one_detail_config_nom] = useState("");
    const [p_one_detail_config_description, setp_one_detail_config_description] = useState("");


    const [p_detail_config_code, setp_detail_config_code] = useState("");
    const [p_detail_config_nom, setp_detail_config_nom] = useState("");
    const [p_detail_config_description, setp_detail_config_description] = useState("");

    const [config_type_eval_edit_mode, setconfig_type_eval_edit_mode] = useState("");
    const [config_type_eval_changed, setconfig_type_eval_changed] = useState("");

    const [gridline_type_eval_id, setgridline_type_eval_id] = useState("");
    const [display_detail_type_eval, setdisplay_detail_type_eval] = React.useState();


    const [selected_ref_ped_id, setselected_ref_ped_id] = useState("");
    const [add_config_ref_ped, setadd_config_ref_ped] = useState("");


    const [p_one_detail_ref_ped_code, setp_one_detail_ref_ped_code] = useState("");
    const [p_one_detail_ref_ped_commentaire, setp_one_detail_ref_ped_commentaire] = useState("");
    const [p_one_detail_ref_ped_description, setp_one_detail_ref_ped_description] = useState("");


    const [p_detail_ref_ped_code, setp_detail_ref_ped_code] = useState("");
    const [p_detail_ref_ped_commentaire, setp_detail_ref_ped_commentaire] = useState("");
    const [p_detail_ref_ped_description, setp_detail_ref_ped_description] = useState("");

    const [ref_ped_edit_mode, setref_ped_edit_mode] = useState("");
    const [ref_ped_changed, setref_ped_changed] = useState("");

    const [gridline_ref_ped_id, setgridline_ref_ped_id] = useState("");
    const [display_detail_ref_ped, setdisplay_detail_ref_ped] = React.useState();


    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function Enable_Config_Type_Eval_DetailFields() {
        await sleep(5);
        setconfig_type_eval_edit_mode("1");

        if (document.getElementsByName("detail_config_code")[0]) {
            document.getElementsByName("detail_config_code")[0].disabled = false;
            document.getElementsByName("detail_config_code")[0].style.backgroundColor = "#FFFFFF";
        }

        if (document.getElementsByName("detail_config_nom")[0]) {
            document.getElementsByName("detail_config_nom")[0].disabled = false;
            document.getElementsByName("detail_config_nom")[0].style.backgroundColor = "#FFFFFF";
        }

        if (document.getElementsByName("detail_config_desc")[0]) {
            document.getElementsByName("detail_config_desc")[0].disabled = false;
            document.getElementsByName("detail_config_desc")[0].style.backgroundColor = "#FFFFFF";
        }

    }


    async function Disable_Config_Type_Eval_DetailFields() {

        await sleep(10);

        setconfig_type_eval_edit_mode("0");

        if (document.getElementsByName("detail_config_code")[0]) {

            document.getElementsByName("detail_config_code")[0].disabled = true;
            document.getElementsByName("detail_config_code")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_config_nom")[0]) {

            document.getElementsByName("detail_config_nom")[0].disabled = true;
            document.getElementsByName("detail_config_nom")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_config_desc")[0]) {
            document.getElementsByName("detail_config_desc")[0].disabled = true;
            document.getElementsByName("detail_config_desc")[0].style.backgroundColor = "#ECEFF1";
        }

    }

    async function Enable_Config_Ref_Ped_DetailFields() {
        await sleep(5);
        setref_ped_edit_mode("1");

        if (document.getElementsByName("detail_ref_ped_code")[0]) {
            document.getElementsByName("detail_ref_ped_code")[0].disabled = false;
            document.getElementsByName("detail_ref_ped_code")[0].style.backgroundColor = "#FFFFFF";
        }

        if (document.getElementsByName("detail_ref_ped_comment")[0]) {
            document.getElementsByName("detail_ref_ped_comment")[0].disabled = false;
            document.getElementsByName("detail_ref_ped_comment")[0].style.backgroundColor = "#FFFFFF";
        }

        if (document.getElementsByName("detail_ref_ped_desc")[0]) {
            document.getElementsByName("detail_ref_ped_desc")[0].disabled = false;
            document.getElementsByName("detail_ref_ped_desc")[0].style.backgroundColor = "#FFFFFF";
        }

    }


    async function Disable_Config_Red_Ped_DetailFields() {

        await sleep(10);

        setref_ped_edit_mode("0");

        if (document.getElementsByName("detail_ref_ped_code")[0]) {

            document.getElementsByName("detail_ref_ped_code")[0].disabled = true;
            document.getElementsByName("detail_ref_ped_code")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_ref_ped_comment")[0]) {
            document.getElementsByName("detail_ref_ped_comment")[0].disabled = true;
            document.getElementsByName("detail_ref_ped_comment")[0].style.backgroundColor = "#ECEFF1";
        }

        if (document.getElementsByName("detail_ref_ped_desc")[0]) {
            document.getElementsByName("detail_ref_ped_desc")[0].disabled = true;
            document.getElementsByName("detail_ref_ped_desc")[0].style.backgroundColor = "#ECEFF1";
        }

    }


    const myRef = useRef(null)

    async function Annule_Type_Eval_DetailFields() {

        setconfig_type_eval_edit_mode("0");
        var line1 = New_Getall_Parter_config_type_evaluation_result.filter((data) => (data)._id === String(selected_type_eval_id))


        setdisplay_detail_type_eval("1");
        setadd_config_type_eval("");


        setp_detail_config_code(line1[0].code);
        setp_detail_config_nom(line1[0].nom);
        setp_detail_config_description(line1[0].description);



        if (document.getElementById('myRef')) {
            var divh = document.getElementById('myRef').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }


        Disable_Config_Type_Eval_DetailFields();
    }


    async function Annule_Ref_Ped_DetailFields() {

        setconfig_type_eval_edit_mode("0");
        var line1 = New_Getall_Parter_referentiel_padagogique_result.filter((data) => (data)._id === String(selected_ref_ped_id))


        setdisplay_detail_ref_ped("1");
        setadd_config_ref_ped("");


        setp_detail_ref_ped_code(line1[0].code);
        setp_detail_ref_ped_commentaire(line1[0].commentaire);
        setp_detail_ref_ped_description(line1[0].description);


        if (document.getElementById('myRef')) {
            var divh = document.getElementById('myRef').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }


        Disable_Config_Type_Eval_DetailFields();
    }



    function Annule_Add_Type_Eval_DetailFields() {

        var line = JSON.parse(Getall_Parter_config_type_evaluation_result[selected_type_eval_id]);

        setdisplay_detail_type_eval("");
        setadd_config_type_eval("");

        setp_detail_config_code(line.code);
        setp_detail_config_nom(line.nom);
        setp_detail_config_description(line.description);


        Disable_Config_Type_Eval_DetailFields();

        if (document.getElementById('myRef_head')) {
            var divh = document.getElementById('myRef_head').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }

    }

    function Annule_Add_Ref_Ped_DetailFields() {

        var line = JSON.parse(Getall_Parter_referentiel_padagogique_result[selected_ref_ped_id]);

        setdisplay_detail_ref_ped("");
        setadd_config_ref_ped("");

        setp_detail_ref_ped_code(line.code);
        setp_detail_ref_ped_commentaire(line.commentaire);
        setp_detail_ref_ped_description(line.description);


        Disable_Config_Red_Ped_DetailFields();

        if (document.getElementById('myRef_head')) {
            var divh = document.getElementById('myRef_head').offsetTop;
            window.scrollTo({
                top: divh,
                behavior: "smooth",
            });
        }

    }





    const [Add_Config_Type_Eval_api, setAdd_Config_Type_Eval_api] = useState();
    const [Add_Config_Type_Eval_message, setAdd_Config_Type_Eval_message] = useState();
    const [Add_Config_Type_Eval_result, setAdd_Config_Type_Eval_result] = useState();
    function Add_Config_Type_Eval() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("code", p_one_detail_config_code);
        form.append("nom", p_one_detail_config_nom);
        form.append("description", p_one_detail_config_description);


        //console.log(" form == ", form);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Evaluation_Type/";
        setLoading(true);

        axios.post(myurl, form).then(res => {
            setLoading(false);
            //console.log(" In Add_Config_Type_Eval  res.data.status = " + res.data.status);
            //console.log(" In Add_Config_Type_Eval  res.data.message r_class = " + res.data.message);

            if (String(res.data.status) === String("true")) {

                setAdd_Config_Type_Eval_api("true");
                setAdd_Config_Type_Eval_result(res.data.message);

                Getall_Parter_config_type_evaluation();

                setp_one_detail_config_code("");
                setp_one_detail_config_nom("");
                setp_one_detail_config_description("");
                setconfig_type_eval_edit_mode("");
                setconfig_type_eval_changed("");
                setdisplay_detail_type_eval("");
                setadd_config_type_eval("");
                setgridline_type_eval_id("");


                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");

                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }

            }
            else {
                setAdd_Config_Type_Eval_api("false");
                setAdd_Config_Type_Eval_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('UpdateStagiaireData : Not good man :( Add_Config_Type_Eval = ' + error);
            setAdd_Config_Type_Eval_api("false");
            alert(" Impossible d'ajouter  le paramétrage ");

        })
    }



    const [Add_Config_Ref_Ped_api, setAdd_Config_Ref_Ped_api] = useState();
    const [Add_Config_Ref_Ped_message, setAdd_Config_Ref_Ped_message] = useState();
    const [Add_Config_Ref_Ped_result, setAdd_Config_Ref_Ped_result] = useState();
    function Add_Config_Ref_Ped() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("code", p_one_detail_ref_ped_code);
        form.append("commentaire", p_one_detail_ref_ped_commentaire);
        form.append("description", p_one_detail_ref_ped_description);


        //console.log(" form == ", form);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Ref_Pedagogique/";
        setLoading(true);

        axios.post(myurl, form).then(res => {
            setLoading(false);
            //console.log(" In Add_Config_Ref_Ped  res.data.status = " + res.data.status);
            //console.log(" In Add_Config_Ref_Ped  res.data.message r_class = " + res.data.message);

            if (String(res.data.status) === String("true")) {

                setAdd_Config_Ref_Ped_api("true");
                setAdd_Config_Ref_Ped_result(res.data.message);

                Getall_Parter_referentiel_padagogique();

                setp_one_detail_ref_ped_code("");
                setp_one_detail_ref_ped_commentaire("");
                setp_one_detail_ref_ped_description("");

                setref_ped_edit_mode("");
                setref_ped_changed("");
                setdisplay_detail_ref_ped("");
                setadd_config_ref_ped("");
                setgridline_ref_ped_id("");


                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");

                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }

            }
            else {
                setAdd_Config_Ref_Ped_api("false");
                setAdd_Config_Ref_Ped_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('UpdateStagiaireData : Not good man :( Add_Config_Ref_Ped = ' + error);
            setAdd_Config_Ref_Ped_api("false");
            alert(" Impossible d'ajouter  le paramétrage ");

        })
    }

    const [Update_Config_Type_Eval_api, setUpdate_Config_Type_Eval_api] = useState();
    const [Update_Config_Type_Eval_message, setUpdate_Config_Type_Eval_message] = useState();
    const [Update_Config_Type_Eval_result, setUpdate_Config_Type_Eval_result] = useState();
    function Update_Config_Type_Eval() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("code", p_detail_config_code);
        form.append("nom", p_detail_config_nom);
        form.append("description", p_detail_config_description);
        form.append("_id", selected_type_eval_id);

        //console.log(" form == ", form);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Evaluation_Type/";
        setLoading(true);

        axios.post(myurl, form).then(res => {
            setLoading(false);
            //console.log(" In Update_Config_Type_Eval  res.data.status = " + res.data.status);
            //console.log(" In Update_Config_Type_Eval  res.data.message r_class = " + res.data.message);

            if (String(res.data.status) === String("true")) {

                setUpdate_Config_Type_Eval_api("true");
                setUpdate_Config_Type_Eval_result(res.data.message);

                Getall_Parter_config_type_evaluation();

                setp_detail_config_code("");
                setp_detail_config_nom("");
                setp_detail_config_description("");
                setconfig_type_eval_edit_mode("");
                setconfig_type_eval_changed("");
                setdisplay_detail_type_eval("");
                setadd_config_type_eval("");
                setgridline_type_eval_id("");

                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");
                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }

            }
            else {
                setUpdate_Config_Type_Eval_api("false");
                setUpdate_Config_Type_Eval_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('UpdateStagiaireData : Not good man :( Update_Config_Type_Eval = ' + error);
            setUpdate_Config_Type_Eval_api("false");
            alert(" Impossible de mettre à jour le paramétrage ");

        })
    }

    const [Update_Config_Ref_Ped_api, setUpdate_Config_Ref_Ped_api] = useState();
    const [Update_Config_Ref_Ped_message, setUpdate_Config_Ref_Ped_message] = useState();
    const [Update_Config_Ref_Ped_result, setUpdate_Config_Ref_Ped_result] = useState();
    function Update_Config_Ref_Ped() {
        var form = new FormData();
        //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA");


        const stored_cookie = getCookie('tokenmysypart');
        form.append("token", stored_cookie);
        form.append("code", p_detail_ref_ped_code);
        form.append("commentaire", p_detail_ref_ped_commentaire);
        form.append("description", p_detail_ref_ped_description);
        form.append("_id", selected_ref_ped_id);

        //console.log(" form == ", form);

        var myurl = process.env.REACT_APP_API_URL + "myclass/api/Update_Ref_Pedagogique/";
        setLoading(true);

        axios.post(myurl, form).then(res => {
            setLoading(false);
            //console.log(" In Update_Config_Ref_Ped  res.data.status = " + res.data.status);
            //console.log(" In Update_Config_Ref_Ped  res.data.message r_class = " + res.data.message);

            if (String(res.data.status) === String("true")) {

                setUpdate_Config_Ref_Ped_api("true");
                setUpdate_Config_Ref_Ped_result(res.data.message);

                Getall_Parter_referentiel_padagogique();

                setp_detail_ref_ped_code("");
                setp_detail_ref_ped_commentaire("");
                setp_detail_ref_ped_description("");
                setref_ped_edit_mode("");
                setref_ped_changed("");
                setdisplay_detail_ref_ped("");
                setadd_config_ref_ped("");
                setgridline_ref_ped_id("");

                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("success");
                if (document.getElementById('myRef_head')) {
                    var divh = document.getElementById('myRef_head').offsetTop;
                    window.scrollTo({
                        top: divh,
                        behavior: "smooth",
                    });
                }

            }
            else {
                setUpdate_Config_Ref_Ped_api("false");
                setUpdate_Config_Ref_Ped_message(res.data.message);
                // alert(res.data.message)
                setdisplay_alert_mysy("1");
                setalert_message(res.data.message);
                setalert_type("error");
            }

        }).catch((error) => {
            setLoading(false);
            console.warn('UpdateStagiaireData : Not good man :( Update_Config_Ref_Ped = ' + error);
            setUpdate_Config_Ref_Ped_api("false");
            alert(" Impossible de mettre à jour le paramétrage ");

        })
    }



    const [add_config_type_eval, setadd_config_type_eval] = useState("");

    function add_one_eval() {

        setp_one_detail_config_code("");
        setp_one_detail_config_nom("");
        setp_one_detail_config_description("");

        setdisplay_detail_type_eval("");
        setadd_config_type_eval("1");
    }

    function add_ref_ped() {

        setp_one_detail_ref_ped_code("");
        setp_one_detail_ref_ped_commentaire("");
        setp_one_detail_ref_ped_description("");

        setdisplay_detail_ref_ped("");
        setadd_config_ref_ped("1");
    }


    const [display_alert_mysy, setdisplay_alert_mysy] = useState("");
    const [alert_message, setalert_message] = useState("");
    const [alert_type, setalert_type] = useState("");

    function clear_alert_message() {
        setalert_message("");
    }
    function clear_alert_type() {
        setalert_type("");
    }

    function clear_display_alert_mysy() {
        setdisplay_alert_mysy("");
    }

    return (
        <div className="partner_ftion_initiale_configuration">
            {isLoading && <div className="loader-container">
                <div className="mysy_spinner">  <img src={img_loading_spin} />  </div>
            </div>}
            {/***  Affichage des messages d'alerte*/}
            {display_alert_mysy && String(display_alert_mysy) === "1" &&
                <Module_Alert_Confirmation alert_message={alert_message}
                    alert_type={alert_type}
                    clear_alert_message={clear_alert_message}
                    clear_alert_type={clear_alert_type}
                    clear_display_alert_mysy={clear_display_alert_mysy}
                />
            }
            {/*** FIN Affichage des messages d'alerte*/}

            <h3 style={{ fontFamily: 'DM Sans' }}> Formation Initale configuration </h3>
            <div className="div_row" ref={myRef_head} id="myRef_head" >
                <Button variant="outlined" onClick={submenu_type_eval} className="detail_class_submenu" id='technique' name='technique'>Type Evaluation</Button>
                <Button variant="outlined" onClick={submenu_calcul_note_finale} className="detail_class_submenu" id='calcul_note_finale' name='calcul_note_finale'>Calcul Note finale</Button>
                <Button variant="outlined" onClick={submenu_referentiel_padagogique} className="detail_class_submenu" id='referentiel_padagogique' name='referentiel_padagogique'>Référentiel pédag.</Button>


                {/*
                <Button variant="outlined" onClick={submenu_type_client} className="detail_class_submenu" id='type_client' name='type_client'>Type de clients </Button>
                <Button variant="outlined" onClick={submenu_site} className="detail_class_submenu" id='site' name='site'>Sites de formation  </Button>
                <Button variant="outlined" onClick={submenu_condition_paiement} className="detail_class_submenu" id='condition_paiement' name='condition_paiement'>Conditions de paiement  </Button>
                <Button variant="outlined" onClick={submenu_etape_opportunite} className="detail_class_submenu" id='etape_opportunite' name='etape_opportunite'>Etapes d'opportunité </Button>
                <Button variant="outlined" onClick={submenu_competence} className="detail_class_submenu" id='competence' name='competence'>Compétences </Button>
                <Button variant="outlined" onClick={submenu_devis} className="detail_class_submenu" id='devis' name='devis'>Devis </Button>
    */
                }

                {/*** Type evaluation  */}
                {String(submenu) === "type_eval" && <div className="div_row" style={{ paddingRight: '10px' }}>

                    <div>
                        <div className="div_row" style={{ paddingRight: '10px' }}>
                            <div className="session_data">
                                <div style={{ "border": "None" }}>
                                    <div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
                                        &nbsp;
                                        <Box
                                            sx={{
                                                height: 500,
                                                width: '100%',
                                                paddingRight: '1px',

                                                // Gestion des cellule "statut"
                                                '& .cell--status--encours': {
                                                    backgroundColor: '#E6F7C8',
                                                    color: '#1a3e72',
                                                    fontWeight: 'light',
                                                },
                                                '& .cell--status--traite': {
                                                    backgroundColor: '#E6CEAA',
                                                    color: '#F9E79F',
                                                    fontWeight: 'light',
                                                },

                                                "& .MuiDataGrid-columnHeaders": {
                                                    backgroundColor: "#c8cfd5",
                                                    color: "black",
                                                    fontSize: 14
                                                },

                                                '& .line--statut--selected': {
                                                    backgroundColor: '#FBF2EF',
                                                    color: 'black',
                                                },
                                                '& .line--statut--pair': {
                                                    backgroundColor: 'rgba(235, 235, 235, .7)',
                                                    color: 'black',
                                                },
                                                '& .line--statut--impair': {
                                                    backgroundColor: '#FFFFFF',
                                                    color: 'black',
                                                },

                                            }}
                                        >
                                            <DataGrid
                                                disableSelectionOnClick
                                                // checkboxSelection
                                                onSelectionModelChange={(newSelectionModel) => {
                                                    setselectionModel_type_eval(newSelectionModel);
                                                    /*if (newSelectionModel.length === 1)
                                                        handleClick_edit_config_From_Line(newSelectionModel);*/
                                                    if (newSelectionModel.length !== 1) {
                                                        setp_detail_config_code("");
                                                        setp_detail_config_nom("");
                                                        setp_detail_config_description("");
                                                        setconfig_type_eval_edit_mode("");
                                                        setconfig_type_eval_changed("");


                                                    }
                                                }}
                                                selectionModel={selectionModel_type_eval}

                                                localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                                rows={Getall_Parter_config_type_evaluation_result.map((item, index) => (
                                                    {
                                                        id: index,
                                                        _id: JSON.parse(item)._id,
                                                        code: JSON.parse(item).code,
                                                        nom: JSON.parse(item).nom,
                                                        description: JSON.parse(item).description,
                                                    }
                                                ))}

                                                columns={columns_type_evaluation}
                                                pageSize={10}
                                                className="datagridclass"

                                                onRowDoubleClick={(newSelectionModel) => {
                                                    setgridline_type_eval_id(newSelectionModel.row.id);
                                                    setp_detail_config_code(newSelectionModel.row.code);
                                                    setp_detail_config_nom(newSelectionModel.row.nom);
                                                    setp_detail_config_description(newSelectionModel.row.description);
                                                    setselected_type_eval_id(newSelectionModel.row._id);

                                                    setadd_config_type_eval("");
                                                    setdisplay_detail_type_eval("1");
                                                    setadd_config_type_eval("");
                                                    setconfig_type_eval_edit_mode("");
                                                    setconfig_type_eval_changed("");

                                                    Disable_Config_Type_Eval_DetailFields();

                                                    //handleClick_edit_config_From_Line(newSelectionModel.row.id);

                                                }}


                                                rowsPerPageOptions={[10]}
                                                //disableSelectionOnClick
                                                components={{
                                                    Toolbar: GridToolbar,
                                                }}
                                                //sx={datagridSx}
                                                getCellClassName={(params) => {



                                                }}
                                                getRowClassName={(params) => {


                                                    // Pour la gestion de la couleur de zone double cliquée
                                                    if (String(params.row.id) === String(gridline_type_eval_id)) {
                                                        return 'line--statut--selected';
                                                    }
                                                    else if (parseInt(String(params.row.id)) % 2 === 0) {
                                                        return 'line--statut--pair';
                                                    }
                                                    else if (parseInt(String(params.row.id)) % 2 !== 0) {
                                                        return 'line--statut--impair';
                                                    }
                                                }}


                                            />
                                        </Box>
                                        <br />

                                    </div>

                                </div>

                            </div>
                            <div className="div_row" style={{ "border": "None" }}>

                                <div className="div_row_gauche div_row_gauche_etendu" style={{ "textAlign": "left", "paddingLeft": "5px" }}>
                                    <Button variant="outlined" onClick={add_one_eval}
                                        className="detail_class_submenu bton_add_session"
                                        id='menu_import_participant' name='menu_import_participant'>Ajout 1 Type Eval &nbsp;
                                        <IoAddCircleOutline style={{ "fontSize": "x-large", "color": "green" }} />
                                    </Button>
                                </div>
                            </div>
                            <div className="div_row" ref={myRef} id="myRef"> &nbsp;</div>
                        </div>




                        {display_detail_type_eval && String(display_detail_type_eval) === "1" && String(add_config_type_eval) !== "1" && <div className="div_row">


                            {String(config_type_eval_edit_mode) !== "1" && <div>

                                <div className="session_caract"> Code <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_code"
                                        id="detail_config_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_code}

                                    />

                                </div>



                                <div className="session_caract"> Nom <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_nom"
                                        id="detail_config_nom"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_nom}

                                    />

                                </div>

                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_desc"
                                        id="detail_config_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_description}

                                    />

                                </div>

                            </div>}


                            {String(config_type_eval_edit_mode) === "1" && <div>

                                <div className="session_caract"> Code <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_code"
                                        id="detail_config_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_code}
                                        onChange={(e) => {
                                            setp_detail_config_code(e.target.value);
                                            setconfig_type_eval_changed("1");
                                        }}

                                    />

                                </div>



                                <div className="session_caract"> Nom <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_nom"
                                        id="detail_config_nom"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_nom}
                                        onChange={(e) => {
                                            setp_detail_config_nom(e.target.value);
                                            setconfig_type_eval_changed("1");
                                        }}

                                    />

                                </div>

                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_desc"
                                        id="detail_config_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_config_description}
                                        onChange={(e) => {
                                            setp_detail_config_description(e.target.value);
                                            setconfig_type_eval_changed("1");
                                        }}
                                    />

                                </div>

                            </div>}



                            <div>
                                <div className="div_row" style={{ "border": "None" }}>
                                    &nbsp;
                                </div>
                                {String(config_type_eval_changed) === "1" && String(config_type_eval_edit_mode) === "1" && <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
                                    /!\ Pensez à enregistrer les modifications
                                </div>}
                                <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                                    {String(config_type_eval_edit_mode) === "1" && String(config_type_eval_changed) === "1" && <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                        <Button variant="contained" className="bton_enreg" onClick={Update_Config_Type_Eval}>Enregistrer les modifications
                                        </Button>

                                    </div>}

                                    {String(config_type_eval_edit_mode) === "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                        <Button variant="contained" className="bton_annule" onClick={Annule_Ref_Ped_DetailFields}>Annuler
                                        </Button>
                                    </div>}
                                </div>


                                {String(config_type_eval_edit_mode) !== "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>

                                    <Button variant="contained" className="bton_edit" onClick={(event) => {
                                        Enable_Config_Type_Eval_DetailFields();
                                    }} >Editer
                                    </Button>

                                </div>}
                                <div className="div_row" style={{ "border": "None" }}>
                                    &nbsp;
                                </div>
                            </div>

                        </div>
                        }

                        {add_config_type_eval && String(display_detail_type_eval) !== "1" && String(add_config_type_eval) === "1" && <div className="div_row">

                            <div>

                                <div className="session_caract"> Code <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_code"
                                        id="detail_config_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_config_code}
                                        onChange={(e) => {
                                            setp_one_detail_config_code(e.target.value);

                                        }}

                                    />

                                </div>



                                <div className="session_caract"> Nom <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_nom"
                                        id="detail_config_nom"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_config_nom}
                                        onChange={(e) => {
                                            setp_one_detail_config_nom(e.target.value);

                                        }}

                                    />

                                </div>

                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_config_desc"
                                        id="detail_config_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_config_description}
                                        onChange={(e) => {
                                            setp_one_detail_config_description(e.target.value);

                                        }}
                                    />

                                </div>

                                <div>
                                    <div className="div_row" style={{ "border": "None" }}>
                                        &nbsp;
                                    </div>

                                    <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                                        <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                            <Button variant="contained" className="bton_enreg" onClick={Add_Config_Type_Eval}>Enregistrer les modifications
                                            </Button>

                                        </div>

                                        <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                            <Button variant="contained" className="bton_annule" onClick={Annule_Add_Type_Eval_DetailFields}>Annuler
                                            </Button>
                                        </div>
                                    </div>


                                    <div className="div_row" style={{ "border": "None" }}>
                                        &nbsp;
                                    </div>
                                </div>

                            </div>

                        </div>}
                    </div>
                </div>}


                {/*** Implementation des differents modes de calcul de moyenne finale d'une apprenant pour une matière  */}
                {String(submenu) === "calcul_note_finale" && <div className="div_row" style={{ paddingRight: '10px' }}>
                    <div className="div_row" style={{ fontFamily: 'DM Sans' }}>
                        Configuration des modes de calcul de la note finale d'une matière pour un apprenant <br />
                    </div>

                    <div className="div_row" style={{ fontFamily: 'DM Sans' }}>
                        Règle 1 : <br />
                        Description : <br />
                        ( (Moyenne Art. (TD) + Moyenne Art(TP) * 2)/3 + Exemen Final ) / 2
                    </div>

                    <div className="div_row" style={{ fontFamily: 'DM Sans' }}>
                        Règle 2 : <br />
                        Description : <br />
                        ( Note Stage + Exemen Final ) / 2
                    </div>

                    <div className="div_row" style={{ fontFamily: 'DM Sans' }}>
                        Règle 3 : <br />
                        Description : <br />
                        (Moyenne Art.(TD) + Moyenne Art.(Controle Continue) + Exemen Final*1.5 ) / 3
                    </div>




                </div>}

                {/*** référentiel pédagogique  */}
                {String(submenu) === "referentiel_padagogique" && <div className="div_row" style={{ paddingRight: '10px' }}>

                    <div>
                        <div className="div_row" style={{ paddingRight: '10px' }}>
                            <div className="session_data">
                                <div style={{ "border": "None" }}>
                                    <div style={{ height: 550, width: '100%', paddingRight: '5px' }}>
                                        &nbsp;
                                        <Box
                                            sx={{
                                                height: 500,
                                                width: '100%',
                                                paddingRight: '1px',

                                                // Gestion des cellule "statut"
                                                '& .cell--status--encours': {
                                                    backgroundColor: '#E6F7C8',
                                                    color: '#1a3e72',
                                                    fontWeight: 'light',
                                                },
                                                '& .cell--status--traite': {
                                                    backgroundColor: '#E6CEAA',
                                                    color: '#F9E79F',
                                                    fontWeight: 'light',
                                                },

                                                "& .MuiDataGrid-columnHeaders": {
                                                    backgroundColor: "#c8cfd5",
                                                    color: "black",
                                                    fontSize: 14
                                                },

                                                '& .line--statut--selected': {
                                                    backgroundColor: '#FBF2EF',
                                                    color: 'black',
                                                },
                                                '& .line--statut--pair': {
                                                    backgroundColor: 'rgba(235, 235, 235, .7)',
                                                    color: 'black',
                                                },
                                                '& .line--statut--impair': {
                                                    backgroundColor: '#FFFFFF',
                                                    color: 'black',
                                                },

                                            }}
                                        >
                                            <DataGrid
                                                disableSelectionOnClick
                                                // checkboxSelection
                                                onSelectionModelChange={(newSelectionModel) => {
                                                    setselectionModel_type_eval(newSelectionModel);
                                                    /*if (newSelectionModel.length === 1)
                                                        handleClick_edit_config_From_Line(newSelectionModel);*/
                                                    if (newSelectionModel.length !== 1) {
                                                        setp_detail_ref_ped_code("");
                                                        setp_detail_ref_ped_commentaire("");
                                                        setp_detail_ref_ped_description("");
                                                        setref_ped_edit_mode("");
                                                        setref_ped_changed("");


                                                    }
                                                }}
                                                selectionModel={selectionModel_referentiel_padagogique}

                                                localeText={frFR.components.MuiDataGrid.defaultProps.localeText}
                                                rows={Getall_Parter_referentiel_padagogique_result.map((item, index) => (
                                                    {
                                                        id: index,
                                                        _id: JSON.parse(item)._id,
                                                        code: JSON.parse(item).code,
                                                        commentaire: JSON.parse(item).commentaire,
                                                        description: JSON.parse(item).description,
                                                    }
                                                ))}

                                                columns={columns_referentiel_padagogique}
                                                pageSize={10}
                                                className="datagridclass"

                                                onRowDoubleClick={(newSelectionModel) => {
                                                    setgridline_ref_ped_id(newSelectionModel.row.id);
                                                    setp_detail_ref_ped_code(newSelectionModel.row.code);
                                                    setp_detail_ref_ped_commentaire(newSelectionModel.row.commentaire);
                                                    setp_detail_ref_ped_description(newSelectionModel.row.description);
                                                    setselected_ref_ped_id(newSelectionModel.row._id);

                                                    setadd_config_ref_ped("");
                                                    setdisplay_detail_ref_ped("1");
                                                    setref_ped_edit_mode("");
                                                    setref_ped_changed("");

                                                    Disable_Config_Red_Ped_DetailFields();

                                                    //handleClick_edit_config_From_Line(newSelectionModel.row.id);

                                                }}


                                                rowsPerPageOptions={[10]}
                                                //disableSelectionOnClick
                                                components={{
                                                    Toolbar: GridToolbar,
                                                }}
                                                //sx={datagridSx}
                                                getCellClassName={(params) => {



                                                }}
                                                getRowClassName={(params) => {


                                                    // Pour la gestion de la couleur de zone double cliquée
                                                    if (String(params.row.id) === String(gridline_type_eval_id)) {
                                                        return 'line--statut--selected';
                                                    }
                                                    else if (parseInt(String(params.row.id)) % 2 === 0) {
                                                        return 'line--statut--pair';
                                                    }
                                                    else if (parseInt(String(params.row.id)) % 2 !== 0) {
                                                        return 'line--statut--impair';
                                                    }
                                                }}


                                            />
                                        </Box>
                                        <br />

                                    </div>

                                </div>

                            </div>
                            <div className="div_row" style={{ "border": "None" }}>

                                <div className="div_row_gauche div_row_gauche_etendu" style={{ "textAlign": "left", "paddingLeft": "5px" }}>
                                    <Button variant="outlined" onClick={add_ref_ped}
                                        className="detail_class_submenu bton_add_session"
                                        id='menu_import_participant' name='menu_import_participant'>Ajout 1 Réf. Ped.  &nbsp;
                                        <IoAddCircleOutline style={{ "fontSize": "x-large", "color": "green" }} />
                                    </Button>
                                </div>
                            </div>
                            <div className="div_row" ref={myRef} id="myRef"> &nbsp;</div>
                        </div>


                        {display_detail_ref_ped && String(display_detail_ref_ped) === "1" && String(add_config_ref_ped) !== "1" && <div className="div_row">

                            {String(ref_ped_edit_mode) !== "1" && <div>

                                <div className="session_caract"> Code <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_code"
                                        id="detail_ref_ped_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_code}

                                    />

                                </div>


                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_desc"
                                        id="detail_ref_ped_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_description}

                                    />

                                </div>

                                <div className="session_caract"> Commentaire <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_comment"
                                        id="detail_ref_ped_comment"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_commentaire}

                                    />

                                </div>



                            </div>}


                            {String(ref_ped_edit_mode) === "1" && <div>

                                <div className="session_caract"> Code <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_code"
                                        id="detail_ref_ped_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_code}
                                        onChange={(e) => {
                                            setp_detail_ref_ped_code(e.target.value);
                                            setref_ped_changed("1");
                                        }}

                                    />

                                </div>





                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_desc"
                                        id="detail_ref_ped_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_description}
                                        onChange={(e) => {
                                            setp_detail_ref_ped_description(e.target.value);
                                            setref_ped_changed("1");
                                        }}
                                    />

                                </div>

                                <div className="session_caract"> Commentaire <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_comment"
                                        id="detail_ref_ped_comment"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_detail_ref_ped_commentaire}
                                        onChange={(e) => {
                                            setp_detail_ref_ped_commentaire(e.target.value);
                                            setref_ped_changed("1");
                                        }}

                                    />

                                </div>

                            </div>}



                            <div>
                                <div className="div_row" style={{ "border": "None" }}>
                                    &nbsp;
                                </div>
                                {String(ref_ped_changed) === "1" && String(ref_ped_edit_mode) === "1" && <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>
                                    /!\ Pensez à enregistrer les modifications
                                </div>}
                                <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                                    {String(ref_ped_edit_mode) === "1" && String(ref_ped_changed) === "1" && <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                        <Button variant="contained" className="bton_enreg" onClick={Update_Config_Ref_Ped}>Enregistrer les modifications
                                        </Button>

                                    </div>}

                                    {String(ref_ped_edit_mode) === "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                        <Button variant="contained" className="bton_annule" onClick={Annule_Ref_Ped_DetailFields}>Annuler
                                        </Button>
                                    </div>}
                                </div>


                                {String(ref_ped_edit_mode) !== "1" && <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }}>

                                    <Button variant="contained" className="bton_edit" onClick={(event) => {
                                        Enable_Config_Ref_Ped_DetailFields();
                                    }} >Editer
                                    </Button>

                                </div>}
                                <div className="div_row" style={{ "border": "None" }}>
                                    &nbsp;
                                </div>
                            </div>

                        </div>
                        }

                        {add_config_ref_ped && String(display_detail_ref_ped) !== "1" && String(add_config_ref_ped) === "1" && <div className="div_row">

                            <div>

                                <div className="session_caract"> Code  <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_code"
                                        id="detail_ref_ped_code"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_ref_ped_code}
                                        onChange={(e) => {
                                            setp_one_detail_ref_ped_code(e.target.value);

                                        }}

                                    />

                                </div>


                                <div className="session_caract"> Description <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_desc"
                                        id="detail_ref_ped_desc"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_ref_ped_description}
                                        onChange={(e) => {
                                            setp_one_detail_ref_ped_description(e.target.value);

                                        }}
                                    />

                                </div>

                                <div className="session_caract"> Commentaire <br />
                                    <TextField
                                        sx={{ '& legend': { display: 'none' }, '& fieldset': { top: 0 }, }}
                                        required
                                        name="detail_ref_ped_comment"
                                        id="detail_ref_ped_comment"

                                        InputLabelProps={{
                                            shrink: true,
                                        }}
                                        disabled={false}
                                        className="disabled_style"
                                        value={p_one_detail_ref_ped_commentaire}
                                        onChange={(e) => {
                                            setp_one_detail_ref_ped_commentaire(e.target.value);

                                        }}

                                    />

                                </div>


                                <div>
                                    <div className="div_row" style={{ "border": "None" }}>
                                        &nbsp;
                                    </div>

                                    <div className="div_row" style={{ "border": "None", "color": "orange", "textAlign": "center" }}>

                                        <div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>

                                            <Button variant="contained" className="bton_enreg" onClick={Add_Config_Ref_Ped}>Enregistrer les modifications
                                            </Button>

                                        </div>

                                        <div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
                                            <Button variant="contained" className="bton_annule" onClick={Annule_Add_Ref_Ped_DetailFields}>Annuler
                                            </Button>
                                        </div>
                                    </div>


                                    <div className="div_row" style={{ "border": "None" }}>
                                        &nbsp;
                                    </div>
                                </div>

                            </div>

                        </div>}
                    </div>
                </div>}


            </div>


        </div>
    )
}


export default Partner_Config_Ftion_Initiale;
