@view('header', [ 'title' => 'Create transaction - Transactions' ])

<div class="breadcrumb">
    <ul>
        <li><a href="/">Banq</a></li>
        <li><a href="/transactions">Transactions</a></li>
        <li class="is-active"><a href="/transactions/create">Create</a></li>
    </ul>
</div>

<h1 class="title">Create transaction</h1>

@view('errors')

<form method="post" action="/transactions">
    @view('csrf_token')

    <div class="field">
        <label class="label" for="name">Name</label>
        <input class="input" type="text" id="name" name="name" value="{{ old('name', 'Transaction at ' . date('Y-m-d H:i:s')) }}" required>
    </div>

    <div class="field">
        <label class="label" for="from_account_id">From account</label>
        <select class="input" id="from_account_id" name="from_account_id" required>
            @foreach ($from_accounts as $account):
                <option value="{{ $account->id }}" {{ $account->id == old('from_account_id', $from_account_id) ? 'selected' : '' }}>{{ $account->name }}</option>
            @endforeach
        </select>
    </div>

    <div class="field">
        <label class="label" for="to_account_id">To account</label>
        <select class="input" id="to_account_id" name="to_account_id" required>
            @foreach ($to_accounts as $account):
                <option value="{{ $account->id }}" {{ $account->id == old('to_account_id') ? 'selected' : '' }}>{{ $account->name }}</option>
            @endforeach
        </select>
    </div>

    <div class="field">
        <label class="label" for="amount">Amount</label>
        <input class="input" type="number" id="amount" name="amount" step="0.01" value="{{ old('amount') }}" required>
    </div>

    <div class="field">
        <button class="button is-link" type="submit">Create transaction</button>
    </div>
</form>

@view('footer')
