@extends('desktop.layouts.app')
@section('content')
<div id="movieRank" class="container-fluid">

    <h5>인기 순위</h5>
    <hr/>

    <form id="fMovieRank" method="get" action="{{ route('movie.rank.index') }}" autocomplete="on" accept-charset="UTF-8">
        <div class="row g-2 justify-content-center">
            <div class="col-auto align-self-center ps-2">
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="nationK" name="nation[]" value="k" @if(in_array('k', $nation) || !$nation) checked @endif/>
                    <label class="form-check-label" for="nationK">한국영화</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="checkbox" id="nationF" name="nation[]" value="f" @if(in_array('f', $nation) || !$nation) checked @endif/>
                    <label class="form-check-label" for="nationF">외국영화</label>
                </div>
            </div>
            <div class="col-auto">
                <input type="text" name="date" class="form-control date-picker w-auto" value="{{ $date }}"/>
            </div>
            <div class="col-auto">
                <button type="submit" class="btn btn-dark">검색</button>
            </div>
        </div>
    </form>
    <br/>

    @if($data->rows > 0)
    <div class="rank-list row row-cols-1 row-cols-sm-2 row-cols-lg-3 row-cols-xxl-5">
        @foreach($data->list as $row)
            <div class="col">
                <a href="{{ $row->viewURL }}" class="poster-img" target="_self" title="{{ $row->MovieNm }}">
                    <div class="ratio ratio-2x3">
                        <img src="{{ $row->Detail->MainImg }}" class="img-fluid rounded" alt="{{ $row->MovieNm }}" onerror="this.src='/images/default/no_image.png'"/>
                    </div>
                </a>
                <dl>
                    <dt>
                        <a href="{{ $row->viewURL }}" target="_self">
                            {{ $row->MovieNm }}
                        </a>
                    </dt>
                    <dd>
                        <div class="row">
                            <div class="col">
                                <span class="badge text-bg-warning">
                                    {{ $row->Rank }}위
                                </span>
                            </div>
                            <div class="col text-end">
                                {{ $row->RankInten }}
                                @if($row->RankInten > 0)
                                    <span class="text-danger">▲</span>
                                @else
                                    <span class="text-primary">▼</span>
                                @endif
                            </div>
                        </div>
                    </dd>
                </dl>
            </div>
        @endforeach
    </div>
    @else
    <div class="text-center p-5">
        <h6>자료가 존재하지 않습니다.</h6>
    </div>
    @endif
</div>
@endsection

@push('styles')
    <link rel="stylesheet" href="{{ asset('css/desktop/movie/rank.css') }}"/>
@endpush
