@view('header', [ 'title' => 'Edit user - Users - Admin' ])

<div class="breadcrumb">
    <ul>
        <li><a href="/">Banq</a></li>
        <li><a href="/admin">Admin</a></li>
        <li><a href="/admin/users">Users</a></li>
        <li><a href="/admin/users/{{ $user->id }}">{{ $user->username }}</a></li>
        <li class="is-active"><a href="/admin/users/{{ $user->id }}/edit">Edit</a></li>
    </ul>
</div>

<h1 class="title">Edit user</h1>

@view('errors')

<form method="post" action="/admin/users/{{ $user->id }}">
    @view('csrf_token')

    <div class="columns">
        <div class="column">
            <div class="field">
                <label class="label" for="firstname">First name</label>
                <input class="input" type="text" id="firstname" name="firstname" value="{{ old('firstname', $user->firstname) }}" {{ !isset($errors) ? 'autofocus' : '' }} required>
            </div>
        </div>
        <div class="column">
            <div class="field">
                <label class="label" for="lastname">Last name</label>
                <input class="input" type="text" id="lastname" name="lastname" value="{{ old('lastname', $user->lastname) }}" required>
            </div>
        </div>
    </div>

    <div class="field">
        <label class="label" for="username">Username</label>
        <input class="input" type="text" id="username" name="username" value="{{ old('username', $user->username) }}" required>
    </div>

    <div class="field">
        <label class="label" for="email">Email address</label>
        <input class="input" type="email" id="email" name="email" value="{{ old('email', $user->email) }}" required>
    </div>

    <div class="field">
        <label class="label" for="password">Password (leave empty to not change)</label>
        <input class="input" type="password" id="password" name="password">
    </div>

    <div class="field">
        <label class="label" for="password_confirmation">Confirm password</label>
        <input class="input" type="password" id="password_confirmation" name="password_confirmation">
    </div>

    <div class="field">
        <label class="label" for="phone_number">Phone number</label>
        <input class="input" type="tel" id="phone_number" name="phone_number" value="{{ old('phone_number', $user->phone_number) }}" required>
    </div>

    <div class="columns">
        <div class="column">
            <div class="field">
                <label class="label" for="sex">Sex</label>
                <select class="input" id="sex" name="sex" required>
                    <option value="" disabled {{ old('sex', $user->sex) == '' ? 'selected' : '' }}>Choose a sex</option>
                    <option value="M" {{ old('sex', $user->sex) == 'M' ? 'selected' : '' }}>Male</option>
                    <option value="F" {{ old('sex', $user->sex) == 'F' ? 'selected' : '' }}>Female</option>
                    <option value="X" {{ old('sex', $user->sex) == 'X' ? 'selected' : '' }}>Complicated / other</option>
                </select>
            </div>
        </div>
        <div class="column">
            <div class="field">
                <label class="label" for="birth_date">Birth date</label>
                <input class="input" type="date" id="birth_date" name="birth_date" value="{{ old('birth_date', $user->birth_date) }}" required>
            </div>
        </div>
    </div>

    <div class="columns">
        <div class="column">
            <div class="field">
                <label class="label" for="address">Address (street with house number)</label>
                <input class="input" type="text" id="address" name="address" value="{{ old('address', $user->address) }}" required>
            </div>
        </div>
        <div class="column">
            <div class="field">
                <label class="label" for="postcode">Postcode</label>
                <input class="input" type="text" id="postcode" name="postcode" value="{{ old('postcode', $user->postcode) }}" required>
            </div>
        </div>
    </div>

    <div class="columns">
        <div class="column">
            <div class="field">
                <label class="label" for="city">City</label>
                <input class="input" type="text" id="city" name="city" value="{{ old('city', $user->city) }}" required>
            </div>
        </div>
        <div class="column">
            <div class="field">
                <label class="label" for="region">Region</label>
                <select class="input" id="region" name="region" required>
                    <option value="" disabled {{ old('region', $user->region) == '' ? 'selected' : '' }}>Choose a region</option>
                    <option value="Drenthe" {{ old('region', $user->region) == 'Drenthe' ? 'selected' : '' }}>Drenthe</option>
                    <option value="Flevoland" {{ old('region', $user->region) == 'Flevoland' ? 'selected' : '' }}>Flevoland</option>
                    <option value="Friesland" {{ old('region', $user->region) == 'Friesland' ? 'selected' : '' }}>Friesland</option>
                    <option value="Gelderland" {{ old('region', $user->region) == 'Gelderland' ? 'selected' : '' }}>Gelderland</option>
                    <option value="Groningen" {{ old('region', $user->region) == 'Groningen' ? 'selected' : '' }}>Groningen</option>
                    <option value="Limburg" {{ old('region', $user->region) == 'Limburg' ? 'selected' : '' }}>Limburg</option>
                    <option value="Noord-Brabant" {{ old('region', $user->region) == 'Noord-Brabant' ? 'selected' : '' }}>Noord-Brabant</option>
                    <option value="Noord-Holland" {{ old('region', $user->region) == 'Noord-Holland' ? 'selected' : '' }}>Noord-Holland</option>
                    <option value="Overijssel" {{ old('region', $user->region) == 'Overijssel' ? 'selected' : '' }}>Overijssel</option>
                    <option value="Utrecht" {{ old('region', $user->region) == 'Utrecht' ? 'selected' : '' }}>Utrecht</option>
                    <option value="Zeeland" {{ old('region', $user->region) == 'Zeeland' ? 'selected' : '' }}>Zeeland</option>
                    <option value="Zuid-Holland" {{ old('region', $user->region) == 'Zuid-Holland' ? 'selected' : '' }}>Zuid-Holland</option>
                </select>
            </div>
        </div>
    </div>

    <div class="field">
        <label class="label" for="role">Role</label>
        <select class="input" id="role" name="role" required>
            <option value="" disabled {{ old('role', $user->role) == '' ? 'selected' : '' }}>Choose a role</option>
            <option value="{{ Users::ROLE_NORMAL }}" {{ old('role', $user->role) == Users::ROLE_NORMAL ? 'selected' : ''}}>Normal</option>
            <option value="{{ Users::ROLE_ADMIN }}" {{ old('role', $user->role) == Users::ROLE_ADMIN ? 'selected' : ''}}>Admin</option>
        </select>
    </div>

    <div class="field">
        <button class="button is-link" type="submit">Edit user</button>
    </div>
</form>

@view('footer')
