@view('header', [ 'title' => 'Accounts' ])

<div class="breadcrumb">
    <ul>
        <li><a href="/">Banq</a></li>
        <li class="is-active"><a href="/accounts">Accounts</a></li>
    </ul>
</div>

<h1 class="title">Accounts</h1>

<div class="columns">
    <div class="column">
        <div class="buttons">
            <a class="button is-link" href="/accounts/create">Create</a>
        </div>
    </div>
    <form class="column" method="get">
        <div class="field has-addons">
            <div class="control" style="width: 100%;">
                <input class="input" type="text" id="q" name="q" placeholder="Search..." value="{{ request('q') }}">
            </div>
            <div class="control">
                <button class="button is-link" type="submit">Search</button>
            </div>
        </div>
    </form>
</div>

@if (count($accounts) > 0):
    @view('pagination', [ 'page' => $page, 'last_page' => $last_page ])

    @foreach ($accounts as $account):
        <div class="box">
            <h2 class="title is-4">
                <a href="/accounts/{{ $account->id }}">{{ $account->name }}</a>
                @if ($account->type == Accounts::TYPE_SAVE):
                     <span class="tag is-success" style="margin-left: 16px;">SAVE ACCOUNT</span>
                @endif
                @if ($account->type == Accounts::TYPE_PAYMENT):
                    <span class="tag is-info" style="margin-left: 16px;">PAYMENT ACCOUNT</span>
                @endif
            </h2>
            <p>Amount: {!! format_money($account->amount) !!}</p>
        </div>
    @endforeach

    @view('pagination', [ 'page' => $page, 'last_page' => $last_page ])
@else:
    <p><i>There are no accounts found</i></p>
@endif

@view('footer')
