@extends('layouts.main')
@section('container')
    @if (session()->has('success'))
        <div class="alert alert-success alert-dismissible show fade">
            <div class="alert-body">
                <button class="close" data-dismiss="alert">
                    <span>×</span>
                </button>
                {{ session('success') }}
            </div>
        </div>
    @endif
    <div class="card shadow mb-4">
        <div class="card-header py-3 d-flex justify-content-between align-items-center">
            <h6 class="m-0 font-weight-bold text-primary">Data Ibu Hamil</h6>

        </div>

        <div class="card-body">
            <div class="table-responsive">
                <table id="example" class="table table-stripped table-hover">
                    <thead>
                        <tr>
                            <th class="text-center">No</th>
                            <th class="text-center">Nama Ibu</th>
                            <th class="text-center">Nama Ayah</th>
                            <th class="text-center">Alamat</th>
                            <th class="text-center">Status Ibu</th>
                            @can('admin_is')
                                <th class="text-center">Delete</th>
                            @endcan
                            <th class="text-center">Preview</th>
                        </tr>
                    </thead>
                    <tbody class="text-center">
                        @foreach ($dataIbuHamil as $dih)
                            <tr>
                                <td>{{ $loop->iteration }}</td>
                                <td>{{ $dih->nama_ibu }}</td>
                                <td>{{ $dih->nama_ayah }}</td>
                                <td>{{ $dih->alamat }}</td>
                                <td>{{ $dih->status_ibu }}</td>
                                @can('admin_is')
                                    <td>
                                        <a href="#" data-toggle="modal" data-target="#hapusData{{ $dih->id }}"
                                            class="btn btn-danger">
                                            <span class="icon text-white">
                                                <i class="fas fa-trash"></i>
                                            </span>
                                        </a>
                                    </td>
                                @endcan
                                <td>
                                    <a href="/data_pasien/{{ $dih->id }}" class="btn btn-success">
                                        <span class="icon text-white">
                                            <i class="fas fa-angle-double-right"></i>
                                        </span>
                                    </a>
                                </td>
                            </tr>
                            <div class="modal fade" id="hapusData{{ $dih->id }}" tabindex="-1" role="dialog"
                                aria-labelledby="exampleModalLabel" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h5 class="modal-title" id="exampleModalLabel">Apakah Kamu Akan Menghapus Data
                                                Ibu {{ $dih->nama_ibu }}?
                                            </h5>
                                            <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">×</span>
                                            </button>
                                        </div>
                                        <div class="modal-body">Pilih "Hapus" di bawah jika Anda ingin menghapus seluruh
                                            data ibu
                                            {{ $dih->nama_ibu }}
                                        </div>
                                        <div class="modal-footer">
                                            <form action="/data_ibu_hamil/{{ $dih->id }}/delete" method="post"
                                                class="d-inline">
                                                @method('delete')
                                                @csrf
                                                <button class="btn btn-secondary" type="button"
                                                    data-dismiss="modal">Cancel</button>
                                                <button class="btn btn-danger">Hapus</button>
                                            </form>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- Logout Modal-->
@endsection
