<div class="modal-header" style="background-color: #2196f3;">
    <h4 class="modal-title text-center " style="color: #fff">CAMBIAR CONTRASEÑA</h4>
</div>
<div class="modal-body p-0">
    <?php
    $referer = request()->headers->get('referer');
    ?>
    <div class="row">
        <div class="col-sm-12 col-md-12">
            <div class="col-sm-12 p-0 hidden alert-password">
                <div class="alert alert-danger m-b-0" style="border-radius:0">
                    <button type="button" class="close close-toogle">×</button>
                    <i class="fa-fw fa fa-warning"></i>
                    <strong><span class="message_"></span></strong>
                </div>
            </div>
            {{--<div class="col-sm-12 col-md-12">--}}
                {{--<p class="text-center"><strong> {{ $user->full_name }}</strong></p>--}}
            {{--</div>--}}
            {!! Form::open(['url'=>'#', 'class'=>'row p-10']) !!}
            <div class="col-sm-12 col-md-12">
                <div class="form-group">
                    {!! Form::label('password', 'Escriba nueva contraseña', ['class' => 'text-center d-block']) !!}
                    {!! Form::password('password',['class'=>'form-control input-sm', 'id'=>'password', 'placeholder'=>'*********']) !!}
                </div>
            </div>
            <div class="col-sm-12 col-md-12 text-center m-b-30">
                <button type="submit" class="btn btn-success">CAMBIAR</button>
                <button type="button" class="btn btn-danger m-l-5 btnDeleteModal" data-dismiss="modal">
                    CANCELAR
                </button>
            </div>
            {!! Form::close() !!}
        </div>
    </div>
</div>

<script>
    $(function () {
        var url= "{{ route('admin.cambiarpassword') }}";
        $('form').on('submit', function (e) {
            e.preventDefault();
            {{--var url= "{{ route('admin.cambiarpassword') }}";--}}
            {{--console.log("url:::", url);--}}
            var pass_ = $("#password").val();
            var referer = "{{ $referer }}";
            if (pass_ === "") {
                message_pass("Favor ingrese contraseña");
                return false;
            } else {
                if (pass_.length < 6) {
                    message_pass("La contraseña debe tener como minimo 6 caracteres");
                    return false;
                }
                var data = {password: pass_};
                $.ajax({
                    url: url,
                    type: 'POST',
                    headers: {'X-CSRF-Token': $("input[name=_token]").val()},
                    data: data,
                    dataType: 'json',
                    beforeSend: function () {
                    },
                    success: function (response) {
                        window.location.href = referer;
                    },
                    error: function (err) {
                        console.log("show_error_: ", err.responseText);
                    }
                });
            }
        });
        $('.close-toogle').on('click', function () {
            $('.alert-password').addClass('hidden');
        });
    });
</script>