var NotifyPushForm = function(){};

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

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

/*
* Save the Element
*/
NotifyPushForm.SaveElement = function(e){
   
    if(Form.IsValid("NotifyPushFormForm"))
    {
    let request = new Http("Notify", "SavePush");
        request.SetData(Form.Serialize("NotifyPushFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

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

                Notify.ReloadPush(data);
                Dialog.Close();
            }
        });
    }
};

