kusowl 94ef8f360d feature (favorite and reported deals):
- add favorites and reported tabs in user profile pages
- add remove favorites
- customers can view a deal directly from profiles section and deal modal is shown in explore page
- fix formatting by pint
2026-01-23 16:14:04 +05:30

33 lines
1.3 KiB
JavaScript

export function initTabs() {
try {
const tabs = document.querySelectorAll('.tabs');
tabs.forEach(tab => {
const tabBtns = tab.querySelectorAll('.tab-btn');
tabBtns.forEach(tabBtn =>
tabBtn.addEventListener('click', (e) => {
// Make the current button active
tabBtns.forEach(btn => btn.classList.remove('bg-white'));
tabBtn.classList.add('bg-white');
// Hide all other tabs
const tabContents = tab.querySelectorAll('.tab-content');
tabContents.forEach(content => content.removeAttribute('data-show'));
// Show the target tab
const targetContent = tabBtn.dataset.target;
if (targetContent) {
const contentTabData = `[data-tab="${targetContent}"]`;
const tabContent = tab.querySelector(contentTabData);
if (tabContent) {
tabContent.setAttribute('data-show', '')
}
}
}
)
);
})
} catch (e) {
console.error(e)
}
}