@extends('layouts.app')

@section('content')

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-12">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb bg-light">
                    <li class="breadcrumb-item"><a href="{{ route('homepage') }}">All Memes</a></li>
                    <li class="breadcrumb-item active" aria-current="page">Meme {{ $data['meme']->id }}</li>
                </ol>
            </nav>
        </div>
        <div class="col-md-6 text-center">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title">{{ $data['meme']->title }}</h5>
                    @if ($data['meme']->caption)
                        <p class="card-text mb-1">{{ $data['meme']->caption }}</p>
                    @endif
                    <p class="card-text">By: <a href="{{ url('/user/' . $data['meme']->user->id) }}">{{ $data['meme']->user->name }}</a></p>
                </div>
                <a href="{{ url($data['meme']->image) }}">
                    <img src="{{ url($data['meme']->image) }}" class="card-img-top" alt="{{ $data['meme']->title }} Meme">
                </a>
                <div class="card-body p-0 pt-3">
                    {!!html_entity_decode($data['share'])!!}
                </div>
                <div class="card-footer">
                    <h5 class="card-title">{{ $data['meme']->meme_tips_total }} XMR Recieved</h5>
                    <p class="card-text">Published {{ $data['meme']->created_at->diffForHumans() }}</p>
                </div>
            </div>
        </div>
    </div>
    <div class="row text-center justify-content-center">
        <div class="col-md-12">
            <h3 class="mt-4 mb-0">Tip The Creator</h3>
            <img class="img-qr" src="{{ $data['qr'] }}" alt="QR code">
            <p class="text-break">{{ $data['meme']->address }}</p>
        </div>
        <div class="col-12 col-lg-6">
            <h4 class="mt-4">Monero Tips Recieved</h4>
            <div class="table-responsive-md text-left mt-4">
                <table class="table">
                    <thead>
                        <tr>
                            <th scope="col">Amount</th>
                            <th scope="col">Date Recieved</th>
                            <th scope="col">Transaction ID</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($data['meme']['tips'] as $tip)
                            @if ($tip->is_deposit === 1)
                                <tr>
                                    <td>{{ $tip->amount_formatted }}</td>
                                    <td>{{ $tip->created_at->diffForHumans() }}</td>
                                    <td class="text-truncate">
                                        <a href="{{ $tip->tx_url }}" target="_blank">
                                            {{ $tip->txid }}
                                        </a>
                                    </td>
                                </tr>
                            @endif
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-12 col-lg-6">
            <h4 class="mt-4">Monero Tips Sent</h4>
            <div class="table-responsive-md text-left mt-4">
                <table class="table">
                    <thead>
                        <tr>
                            <th scope="col">Amount</th>
                            <th scope="col">Date Sent</th>
                            <th scope="col">Transaction ID</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($data['meme']['tips'] as $tip)
                            @if ($tip->is_deposit === 0)
                                <tr>
                                    <td>{{ $tip->amount_formatted }}</td>
                                    <td>{{ $tip->created_at->diffForHumans() }}</td>
                                    <td class="text-truncate">
                                        <a href="{{ $tip->tx_url }}" target="_blank">
                                            {{ $tip->txid }}
                                        </a>
                                    </td>
                                </tr>
                            @endif
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection
