add_comment.blade.php 2.35 KB
<div id="add_comment" class="modal">
    <div class="modal__body">
        <div class="modal__title">Комментарий для работодателя</div>
        <form class="modal__form comment_form">
            @csrf
            <div class="modal__form-item" style="display:none">
                <!-- Отправитель сообщения: -->
                <input type="hidden" id="response_user_id" name="_user_id" class="input" placeholder="user_id" value="">
                <!-- Получатель сообщения: -->
                <input type="hidden" id="response_to_user_id" name="_to_user_id" class="input" placeholder="to_user_id" value="">
                <!-- Вакансия: -->
                <input type="hidden" id="response_vacancy" name="_vacancy" class="input" placeholder="vacancy" value="">
            </div>
            <div class="modal__form-item">
                <textarea id="comment_text" class="textarea" name="text" placeholder="Комментарий" required value=""></textarea>
                <label for="comment_text">Не заполнено поле</label>
            </div>
            <div class="modal__form-item">
                <button type="button"
                        data-fancybox
                        data-src="#response_sent"
                        class="button main__employer-page-two-item-button send_resume">Отправить</button>
                <button type="button"
                        data-fancybox
                        data-src="#response_sent_no_comment"
                        class="button main__employer-page-two-item-button send_resume">Пропустить</button>
            </div>
        </form>
    </div>
</div>

<script>
    $(document).on('click', '.send_resume', function(){
        var data = {
            user_from: $('#response_user_id').val(),
            user_to: $('#response_to_user_id').val(),
            vacancy: $('#response_vacancy').val(),
            _token: '{{csrf_token()}}'
        }

        var comment = $('.comment_form textarea').serializeArray()[0].value;

        if (comment !== '') {
            data.comment = comment;
        }

        $.ajax({
            url: '{{ route('worker.new_message') }}',
            type: 'POST',
            data: data,
            success: function (data) {
                //
            }
        })
    })
</script>