<html>

<x-head />

<body>
    <!--[if lte IE 9]>
            <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience and security.</p>
        <![endif]-->

    <!-- header-start -->
    <x-header />

    <!-- header-end -->

    <!-- bradcam_area  -->
    <!-- bradcam_area  -->
    <div class="bradcam_area bradcam_bg_1">
        <div class="container">
            <div class="row">
                <div class="col-xl-12">
                    <div class="bradcam_text">
                        <h3>{{$job->name}}</h3>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--/ bradcam_area  -->

    <div class="job_details_area">
        <div class="container">
            <div class="row">
                <div class="col-lg-8">
                    <div class="job_details_header">
                        <div class="single_jobs white-bg d-flex justify-content-between">
                            <div class="jobs_left d-flex align-items-center">
                                <div class="thumb">
                                    <img src="public/{{ $job->icon }}" alt="">
                                </div>
                                <div class="jobs_conetent">
                                    <a href="#">
                                        <h4>{{$job->name}}</h4>
                                    </a>
                                    <div class="links_locat d-flex align-items-center">
                                        <div class="location">
                                            <p> <i class="fa fa-map-marker"></i>{{$job->city->name}}</p>
                                        </div>
                                        <div class="location">
                                            <p> <i class="fa fa-clock-o"></i>{{ $job->jobnature }}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="jobs_right" style="text-align: right;">
                                <div class="apply_now">
                                    <div class="thumb">
                                        <img src="public/{{ $job->user->avatar }}" alt="">
                                    </div>
                                    <p>Работодатель: {{$job->user->name}}</p>
                                    <p>Почта: {{$job->user->email}}</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="descript_wrap white-bg">
                        <div class="single_wrap">
                            <h4>Описание</h4>
                            <p>{{ $job->description }}</p>
                        </div>
                    </div>

                    @if(Auth::user() && Auth::user()->role != "user")
                    <div class="apply_job_form white-bg">
                        <h3>Отклики на вакансию</h3>
                        @foreach($apply as $ap)
                        <div class="card mt-3 ">
                            <div class="card-body">
                                <div class="row">
                                    <div class="col-md-10">
                                        <p class="card-text">Имя: <a href="{{Route('user', $ap->user->id)}}" target="_blank">{{$ap->user->name}}</a></p>
                                        <p class="card-text">Портфолио: <a href="//{{$ap->website}}" target="_blank">Посмотреть портфолио</a></p>
                                        <p class="card-text">Комментарий: {{$ap->resume}}</p>
                                        <p class="card-text">Дата отклика: {{$ap->created_at}}</p>
                                        <!-- <a href="#" class="btn btn-success">Принять</a> -->
                                    </div>
                                </div>
                            </div>
                        </div>
                        @endforeach
                    </div>
                    @endif

                    @if(!Auth::user()|| Auth::user()->role != "employer")
                    <div class="apply_job_form white-bg">
                        <h4>Откликнуться на вакансию</h4>
                        <form action="{{Route('addapply', $job->id)}}" method="post">
                            @csrf
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="input_field">
                                        <input type="text" name="website" placeholder="Ссылка на сайт/портфолио">
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="input_field">
                                        <textarea name="resume" cols="30" rows="10" placeholder="Резюме"></textarea>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="submit_btn">
                                        <button class="boxed-btn3 w-100" type="submit">Откликнуться</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    @endif

                </div>
                <div class="col-lg-4">
                    <div class="job_sumary">
                        <div class="summery_header">
                            <h3>Краткое описание работы</h3>
                        </div>
                        <div class="job_content">
                            <ul>
                                <li>Категория: <span>{{$job->category->name}}</span></li>
                                <li>Зарплата: <span>{{$job->salary}} руб./мес.</span></li>
                                <li>Город: <span>{{$job->city->name}}</span></li>
                                <li>Количество вакансий: <span>{{$job->job_count}}</span></li>
                                <li>Тип занятости: <span>{{$job->jobnature}}</span></li>
                                <li>Дата публикации: <span>{{$job->created_at}}</span></li>
                            </ul>
                        </div>
                    </div>
                    @if(Auth::user() && Auth::user()->role == "employer" && Auth::user()->id == $job->user->id || Auth::user() && Auth::user()->role == "admin")
                    <div class="share_wrap d-flex">
                        <a href="{{Route('edit_job', $job->id)}}" class="boxed-btn3 w-50 mr-2">Изменить</a>
                        <a href="{{Route('deletejob', $job->id)}}" class="boxed-btn3 w-50">Удалить</a>
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </div>

    <x-footer />

    <x-scripts />

</body>

</html>