﻿<div x-data="{ open: {{ request()->routeIs('companies.*') || request()->routeIs('branches.*') ? 'true' : 'false' }} }" class="mb-1">
    @permission('companies.view')
    <button @click="open = !open" class="group flex items-center p-3 py-2 text-base font-medium rounded-md
        {{ request()->routeIs('companies.*') || request()->routeIs('branches.*') ? 'bg-red-100 text-red-800' : 'text-gray-700 hover:bg-red-50 hover:text-red-800' }}">
        <svg xxmlns="http://www.w3.org/2000/svg" class="ml-3 flex-shrink-0 h-6 w-6
            {{ request()->routeIs('companies.*') || request()->routeIs('branches.*') ? 'text-red-700' : 'text-gray-500 group-hover:text-red-700' }}"
            fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
        </svg>
        <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Companies and Branches', __('Companies and Branches')) }}</span>
        <svg :class="{'rotate-180': open, 'rotate-0': !open}" class="mr-auto h-5 w-5 transform transition-transform duration-200"
            xxmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
            <path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
        </svg>
    </button>
    <div x-show="open" x-transition class="pr-4 mr-4 border-r border-gray-200">
        @permission('companies.view')
        <a href="{{ route('companies.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('companies.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('companies.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Companies List', __('Companies List')) }}</span>
        </a>
        @endpermission

        @permission('companies.create')
        <a href="{{ route('companies.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('companies.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('companies.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Company', __('Add New Company')) }}</span>
        </a>
        @endpermission

        @permission('branches.view')
        <a href="{{ route('branches.index') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('branches.index') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('branches.index') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Branches List', __('Branches List')) }}</span>
        </a>
        @endpermission

        @permission('branches.create')
        <a href="{{ route('branches.create') }}" class="group flex items-center p-3 py-2 text-sm font-medium rounded-md
            {{ request()->routeIs('branches.create') ? 'text-red-800' : 'text-gray-700 hover:text-red-800' }}">
            <span class="ml-2 w-1 h-1 rounded-full {{ request()->routeIs('branches.create') ? 'bg-red-600' : 'bg-gray-500' }}"></span>
            <span>{{ \App\Helpers\TranslationHelper::transFromDatabase('Add New Branch', __('Add New Branch')) }}</span>
        </a>
        @endpermission
    </div>
    @endpermission
</div>
