@extends('breadcrumbs.app')

@section('content')



	@if(!$positions->isEmpty())

		<!-- todo: details component -->

		@foreach($positions as $position)
				<x-modal id="{{ $position->vacancySlug . '-details' }}" modal-label="{{ $position->vacancySlug . '-details-label' }}" modal-title="{{__('Vacancy details')}}" include-close-button="false">

					@if (is_null($position->vacancyFullDescription))

						<div class="alert alert-warning">

							<h3><i class="fas fa-question-circle"></i> {{__("There don't seem to be any details.")}}</h3>
							<p>
								{{__('This vacancy does not have any details yet.')}}
							</p>

						</div>
					@else

						{!! $position->vacancyFullDescription !!}
						<p class="text-sm text-muted">
							{{__('Last updated :lastUpdatedRelativeTimeValue', ['lastUpdatedRelativeTimeValue' => $position->updated_at->diffForHumans()])}}
						</p>
					@endif

					<x-slot name="modalFooter">
                    </x-slot>

				</x-modal>

		@endforeach


	@endif

	<!--Main Layout-->
	<main class="py-5">

	  <div class="container-fluid">

          @if ($demoActive)
              <div class="row">
                  <div class="col">
                      <div class="alert alert-warning">
                          <p class="font-weight-bold"><i class="fas fa-exclamation-circle"></i> {{ __('Attention') }}</p>
                          <p>{{ __('Demo mode is active on this instance. The database is refreshed daily and some features are disabled for security reasons.') }}</p>

                          <p>{{ __("If you're seeing this message in error, please contact your system administrator.") }}</p>
                      </div>
                  </div>
              </div>
          @endif


          <div class="row mt-5">

              <div class="col text-center">
                  <h3>{{ __('Check out our available roles') }}</h3>
                  {!! __("<p>Are you looking to work with the :appName team? We're actively recruiting! Check out one of our open roles. A good team is an important aaspect of a successful community.</p>", ['appName' => config('app.name')]) !!}
              </div>

          </div>

          <div class="row mt-5 mb-5">

              @if (!$positions->isEmpty())

                  @foreach($positions as $position)

                      <div class="col-md-4">

                          <div class="card mt-3">

                              <div class="card-header text-center">

                                  <h4 class="card-title">{{$position->vacancyName}}</h4>
                                  <p class="card-subtitle">{{trans_choice('{1} There is :count open position!|[2,*] There are :count open positions!', $position->vacancyCount)}}</p>


                              </div>

                              <div class="card-body text-center">

                                  <p class="card-text">
                                      {{$position->vacancyDescription}}
                                  </p>

                              </div>

                              <div class="card-footer text-center">
                                  @auth

                                      @if ($position->requiresDiscord)
                                          @if(Auth::user()->hasDiscordConnection())
                                              <button {{($isEligibleForApplication) ? '' : 'disabled'}} type="button" class="btn btn-success" onclick="window.location.href='{{route('renderApplicationForm', ['vacancySlug' => $position->vacancySlug])}}'">{{__('Apply')}}</button>
                                          @else
                                              <button {{($isEligibleForApplication) ? '' : 'disabled'}} style="background-color: #5865F2; color: white" type="button" class="btn" onclick="window.location.href='{{route('renderApplicationForm', ['vacancySlug' => $position->vacancySlug])}}'"><i class="fab fa-discord"></i> {{__('Apply with Discord')}}</button>
                                          @endif
                                      @else
                                          <button {{($isEligibleForApplication) ? '' : 'disabled'}} type="button" class="btn btn-success" onclick="window.location.href='{{route('renderApplicationForm', ['vacancySlug' => $position->vacancySlug])}}'">{{__('Apply')}}</button>
                                      @endif

                                      @if(!$isEligibleForApplication)
                                          <span class="badge-warning badge"><i class="fa fa-info"></i> {{__('Ineligible (:days) day(s) remaining', ['days' => $eligibilityDaysRemaining])}}</span>
                                      @endif
                                  @endauth

                                  @guest
                                          @if ($position->requiresDiscord)
                                              <button style="background-color: #5865F2; color: white" type="button" class="btn" onclick="window.location.href='{{route('discord-apply', ['vacancySlug' => $position->vacancySlug])}}'"><i class="fab fa-discord"></i> {{__('Apply with Discord')}}</button>
                                          @else
                                              <button type="button" class="btn btn-dark" onclick="window.location.href='{{route('renderApplicationForm', ['vacancySlug' => $position->vacancySlug])}}'">{{__('Apply')}}</button>
                                          @endif
                                  @endguest

                                      <button type="button" class="btn btn-outline-primary" onclick="$('#{{ $position->vacancySlug }}-details').modal('show')">{{__('Learn more')}}</button>


                              </div>

                          </div>

                      </div>

                  @endforeach

              @else

                  <div class="col-md-4 offset-md-4">

                      <div class="card">

                          <div class="card-header">

                              <div class="card-title"><h4>{{__('There are no open roles')}}</h4></div>

                          </div>

                          <div class="card-body">

                              <div class="alert alert-info">

                                  <p><b>{{__('Hello There!')}}</b></p>
                                  <p>
                                      {{__('We are currently not recruiting any new staff members at the moment. If you\'d like to apply, check out our community\'s
      announcement channel for news when a new role opens.')}}
                                  </p>

                              </div>

                          </div>

                      </div>

                  </div>

              @endif

          </div>

          <div class="row mt-5 mb-5">

              <div class="col text-center">

                  {!! __("<h3>The :appName management team usually responds to applications within :timeTakenAppl hours.</hr>", ['appName' => config('app.name'), 'timeTakenAppl' => '48']) !!}
                  <p>{!! __('If you have any questions about your web portal account, application or literally anything else, please visit our <a href=":supportURL" target="_blank">support site</a>, or <a href="mailto::supportEmail">send us an email</a>.', ['supportURL' => config('app.support_url'), 'supportEmail' => config('app.support_email')])  !!}</p>
              </div>

          </div>


	  </div>

	</main>
<!--Main Layout-->

@stop
