@view('header', [ 'title' => 'Create account - Accounts - Admin' ])

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

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

@view('errors')

<form method="post" action="/admin/accounts">
    @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') }}" {{ !isset($errors) ? 'autofocus' : '' }} required>
    </div>

    <div class="field">
        <label class="label" for="type">Type</label>
        <select class="input" id="type" name="type" required>
            <option value="" disabled {{ old('type') == '' ? 'selected' : '' }}>Choose a type</option>
            <option value="{{ Accounts::TYPE_SAVE }}" {{ old('type') == Accounts::TYPE_SAVE ? 'selected' : '' }}>Save</option>
            <option value="{{ Accounts::TYPE_PAYMENT }}" {{ old('type') == Accounts::TYPE_PAYMENT ? 'selected' : '' }}>Payment</option>
        </select>
    </div>

    <div class="field">
        <label class="label" for="user_id">User</label>
        <select class="input" id="user_id" name="user_id" required>
            @foreach ($users as $user):
                <option value="{{ $user->id }}" {{ $user->id == old('user_id', $user_id) ? 'selected' : ''}}>{{ $user->firstname }} {{ $user->lastname }}</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', '0') }}" required>
    </div>

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

@view('footer')
