@extends('admin.layouts.app')
@section('panel')
    <div class="row">

        <div class="col-lg-12">
            <div class="show-filter mb-3 text-end">
                <button type="button" class="btn btn-outline--primary showFilterBtn btn-sm"><i class="las la-filter"></i>
                    @lang('Filter')</button>
            </div>
            <div class="card responsive-filter-card mb-4">
                <div class="card-body">
                    <form action="">
                        <div class="d-flex flex-wrap gap-4">
                            <div class="flex-grow-1">
                                <label>@lang('Name/Username/email')</label>
                                <input type="text" name="search" value="{{ request()->search }}" class="form-control">
                            </div>

                            <div class="flex-grow-1 align-self-end">
                                <button class="btn btn--primary w-100 h-45"><i class="fas fa-filter"></i>
                                    @lang('Filter')</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

            <div class="card b-radius--10 ">
                <div class="card-body p-0">
                    <div class="table-responsive--md  table-responsive">
                        <table class="table table--light style--two">
                            <thead>
                                <tr>
                                    <th>@lang('Name')</th>
                                    <th>@lang('Username')</th>
                                    <th>@lang('Email')</th>
                                    <th>@lang('Mobile')</th>
                                    <th>@lang('Date Of Joining')</th>
                                    <th>@lang('Roles')</th>
                                    <th>@lang('Action')</th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($users as $user)
                                    <tr>
                                        <td>
                                            <div class="d-flex align-items-center">
                                                <div class="avatar avatar--md">
                                                    <img src="{{ getImage(getFilePath('adminProfile') . '/' . $user->image, getFileSize('adminProfile')) }}"
                                                        alt="@lang('Image')">
                                                </div>
                                                <span class="d-inline-block ms-2"> {{ $user->name }}</span>
                                            </div>
                                        </td>
                                        <td>{{ $user->username }}</td>
                                        <td>{{ $user->email }}</td>
                                        <td>{{ $user->mobile }}</td>
                                        <td>{{ $user->created_at->format('d M Y') }}</td>

                                        <td>
                                            <div class="row gap-2 flex-wrap" style="max-width: 200px;">
                                                @forelse($user->roles as $r)
                                                    <span>
                                                        <span class="badge badge--primary">{{ $r->name }}</span>
                                                    </span>
                                                @empty
                                                    --
                                                @endforelse
                                            </div>
                                        </td>

                                        <td>
                                            <button
                                                data-action="{{ route('admin.access.employees.create-edit', $user->id) }}"
                                                data-title="@lang('Edit Employee '): {{ $user->username }} "
                                                class="btn btn-sm btn-outline--primary formModalBtn">
                                                <i class="las la-edit text--shadow"></i> @lang('Edit')
                                            </button>

                                            <button
                                                data-action="{{ route('admin.access.employees.edit-role', $user->id) }}"
                                                data-title="@lang('Edit Roles of'): {{ $user->username }} "
                                                class="btn btn-sm btn-outline--primary formModalBtn">
                                                <i class="las la-desktop text--shadow"></i> @lang('Roles')
                                            </button>

                                            @if ($user->status == Status::USER_ACTIVE)
                                                <button
                                                    data-action="{{ route('admin.access.employees.ban', $user->id) }}"
                                                    data-title="@lang('Ban User '): {{ $user->username }} "
                                                    data-question="@lang('Are you sure you want to ban this user?')"
                                                    data-values="{{ json_encode(['status' => Status::USER_BAN]) }}"
                                                    class="btn btn-sm btn-outline--danger confirmationBtn">
                                                    <i class="las la-ban text--shadow"></i> @lang('Ban')
                                                </button>
                                            @else
                                                <button
                                                    data-action="{{ route('admin.access.employees.ban', $user->id) }}"
                                                    data-title="@lang('Unban User '): {{ $user->username }} "
                                                    data-question="@lang('Are you sure you want to unban this user?')"
                                                    data-values="{{ json_encode(['status' => Status::USER_ACTIVE]) }}"
                                                    class="btn btn-sm btn-outline--success confirmationBtn">
                                                    <i class="las la-undo text--shadow"></i> @lang('Unban')
                                                </button>
                                            @endif
                                        </td>

                                    </tr>
                                @empty
                                    <tr>
                                        <td class="text-muted text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                    </tr>
                                @endforelse

                            </tbody>
                        </table>
                    </div>
                </div>
                @if ($users->hasPages())
                    <div class="card-footer py-4">
                        {{ paginateLinks($users) }}
                    </div>
                @endif
            </div>
        </div>

        <x-form-modal />
        <x-confirmation-modal />
    </div>
@endsection



@push('breadcrumb-plugins')
    <button data-action="{{ route('admin.access.employees.create-edit') }}" data-title="@lang('Create Employee')"
        class="btn btn-sm btn-outline--primary formModalBtn"><i class="fas fa-plus"></i> Add
        Employee</button>
@endpush

@push('style-lib')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/vendor/datepicker.min.css') }}">
@endpush


@push('script-lib')
    <script src="{{ asset('assets/admin/js/vendor/datepicker.min.js') }}"></script>
    <script src="{{ asset('assets/admin/js/vendor/datepicker.en.js') }}"></script>
@endpush

@push('script')
@endpush
