feat: validate razorpay data
This commit is contained in:
@@ -222,9 +222,9 @@
|
||||
</a>
|
||||
|
||||
{% elif course.paid_course %}
|
||||
<a class="btn btn-primary wide-button" id="buy-course">
|
||||
<div class="btn btn-primary wide-button" id="buy-course" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Buy This Course") }}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{% elif show_start_learing_cta(course, membership) %}
|
||||
<div class="btn btn-primary wide-button enroll-in-course" data-course="{{ course.name | urlencode }}">
|
||||
|
||||
@@ -21,24 +21,17 @@ frappe.ready(() => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
|
||||
$("#apply-certificate").click((e) => {
|
||||
apply_cetificate(e);
|
||||
});
|
||||
|
||||
$("#slot-date").on("change", (e) => {
|
||||
display_slots(e);
|
||||
});
|
||||
|
||||
$("#submit-slot").click((e) => {
|
||||
submit_slot(e);
|
||||
});
|
||||
|
||||
$(".close-slot-modal").click((e) => {
|
||||
close_slot_modal(e);
|
||||
});
|
||||
|
||||
$(document).on("click", ".slot", (e) => {
|
||||
select_slot(e);
|
||||
$("#buy-course").click((e) => {
|
||||
e.preventDefault();
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_course.lms_course.buy_course",
|
||||
args: {
|
||||
course: decodeURIComponent(
|
||||
$(e.currentTarget).attr("data-course")
|
||||
),
|
||||
},
|
||||
callback: (data) => {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -162,99 +155,3 @@ const submit_for_review = (e) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const apply_cetificate = (e) => {
|
||||
$("#slot-modal").modal("show");
|
||||
};
|
||||
|
||||
const submit_slot = (e) => {
|
||||
e.preventDefault();
|
||||
const slot = window.selected_slot;
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_certificate_request",
|
||||
args: {
|
||||
course: slot.data("course"),
|
||||
date: $("#slot-date").val(),
|
||||
day: slot.data("day"),
|
||||
start_time: slot.data("start"),
|
||||
end_time: slot.data("end"),
|
||||
},
|
||||
callback: (data) => {
|
||||
$("#slot-modal").modal("hide");
|
||||
frappe.show_alert(
|
||||
{
|
||||
message: __(
|
||||
"Your slot has been booked. Prepare well for the evaluations."
|
||||
),
|
||||
indicator: "green",
|
||||
},
|
||||
3
|
||||
);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 3000);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const display_slots = (e) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.course_evaluator.course_evaluator.get_schedule",
|
||||
args: {
|
||||
course: $(e.currentTarget).data("course"),
|
||||
date: $(e.currentTarget).val(),
|
||||
},
|
||||
callback: (data) => {
|
||||
let options = "";
|
||||
data.message.forEach((obj) => {
|
||||
options += `<button type="button" class="btn btn-sm btn-secondary mb-3 mr-3 slot hide"
|
||||
data-course="${$(e.currentTarget).data("course")}"
|
||||
data-day="${obj.day}" data-start="${
|
||||
obj.start_time
|
||||
}" data-end="${obj.end_time}">
|
||||
${format_time(obj.start_time)} - ${format_time(
|
||||
obj.end_time
|
||||
)}</button>`;
|
||||
});
|
||||
e.preventDefault();
|
||||
$("#slot-modal .slots").html(options);
|
||||
const weekday = [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
];
|
||||
const day = weekday[new Date($(e.currentTarget).val()).getDay()];
|
||||
|
||||
$(".slot").addClass("hide");
|
||||
$(".slot-label").addClass("hide");
|
||||
|
||||
if ($(`[data-day='${day}']`).length) {
|
||||
$(".slot-label").removeClass("hide");
|
||||
$(`[data-day='${day}']`).removeClass("hide");
|
||||
$("#no-slots-message").addClass("hide");
|
||||
} else {
|
||||
$("#no-slots-message").removeClass("hide");
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const select_slot = (e) => {
|
||||
$(".slot").removeClass("btn-outline-primary");
|
||||
$(e.currentTarget).addClass("btn-outline-primary");
|
||||
window.selected_slot = $(e.currentTarget);
|
||||
};
|
||||
|
||||
const format_time = (time) => {
|
||||
let date = moment(new Date()).format("ddd MMM DD YYYY");
|
||||
return moment(`${date} ${time}`).format("HH:mm a");
|
||||
};
|
||||
|
||||
const close_slot_modal = (e) => {
|
||||
$("#slot-date").val("");
|
||||
$(".slot-label").addClass("hide");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user