@extends('layout')

@section('content')
<main class="container mx-auto px-5">
    <h1 class="text-4xl font-bold text-center my-4">Ваши заявки</h1>
    <article>
        @if($applications->isNotEmpty())
        <ul class="grid xl:grid-cols-5 lg:grid-cols-3 md:grid-cols-2 grid-cols-1 gap-6 xl:mb-72 lg:mb-64 md:mb-32">
            @foreach($applications as $app)
            <li class="p-5 rounded-xl border-2 border-indigo-800 flex flex-col gap-5">
                <article class="flex flex-col">
                    <p class="text-sm text-gray-400">Курс</p>
                    <p class="text-xl font-medium text-indigo-800">{{ $app->course_name }}</p>
                </article>
                <article class="flex flex-col">
                    <p class="text-sm text-gray-400">Дата</p>
                    <p class="">{{ $app->date }}</p>
                </article>
                <article class="flex flex-col">
                    <p class="text-sm text-gray-400">Статус заявки</p>
                    @if($app->status == 'new')
                    <p class="">Новая</p>
                    @elseif($app->status == 'continue')
                    <p class="">Продолжается</p>
                    @else
                    <p class="">Закончено</p>
                    @endif
                </article>
                @if($app->status == 'end' && $app->review == '')
                <form action="{{ route('apps.review', $app->id) }}" method="POST">
                    @csrf
                    <textarea class="w-full border border-gray-300 rounded-xl p-3" name="review" id="" placeholder="Напишите отзыв"></textarea>
                    <button class="py-2 px-2 rounded-xl bg-green-500 text-white font-semibold">Отправить</button>
                </form>
                @endif
                @if($app->review)
                <article class="flex flex-col">
                    <p class="text-sm text-gray-400">Ваш отзыв:</p>
                    <p>"{{ $app->review }}"</p>
                </article>
                @endif
            </li>

            @endforeach
        </ul>
        @else
            <p class='text-center italic md:text-xl text-base xl:mt-48 lg:mt-32 md:mt-24 mt-6 mb-96'>У вас нет никакой заявки на обучение!</p>
        @endif
    </article>
</main>
@endsection