var RewardUserForm = function(){};

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

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

/*
* Save the Element
*/
RewardUserForm.SaveElement = function(e){
   
    if(Form.IsValid("RewardUserFormForm"))
    {
    let request = new Http("Reward", "SaveUserResponse");
        request.SetData(Form.Serialize("RewardUserFormForm"));

        request.Post(data => {

            data = JSON.parse(data);

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

                Dialog.Close();
                Animation.Notify(Language.GetCode("Reward.ResponseUserRecevied"));

            }
        });
    }
};

