@extends($activeTemplate . 'layouts.master')

@section('content')
<style>
    .margin-element {
        margin: 90px;
    }
  
</style>

<div class="margin-element">
    <div class="content-body">
        <div class="container">
            <div class="row">
                @forelse($ads as $ad)
                @if($ad->schedule)
                @php
                $currentTime = now()->format('H:i');
                $isScheduled = $ad->schedule->where('day', strtolower(now()->format('l')))
                                          ->where('start', '<', $currentTime)
                                          ->where('end', '>', $currentTime)
                                          ->first();
                @endphp

                @if(!$isScheduled)
                    @continue
                @endif
                @endif

                <div class="col-lg-6">
                    <div class="card claim-card">
                        <div class="card-body">
                            <h4 class="mb-3">Claim Energy Profit</h4>
                            <center>
                                <h2 class="alert alert-primary">Amount: {{ $ad->amount }}</h2>
                            </center>
                            <hr class="mb-4">
                            <a class="btn btn-primary btn-block" href="{{ route('user.ptc.show', encrypt($ad->id . '|' . auth()->user()->id)) }}">
                                Claim Earning
                            </a>
                        </div>
                    </div>
                </div>
                @empty
                <div class="col-lg-12">
                    <div class="alert alert-danger">
                        <p>Check back later for more opportunities.</p>
                    </div>
                </div>
                @endforelse
            </div>
        </div>
    </div>
</div>

<script src="/assets/global/js/jquery-3.6.0.min.js"></script>
@endsection
