@extends('admin.layouts.app')

@section('content')
    <div class="row px-5">
        <div class="col-xl-12">
            <div class="card shadow">
                <div class="card-header bg-transparent">
                    <div class="row align-items-center">
                        <div class="col">
                            <h6 class="text-uppercase text-muted ls-1 mb-1">Update User Management</h6>
                            <h2 class="mb-0">Edit Pengguna Rumah Sakit</h2>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <form action="{{ route($route.'update_action') }}" class="form-global-handle" method="POST" enctype="multipart/form-data">
                        @csrf
                        <input type="hidden" name="id" value="{{Hashids::encode($data->id)}}">
                        <div class="form-group">
                            <label for="nama">Nama Rumah Sakit <span class="text-danger">*</span></label>
                            <input type="text" name="nama" required class="form-control cek-email" value="{{ $data->nama  }}" id="nama" placeholder="Contoh : Rumah Sakit Sidoni">
                        </div>
                        <div class="form-group">
                            <label for="kode_rumah_sakit">Kode Rumah Sakit <span class="text-danger">*</span></label>
                            <input type="text" name="kode_rumah_sakit" required class="form-control cek-email" value="{{ $data->kode_rumah_sakit  }}" id="kode_rumah-sakit" placeholder="Contoh : Rumah Sakit Sidoni">
                        </div>
                        <div class="form-group">
                            <label for="email">Email <span class="text-danger">*</span></label>
                            <input type="email" name="email" required class="form-control cek_email" data-id="{{ Hashids::encode($data->user_login_id) }}" data-route="{{ route('cek_email') }}"  value="{{ $data->user->email  }}" id="email" placeholder="Contoh : sidoni@mail.com">
                            <div class="email-notification"></div>
                        </div>
                        <div class="form-group">
                            <label for="password">Password <span class="text-danger">*</span></label>
                            <input type="password" name="password" class="form-control" id="password" placeholder="Contoh : *****">
                        </div>
                            <div class="form-group">
                            <label for="nama_bank_darah">Nama Bank Darah <span class="text-danger">*</span></label>
                            <input type="nama_bank_darah" required name="nama_bank_darah"  value="{{ $data->nama_bank_darah  }}" class="form-control" id="nama_bank_darah" placeholder="Contoh : Bank Darah Doni">
                        </div>
                        <div class="form-group">
                            <label for="deskripsi">Deskripsi <span class="text-danger">*</span></label>
                            <textarea name="deskripsi" required class="form-control" id="deskripsi" rows="5" value="Deskripsi">{{ $data->deskripsi  }}</textarea>
                        </div>
                        <div class="form-group">
                            <label for="alamat">Alamat <span class="text-danger">*</span></label>
                            <textarea name="alamat" required class="form-control" id="alamat" rows="5" value="alamat">{{ $data->alamat  }}</textarea>
                        </div>
                        <div class="form-group">
                            <label> List Role <span class="text-danger">*</span></label>
                            <div class="row">
                                @foreach ($roles as $key => $value)
                                    <div class="col-lg-12">
                                        <div class="custom-control custom-control-alternative custom-checkbox mb-3">
                                        <input class="custom-control-input" name="role_id[]" value="{{ $value->id }}" {{ in_array($value->id, $data->user->roles()->get()->pluck('id')->toArray()) ? 'checked' : null }}    id="customCheck{{$key}}" type="checkbox">
                                            <label class="custom-control-label" for="customCheck{{$key}}">{{ $value->name }}</label>
                                        </div>
                                    </div>
                                @endforeach
                            </div>
                        </div>
                        <div class="group">
                            <button type="submit" class="btn btn-success">Simpan</button>
                            <a class="btn btn-default bg-back" href="{{ route($route.'index') }}">Kembali</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

 {{-- load JS yang lu perluin, selain itu no --}}
@push('js')
    <script src="{{ asset('assets') }}/js/blockUI.js"></script>
    <script src="{{ asset('assets') }}/js/sweetalert2.js"></script>
    <script src="{{ asset('assets') }}/js/custom.js"></script>
@endpush