feat: hooks for profile mandatory fields

This commit is contained in:
Jannat Patel
2021-12-20 14:18:22 +05:30
parent f8b0d9b180
commit ea06fe8cf8
4 changed files with 17 additions and 13 deletions

View File

@@ -11,14 +11,17 @@ const hide_profile_for_guest_users = () => {
};
const restrict_users_to_profile_page = () => {
if (frappe.session.user != "Guest") {
frappe.call({
"method": "school.lms.doctype.lms_settings.lms_settings.check_profile_restriction",
"callback": (data) => {
if (data.message && data.message.redirect) {
window.location.href = `${data.message.prefix}${data.message.username}`;
setTimeout(() => {
var link_array = $('.nav-link').filter((i, elem) => $(elem).text().trim() === "My Profile");
if (frappe.session.user != "Guest" && link_array.length && !$(link_array[0]).hasClass("active")) {
frappe.call({
"method": "school.lms.doctype.lms_settings.lms_settings.check_profile_restriction",
"callback": (data) => {
if (data.message && data.message.redirect) {
window.location.href = `${data.message.prefix}${data.message.username}`;
}
}
}
});
}
});
}
}, 10);
};