@extends('layouts.master')
@section('title', 'Detail User')
@section('content')
    <div class="page-content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div class="page-title-box d-flex align-items-center justify-content-between">
                        <h4 class="mb-sm-0">Users</h4>

                        <div class="page-title-right">
                            <ol class="breadcrumb m-0">
                                <li class="breadcrumb-item"><a href="javascript: void(0);">Master</a></li>
                                <li class="breadcrumb-item"><a href="{{ route('admin.users.index') }}">Users</a></li>
                                <li class="breadcrumb-item active">Detail User</li>
                            </ol>
                        </div>

                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4 class="card-title">Detail User</h4>
                        </div>
                        <div class="card-body">
                            <form class="custom-validation" action="{{ route('admin.users.update', $user->id) }}" method="POST" enctype="multipart/form-data">
                                @csrf
                                @method('PUT')
                                <div class="row">
                                    <div class="col-md-12 col-lg-6">
                                        <div class="mb-3">
                                            <label>Name</label>
                                            <input type="text" name="name" id="name" class="form-control @error('name') is-invalid @enderror" disabled placeholder="Enter name" value="{{ old('name', $user->name) }}" />
                                            @error('name')
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                            @enderror
                                        </div>

                                        <div class="mb-3">
                                            <label>Password</label>
                                            <input type="password" name="password" id="password" class="form-control @error('password') is-invalid @enderror" disabled placeholder="Password" minlength="8" value="{{ old('password', $user->password) }}" />
                                            @error('password')
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                            @enderror
                                        </div>
                                    </div>
                                    <div class="col-md-12 col-lg-6">
                                        <div class="mb-3">
                                            <label>Email</label>
                                            <input type="email" name="email" id="email" class="form-control @error('email') is-invalid @enderror" disabled placeholder="Enter email" value="{{ old('email', $user->email) }}" />
                                            @error('email')
                                                <span class="invalid-feedback" role="alert">
                                                    <strong>{{ $message }}</strong>
                                                </span>
                                            @enderror
                                        </div>

                                        <div class="mb-3">
                                            <label>Role</label>
                                            <select name="role" id="role" class="form-select" disabled>
                                                @foreach ($roles as $role)
                                                    <option value="{{ $role->id }}" {{ $role->id == $user->roles()->first()->id ? 'selected' : '' }}>{{ ucwords($role->name) }}</option>
                                                @endforeach
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
