<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('User list') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 bg-white border-b border-gray-200">

                    <a href="{{ route('users.create')}}">
                        <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full">
                            <i class="fa fa-add pr-2"></i>{{__('Create user')}}
                        </button>
                    </a>

                    <div align="center" class="pt-4">
                        <table class="table table-sm border-b border-gray-200">
                            <tr class="border border-gray-200">
                                <th class="p-2 border border-gray-200">
                                    {{ __('User name')}}
                                </th>
                                <th class="p-2 border border-gray-200">
                                    {{ __('Name')}}
                                </th>
                                <th class="p-2 border border-gray-200">
                                    {{ __('Email')}}
                                </th>
                                <th class="p-2 border border-gray-200">
                                    {{ __('Actions')}}
                                </th>
                            </tr>
                            @foreach ( $users as $user)
                            <tr class="border border-gray-200">
                                <td class="p-2 border border-gray-200">{{ $user->username }}</td>
                                <td class="p-2 border border-gray-200">{{ $user->name }}</td>
                                <td class="p-2 border border-gray-200">{{ $user->email }}</td>
                                <td class="p-2 border border-gray-200">
                                    <div class="text-center">
                                        <a href="{{ route('users.show',$user->id) }}">
                                            <i class="fa fa-eye text-green-500 hover:text-green-700 px-2 text-lg"></i>
                                        </a>
                                        <a href="{{ route('users.edit',$user->id) }}">
                                            <i class="fa fa-edit text-blue-500 hover:text-blue-700 px-2 text-lg"></i>
                                        </a>
                                        <!-- <a href="{{ route('users.destroy',$user->id) }}">
                                            <i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
                                        </a> -->
                                        @if ($user->id > 1)
                                        <form class="inline-block" action="{{ route('users.destroy', $user->id) }}" method="POST" onsubmit="return confirm('{{ __('Are you sure remove user ').$user->name.'?' }}');">
                                            <input type="hidden" name="_method" value="DELETE">
                                            <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                            <button type="submit">
                                                <i class="fa fa-trash text-red-500 hover:text-red-700 px-2 text-lg"></i>
                                            </button>
                                        </form>
                                        @endif
                                    </div>
                                </td>
                            </tr>
                            @endforeach
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</x-app-layout>