<html>
<x-head />

<body class="body">
    <x-header :ab="$ab"/>

    <div class="main">
        <div class="container">
            <div class="trf">
                <li>
                    <h3>Тарифы</h3>
                    @if (Auth::user() && Auth::user()->role == 'admin')
                    <a href="{{Route('addtariff')}}">Добавить тариф</a>
                    @endif
                </li>
                <div class="tariffs">
                    @foreach ($trfs as $trf)
                    <section class="tariff">
                        <li>
                            <p>{{$trf->name}}</p>
                            <p>{{$trf->sprice}} руб. / сек.</p>
                            <div class="trfed">
                            @if (Auth::user())
                                @if (Auth::user()->role == 'admin')
                                <a href="{{Route('edit_tariff', $trf->id)}}"><button class="but">Изменить</button></a>
                                @if (Auth::user()->role == 'admin' && $trf->id != 1)
                                <a href="{{Route('delete_tariff', $trf->id)}}"><button class="but">Удалить</button></a>
                                @endif
                                @else
                                    @if (Auth::user()->role == 'user' && $ab->tariff_id != $trf->id) 
                                    <a href="{{Route('tariff', $trf->id)}}"><button class="but">Подключить</button></a>
                                    @elseif (Auth::user()->role == 'admin' && $trf->id != 1)
                                    <p>Подключено</p>
                                    @endif
                                @endif
                            @else
                            <a href="{{Route('login')}}"><button class="but">Подключить</button></a>
                            @endif
                            </div>
                        </li>
                    </section>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</body>

</html>