@extends('admin.layouts.layout')

@section('container_content')

    <section class="sky-dashboard">
        <div class="dashboard">
            @include('admin.layouts.menu')

            <div class="dashboard-body">

                @include('admin.layouts.navbar')

                <div id="errors">
                    @if(count($errors))
                        <div class="alert alert-danger">
                            @foreach($errors->all() as $error)
                                <li>
                                    {{$error}}
                                </li>
                            @endforeach
                        </div>
                    @endif
                </div>

                @if (session('message'))
                    <div class="alert alert-success message_alert">{{session('message')}}</div>
                @endif

                @if (session('error_message'))
                    <div class="alert alert-danger message_alert">{{session('error_message')}}</div>
                @endif

                <div class="alert alert-danger ajaxErrorResponse" style="display: none"></div>
                <div class="alert alert-success ajaxResponse" style="display: none"></div>

                @yield('content')
            </div>
        </div>
    </section>

    <footer class="">
        <div class="loading hide">
            <div class="loader"></div>
        </div>
    </footer>
@endsection

@section('container_js')
    {{--    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>--}}
    <script src="{{ asset('assets/admin/js/lib/axios.min.js') }}"></script>

    <script>
        axios.defaults.headers.common = {
            'X-Requested-With': 'XMLHttpRequest',
            'X-CSRF-TOKEN' : document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        };
        var allOptionLabel= '{{ __("main.all") }}'
        var mainOptionLabel= '{{ __("main.main") }}'

    </script>
    <script>
        function SearchModules()
        {
            let title = $('#searchModules').val();
            $.ajax({
                url : "{{route('dashboard.modules')}}",
                type : 'GET',
                data : 'title='+title,
                success:function(data)
                {
                    $('#modules').html(data);
                }
            })
        }
        SearchModules()
    </script>
    
    @yield('inner_js')
    <script src="{{ asset('assets/admin/js/actions.js') }}"></script>

@endsection
