<?php

namespace App\View\Page;

use Livewire\Component;

class Sidebar extends Component
{

    public $mobile = false;

    public function render()
    {
        return <<<'HTML'
        <div
            class="fixed z-40 bg-gray-800 p-6 w-60 top-0 h-screen border-r border-gray-600 border-solid flex flex-col justify-between duration-300
                @if (!$mobile) left-[-16rem] navbar:left-0 @endif"
            @if($mobile)
                x-data="{ visible: false }"
                x-on:toggle-sidebar.window="visible = true"
                :class="{'left-[-16rem]' : !visible, 'left-0': visible}"
            @endif
        >
            <div class="grid gap-2">
                <x-page::menu-entry href="/" menu="dashboard" icon="loss">Dashboard</x-page::menu-entry>
                <x-page::menu-entry href="/member" menu="member" icon="user">Mitglieder</x-page::menu-entry>
                <x-page::menu-entry v-show="hasModule('bill')" href="/subscription" menu="subscription" icon="money">Beiträge</x-page::menu-entry>
                <x-page::menu-entry v-show="hasModule('bill')" href="/invoice" menu="invoice" icon="moneypaper">Rechnungen</x-page::menu-entry>
                <x-page::menu-entry href="/contribution" menu="contribution" icon="contribution">Zuschüsse</x-page::menu-entry>
                <x-page::menu-entry href="/activity" menu="activity" icon="activity">Tätigkeiten</x-page::menu-entry>
                <x-page::menu-entry href="/group" menu="group" icon="group">Gruppierungen</x-page::menu-entry>
                <x-page::menu-entry v-if="hasModule('event')" href="/form" menu="form" icon="event">Veranstaltungen</x-page::menu-entry>
                <x-page::menu-entry href="/maildispatcher" menu="maildispatcher" icon="at">Mail-Verteiler</x-page::menu-entry>
            </div>
            <div class="grid gap-2">
                <a href="#" class="flex w-full px-3 py-2 rounded-xl text-gray-300 bg-gray-700" @click.prevent="dispatch('show-search')">
                    <x-ui::sprite class="text-white w-6 h-6 mr-4" src="search"></x-ui::sprite>
                    <div class="">Suchen</div>
                </a>
                <x-page::menu-entry href="/setting" menu="setting" icon="setting">Einstellungen</x-page::menu-entry>
                <x-page::menu-entry href="/logout" menu="" icon="logout">Abmelden</x-page::menu-entry>
            </div>
            @if($mobile)
            <a href="#" class="absolute right-0 top-0 mr-2 mt-2" @click.prevent="visible = false">
                <x-ui::sprite src="close" class="w-5 h-5 text-gray-300"></x-ui::sprite>
            </a>
            @endif
        </div>
        HTML;
    }
}
