Subversion Repositories SmartDukaan

Rev

Rev 34671 | Rev 35340 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

$(function () {
    $(document).on('click', ".trial_users", function () {
        loadPendingTrialForms("main-content");
    });

    $(document).on('click', ".mk_trial_create", function () {
        let trialFormId = $(this.closest('tr')).data('id');
    });

    $(document).on('click', ".mk_trial_cancel", function () {
        let trialFormId = $(this.closest('tr')).data('id');
        cancelTrialForm(trialFormId);
    });

    function loadPendingTrialForms(domId) {
        doGetAjaxRequestHandler(context + "/trial/pending", function (response) {
            $('#' + domId).html(response);
        });
    }

    function trialCreate(trialFormId) {
        doAjaxRequestHandler(`${context}/trial/create/${trialFormId}`, "GET", function (response) {
            $('#main-content').html(response);
        });
    }

    function cancelTrialForm(trialFormId) {
        if (confirm("Are you sure you want to cancel this trial?")) {
            doGetAjaxRequestHandler(`${context}/trial/cancel/${trialFormId}`, function (response) {
                if (response == "true") {
                    loadPendingTrialForms("main-content");
                }
            });
        }
    }
});