var MenuUserForm = function(){};

/***
 * Init the form
 * @returns {undefined}
 */
MenuUserForm.Init = function(){
    Event.AddById("btnSaveMenu", "click", MenuUserForm.SaveElement);
};

/***
* Get the Id of element 
*/
MenuUserForm.GetId = function(){
    return Form.GetId("MenuUserFormForm");
};

/*
* Save the Element
*/
MenuUserForm.SaveElement = function(e){
   
    if(Form.IsValid("MenuUserFormForm"))
    {
    let request = new Http("EeApp", "SaveMenu");
        request.SetData(Form.Serialize("MenuUserFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

            if(data.status == "error"){
                Form.RenderError("MenuUserFormForm", data.data.message);
            } else{

               EeAppAction.LoadMenuUser();
               Dialog.Close();
            }
        });
    }
};

