@extends('layouts.app')

@section('title','Tambah User')

@section('content')

<div class="container-fluid">

    {{-- Header --}}
    <div class="d-flex justify-content-between align-items-center mb-4">

        <div>

            <h3 class="font-weight-bold mb-1">
                Tambah User
            </h3>

            <p class="text-muted mb-0">
                Tambahkan akun pengguna baru ke dalam sistem.
            </p>

        </div>

        <a href="{{ route('user.index') }}"
           class="btn btn-secondary btn-modern">

            <i class="fas fa-arrow-left mr-1"></i>

            Kembali

        </a>

    </div>

    <form action="{{ route('user.store') }}" method="POST">

        @csrf

        <div class="card card-modern shadow-sm">

            <div class="card-header bg-white border-0">

                <h5 class="mb-0">

                    <i class="fas fa-user-plus text-primary mr-2"></i>

                    Form Tambah User

                </h5>

            </div>

            <div class="card-body">

                <div class="row">

                    {{-- Nama --}}
                    <div class="col-md-6 mb-3">

                        <label>Nama Lengkap</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="fas fa-user"></i>

                                </span>

                            </div>

                            <input
                                type="text"
                                name="name"
                                value="{{ old('name') }}"
                                class="form-control @error('name') is-invalid @enderror"
                                placeholder="Masukkan nama lengkap">

                            @error('name')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                            @enderror

                        </div>

                    </div>

                    {{-- Email --}}
                    <div class="col-md-6 mb-3">

                        <label>Email</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="fas fa-envelope"></i>

                                </span>

                            </div>

                            <input
                                type="email"
                                name="email"
                                value="{{ old('email') }}"
                                class="form-control @error('email') is-invalid @enderror"
                                placeholder="Masukkan email">

                            @error('email')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                            @enderror

                        </div>

                    </div>

                    {{-- Password --}}
                    <div class="col-md-6 mb-3">

                        <label>Password</label>

                        <div class="input-group">

                            <div class="input-group-prepend">

                                <span class="input-group-text">

                                    <i class="fas fa-lock"></i>

                                </span>

                            </div>

                            <input
                                type="password"
                                name="password"
                                class="form-control @error('password') is-invalid @enderror"
                                placeholder="Masukkan password">

                            @error('password')
                            <div class="invalid-feedback">
                                {{ $message }}
                            </div>
                            @enderror

                        </div>

                    </div>

                    {{-- Role --}}
                    <div class="col-md-6 mb-3">

                        <label>Role</label>

                        <select
                            name="role"
                            class="form-control @error('role') is-invalid @enderror">

                            <option value="">-- Pilih Role --</option>

                            <option value="admin"
                                {{ old('role')=='admin'?'selected':'' }}>
                                Administrator
                            </option>

                            <option value="guru"
                                {{ old('role')=='guru'?'selected':'' }}>
                                Guru
                            </option>

                            <option value="staff"
                                {{ old('role')=='staff'?'selected':'' }}>
                                Staff
                            </option>

                        </select>

                        @error('role')
                        <div class="invalid-feedback d-block">
                            {{ $message }}
                        </div>
                        @enderror

                    </div>

                </div>

            </div>

            <div class="card-footer bg-white">

                <button
                    type="submit"
                    class="btn btn-primary btn-modern">

                    <i class="fas fa-save mr-1"></i>

                    Simpan User

                </button>

                <a href="{{ route('user.index') }}"
                   class="btn btn-light btn-modern">

                    Batal

                </a>

            </div>

        </div>

    </form>

</div>

@endsection