@extends('layouts.app')
@section('title', '編集 | 利用者分類マスタ')

@section('content')
    <!-- Content Header -->
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-lg-6">
                    <h1 class="m-0 text-dark">編集</h1>
                </div>
                <div class="col-lg-6">
                    <ol class="breadcrumb float-sm-right text-sm">
                        <li class="breadcrumb-item"><a href="{{ route('home') }}">ホーム</a></li>
                        <li class="breadcrumb-item"><a href="{{ route('usertypes') }}">利用者分類マスタ</a></li>
                        <li class="breadcrumb-item active">編集</li>
                    </ol>
                </div>
            </div>
        </div>
    </div>

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">

        {{-- カード本体 --}}
            <div class="card">
                <form id="usertype-form" method="post" action="{{ route('usertype_edit', ['id' => $user_categoryid]) }}">
                    @csrf
                    @include('admin.usertypes._form', ['isEdit' => 1, 'isInfo' => 0])
                </form>
                <form id="usertype-delete-form" method="post" action="{{ route('usertypes_delete', ['id' => $user_categoryid]) }}" class="d-none">
                    @csrf
                    <input type="hidden" name="pk[]" value="{{ $user_categoryid }}">
                </form>
            </div>
        </div>

        </div>
    </section>
@endsection

@push('scripts')
<script>
(function ($) {
    $(function () {
        var $registerBtn = $('.register');
        var $editForm = $('#usertype-form');
        if ($registerBtn.length && $editForm.length) {
            $registerBtn.off('click.usertypeConfirm').on('click.usertypeConfirm', function (e) {
                e.preventDefault();
                var submitEdit = function () { $editForm.trigger('submit'); };
                if (typeof $.confirm === 'function') {
                    $.confirm({
                        title: '確認ダイアログ。',
                        content: '登録してよろしいですか？はい/いいえ',
                        buttons: {
                            ok: {
                                text: 'はい',
                                btnClass: 'btn-primary',
                                keys: ['enter'],
                                action: submitEdit
                            },
                            いいえ: function () {}
                        }
                    });
                } else if (window.confirm('登録してよろしいですか？')) {
                    submitEdit();
                }
            });
        }

        var $deleteBtn = $('.js-inline-delete');;
        var $deleteForm = $('#usertype-delete-form');
        if ($deleteBtn.length && $deleteForm.length) {
            $deleteBtn.off('click.usertypeDelete').on('click.usertypeDelete', function (e) {
                e.preventDefault();
                var submitDelete = function () { $deleteForm.trigger('submit'); };
                if (typeof $.confirm === 'function') {
                    $.confirm({
                        title: '確認ダイアログ。',
                        content: '削除してよろしいですか？はい/いいえ',
                        buttons: {
                            ok: {
                                text: 'はい',
                                btnClass: 'btn-primary',
                                keys: ['enter'],
                                action: submitDelete
                            },
                            いいえ: function () {}
                        }
                    });
                } else if (window.confirm('削除してよろしいですか？')) {
                    submitDelete();
                }
            });
        }
    });
})(window.jQuery);
</script>
@endpush