@extends('back-end.master.app')
@section('title', 'Role of Website')
@section('body')
    <main class="app-content">
        <div class="row">
            <div class="col-md-12">
                <div class="tile">
                    <div class="tile-title-w-btn">

                        <h4 class="card-title">
                            {{ $role->name }}
                            <br>
                            {{ $role->created_at }}
                        </h4>
                        <div class="btn-group" role="group">
                            <a href="{{ route('roles.index') }}" class="btn btn-outline-primary">
                                <i class="fa fa-list-alt"></i> List
                            </a>
                        </div>
                    </div>
                    <hr />
                    <div class="tile-body row">

                        <div class="col-md-12 col-sm-12 col-12">
                            <div class="card">
                                <div class="card-body">



                                    <table class="table table-hover text-center">
                                        <tr style="font-size: 16px;">
                                            <td># number</td>
                                            <td>Name</td>
                                            <td>Action</td>
                                        </tr>
                                        @if (!empty($rolePermissions))
                                            @foreach ($rolePermissions as $k => $v)
                                                <tr>
                                                    <td>{{ $loop->iteration }}</td>
                                                    <td>{{ $v->name }}</td>
                                                    <td>
                                                        <a href="#" class="btn btn-sm btn-primary"><i
                                                                class="fa fa-edit"></i></a>
                                                        <a href="#" class="btn btn-sm btn-danger"><i
                                                                class="fa fa-trash"></i></a>
                                                    </td>
                                                </tr>
                                            @endforeach
                                        @endif
                                    </table>
                                </div>
                            </div>
                        </div>

                        <form id="delete-form" action="" method="POST" style="display: none;">
                            {{ csrf_field() }}
                            {{ method_field('DELETE') }}
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </main>


@endsection


@section('pageJs')
    <script type="text/javascript">
        $(".app-menu").removeClass("active");
        $("#nav_account").addClass("active");
        $("#nav_accounti").addClass("is-expanded");
        $("#nav_role").addClass("active");
        $(document).on("click", ".btn-delete", function() {
            var id = $(this).attr("data-id");
            swal({
                title: "Are you sure want to delete?",
                text: "...",
                type: "warning",
                showCancelButton: true,
                confirmButtonText: "Yes!",
                cancelButtonText: "No!",
                closeOnConfirm: false,
                closeOnCancel: false
            }, function(isConfirm) {
                if (isConfirm) {
                    $('#delete-form').attr('action', "/info/delete/" + id);
                    $("#delete-form").submit();
                } else {
                    swal("Cancelled", "Record not deleted", "error");
                    return false;
                }
            });
        });
    </script>
@endsection
