---
import MemberManagement from "./MemberManagement.astro";
import EventManagement from "./EventManagement.astro";
---

<div id="officerContent" class="hidden">
    <div class="tabs tabs-boxed mb-6" id="officerViewTabs">
        <button class="tab tab-active" data-officer-tab="members"
            >Member Management</button
        >
        <button class="tab" data-officer-tab="events">Event Management</button>
    </div>

    <div class="tab-contents">
        <div id="officerMembersTab" style="display: block;">
            <MemberManagement />
        </div>
        <div id="officerEventsTab" style="display: none;">
            <EventManagement />
        </div>
    </div>
</div>

<script>
    const officerTabs = document.querySelectorAll("[data-officer-tab]");
    const officerMembersTab = document.getElementById("officerMembersTab");
    const officerEventsTab = document.getElementById("officerEventsTab");

    if (officerTabs && officerMembersTab && officerEventsTab) {
        officerTabs.forEach((tab) => {
            tab.addEventListener("click", () => {
                // Update tab styles
                officerTabs.forEach((t) => t.classList.remove("tab-active"));
                tab.classList.add("tab-active");

                // Update content visibility
                const tabId = (tab as HTMLElement).dataset.officerTab;
                if (tabId === "members") {
                    officerMembersTab.style.display = "block";
                    officerEventsTab.style.display = "none";
                } else {
                    officerMembersTab.style.display = "none";
                    officerEventsTab.style.display = "block";
                }
            });
        });
    }
</script>
