@extends('layout')

@section('content')
<main class="container mx-auto px-5">
    <h1 class="text-4xl font-bold text-center my-4">Админ-панель</h1>
    <article class="overflow-x-scroll">
        @if($apps->isNotEmpty())
        <table class="w-full text-center xl:mb-64 lg:mb-48 mb-32">
            <thead>
                <tr>
                    <th class="border border-gray-300">№ заявки</th>
                    <th class="border border-gray-300">Логин</th>
                    <th class="border border-gray-300">Почта</th>
                    <th class="border border-gray-300">Телефон</th>
                    <th class="border border-gray-300">Название курса</th>
                    <th class="border border-gray-300">Дата</th>
                    <th class="border border-gray-300">Способ оплаты</th>
                    <th class="border border-gray-300">Изменить статус</th>
                    <th class="border border-gray-300">Отзыв</th>
                </tr>
            </thead>
            <tbody>
                @foreach($apps as $app)
                <tr class="">
                    <td class="border border-gray-300 py-3 px-2">{{ $app->id }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->user->login }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->user->email }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->user->phone }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->course_name }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->date }}</td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->payment }}</td>
                    <td class="border border-gray-300 py-3 px-2">
                        @if($app->status != 'end')
                        <form action="{{ route('admin.post', $app->id) }}" method="POST" class='flex gap-1'>
                            @csrf
                            <select name="status" id="" class="p-2 rounded-xl border border-gray-600">
                                <option value="new" @selected($app->status == 'new')>Новая</option>
                                <option value="continue" @selected($app->status == 'continue')>Обучение идет</option>
                                <option value="end">Обучение завершено</option>
                            </select>
                            <button class="py-1 px-3 rounded-xl bg-yellow-500 text-white">Изменить</button>
                        </form>
                        @else
                        Обучение завершено
                        @endif
                    </td>
                    <td class="border border-gray-300 py-3 px-2">{{ $app->review }}</td>
                </tr>
                @endforeach
            </tbody>
        </table>
        @else
        <p>Еще никто не поадвал заявку!</p>
        @endif
    </article>
</main>
@endsection