delete_people.blade.php 5.48 KB
@extends('layout.frontend', ['title' => 'Удаление пользователя - РекаМоре'])

@section('scripts')
  <script>
      console.log('Validation password');
      $(document).on('submit', '#form_del', function() {
          var this_ = $(this);
          var email = $('#email').val();
          var password = $('#password').val();

          $.ajax({
              type: "GET",
              url: "{{ route('employer.ajax_delete_user') }}",
              data: "email=" + email + "&password=" + password +"&preview=1",
              success: function (data) {
                  console.log('Предупреждение!');
                  let d = JSON.parse(data);

                  if(typeof d['SUCCESS'] !== "undefined") {
                      $('#password_delete').val(d['password']);
                      $('#email_delete').val(d['email']);
                      $('#button_submit_hidden').click();
                      console.log(d['SUCCESS']);
                  }

                  if (typeof d['ERROR'] !== "undefined") {
                      console.log(d['ERROR']);
                      $('#block_light').css('display', 'block');
                      $('#mess_arr').html(d['ERROR']);
                  }
              },
              headers: {
                  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
              },
              error: function (data) {
                  data = JSON.stringify(data);
                  console.log('Error: ' + data);
                  $('#mess_arr').html(data);
              }
          });
          return false;
      });
  </script>
@endsection

@section('content')
    <section class="cabinet">
        <div class="container">
            <ul class="breadcrumbs cabinet__breadcrumbs">
                <li><a href="{{ route('index') }}">Главная</a></li>
                <li><b>Личный кабинет</b></li>
            </ul>
            <div class="cabinet__wrapper">

                <div class="cabinet__side">
                    <div class="cabinet__side-toper">
                        @include('employers.emblema')
                    </div>
                    @include('employers.menu', ['item' => 14])
                </div>

                <div class="cabinet__body">
                    <div class="cabinet__body-item">
                        <h2 class="title cabinet__title">Удалить профиль</h2>
                        <p class="cabinet__text"><b>Вы уверены, что хотите удалить свой профиль?</b></p>
                        <div class="notify notify_red">
                            <svg>
                                <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use>
                            </svg>
                            <span>Это действие не может быть отменено!</span>
                        </div>

                        <div class="notify" id="block_light" name="block_light" style="display:none">
                            <svg>
                                <use xlink:href="{{ asset('images/sprite.svg#i') }}"></use>
                            </svg>
                            <span id="mess_arr" name="mess_arr">
                            </span>
                        </div>

                        <form class="cabinet__inputs" id="form_del" name="form_del" method="GET">
                            @csrf
                            <input type="hidden" name="email" id="email" value="{{ $login }}"/>
                            <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
                                <label class="form-group__label">Пожалуйста, введите пароль от учётной записи для подтверждения:</label>
                                <div class="form-group__item">
                                    <input type="password" name="password" id="password" class="input" placeholder="**********" required>
                                    <button type="button" class="eye">
                                        <svg class="js-password-show">
                                            <use xlink:href="{{ asset('images/sprite.svg#eye') }}"></use>
                                        </svg>
                                        <svg class="js-password-hide">
                                            <use xlink:href="{{ asset('images/sprite.svg#eye-2') }}"></use>
                                        </svg>
                                    </button>
                                </div>
                            </div>
                            <div class="cabinet__inputs-item cabinet__inputs-item_fullwidth form-group">
                                <div class="buttons">
                                    <a href="{{ route('employer.cabinet') }}" class="button">Отменить</a>
                                    <button type="submit" id="button_submit"  class="button button_light">Удалить профиль</button>
                                    <button style="display:none;" type="submit" id="button_submit_hidden" data-fancybox data-src="#delete" data-options='{"touch":false,"autoFocus":false}'  class="button button_light">Удалить профиль</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    </div>
@endsection