@extends('layouts.master')

@section('content')

<div class="container" style="max-width: 700px;">
	<h3 style="font-weight: 800; margin-bottom: 5px;">الطلبات الواردة</h3>
	<hr>
	@if (count($demands) > 0)
	<ul class="list-group">
		@foreach($demands as $demand)
			@php $unreadStyle = !$demand->is_read ? 'background: #e8e8f5; border-right: 4px solid #7777CC; font-weight: 700;' : 'background: #fff;'; @endphp
			@if ($demand->type == 'addition')
				<li class="list-group-item" style="display: flex; justify-content: space-between; align-items: center; {{ $unreadStyle }}">
					<div>
						@if(!$demand->is_read)<span style="color: #dc3545; font-size: 11px; margin-left: 5px;">&#9679; جديد</span>@endif
						<span style="color: #28a745; font-weight: 700;">إضافة:</span>
						<a href="/admin/create/{{$demand->id}}">{{ $demand->song}}</a>
						- <b>{{$demand->artist}}</b>
					</div>
					<form method="POST" action="/admin/delete/{{$demand->id}}" style="margin: 0;" onsubmit="return confirm('هل تريد حذف هذا الطلب؟')">
						@csrf
						{{ method_field('DELETE') }}
						<button type="submit" style="background: #dc3545; color: #fff; border: none; padding: 3px 12px; border-radius: 3px; cursor: pointer; font-size: 13px;">حذف</button>
					</form>
				</li>
			@elseif ($demand->type == 'correction')
				<li class="list-group-item" style="display: flex; justify-content: space-between; align-items: center; {{ $unreadStyle }}">
					<div>
						@if(!$demand->is_read)<span style="color: #dc3545; font-size: 11px; margin-left: 5px;">&#9679; جديد</span>@endif
						<span style="color: #7777CC; font-weight: 700;">تصحيح:</span>
						<a href="/admin/edit/{{$demand->id}}">{{ $demand->song}}</a>
						- <b>{{$demand->artist}}</b>
					</div>
					<form method="POST" action="/admin/delete/{{$demand->id}}" style="margin: 0;" onsubmit="return confirm('هل تريد حذف هذا الطلب؟')">
						@csrf
						{{ method_field('DELETE') }}
						<button type="submit" style="background: #dc3545; color: #fff; border: none; padding: 3px 12px; border-radius: 3px; cursor: pointer; font-size: 13px;">حذف</button>
					</form>
				</li>
			@endif
		@endforeach
	</ul>
	@else
		<div class="alert alert-primary" role="alert">
		  لا توجد طلبات حالياً
		</div>
	@endif
</div>

@endsection
