[FIX] EMPLOYEE: Fix delayed section switch and incorrect state persistence in profile navigation

This commit is contained in:
Horilla
2026-01-07 13:40:09 +05:30
parent 68c37db0c8
commit 4d2c7d5116

View File

@@ -41,18 +41,28 @@
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$('#id_profile').change(function (e) {
const file = this.files[0];
const reader = new FileReader();
reader.addEventListener("load", function () {
const imageUrl = reader.result;
$(".preview").attr("src", imageUrl);
});
reader.readAsDataURL(file);
});
// Active tab script // Active tab script
function activeEmpprofileTab() { function activeEmpTab() {
var activeTab = localStorage.getItem("activeEmpprofileTab") var activeTab = localStorage.getItem("activeEmpTab")
if (!["#personal", "#bank"].includes(activeTab)) { if (!["#personal", "#work", "#bank"].includes(activeTab)) {
activeTab = "#personal"; activeTab = "#personal";
} }
if (!$(activeTab).length && $(`[data-target="#personal"]`).length) { if (activeTab != null) {
$(`[data-target="#personal"]`)[0].click()
}else if(activeTab != null){
$(".oh-general__tab-link--active").removeClass("oh-general__tab-link--active"); $(".oh-general__tab-link--active").removeClass("oh-general__tab-link--active");
$(`[data-target='${activeTab}']`).addClass("oh-general__tab-link--active"); $(`[data-target='${activeTab}']`).addClass("oh-general__tab-link--active");
$(".oh-general__tab-target").addClass("d-none"); $(".oh-general__tab-target").addClass("d-none");
@@ -62,15 +72,15 @@
} }
} }
} }
activeEmpprofileTab() activeEmpTab()
$("[data-action=general-tab]").on("click", function (e) { $("[data-action=general-tab]").on("click", function (e) {
e.preventDefault(); e.preventDefault();
const targetId = $(this).attr('data-target'); const targetId = $(this).attr('data-target');
localStorage.setItem("activeEmpprofileTab",targetId) localStorage.setItem("activeEmpTab", targetId)
activeEmpTab()
}); });
}); });
</script> </script>
{% endblock content %} {% endblock content %}