@extends('web.layouts.container')

@section('content')
    <section class="inner_header">
        <img src="{{asset('assets/web/images/icons/inner.svg')}}" alt="" class="inner_shap">
        <div class="container">
            <ul class="links">
                <li>
                    <a href="{{LaravelLocalization::getLocalizedURL($lang, route('home'), [], true)}}">{{__('main.home')}}</a>
                </li>
                <li>
                    <a href="#"> {{$title}} </a>
                </li>
            </ul>
            <h4>{{$title}}</h4>
        </div>
    </section>

    @if(in_array($consultingRequest->status, ['active', 'not_active']))
        @if($consultingRequest->consulting_way == 'phone')
            @include('web.users.my_consulting.consulting_ways.phone')
        @endif
        @if($consultingRequest->consulting_way == 'office')
            @include('web.users.my_consulting.consulting_ways.office')
        @endif
        @if($consultingRequest->consulting_way == 'zoom')
            @include('web.users.my_consulting.consulting_ways.zoom')
        @endif
    @endif

    @if($consultingRequest->status == 'finished')
        @include('web.users.my_consulting.consulting_ways.finished')
    @endif


@endsection

@section('inner_js')

    <script>

        let evaluateModal = new bootstrap.Modal(document.querySelector('.evaluate_modal')),
            complaintModal = new bootstrap.Modal(document.querySelector('.complaint_modal'));
        $('.consulting_evaluate_complaint_button').click(async function (e) {
            e.preventDefault();
            $(this).attr('disabled', true);
            let form = $(this).parents('form'),
                data = new FormData(form[0]),
                url = form.attr('action'),
                method = form.attr('method');

            const response=await ajax({
                url,
                data,
                dataType: 'json',
                method,
                contentType: false,
                processData: false,
            });

            if (response.errors) {
                $(this).attr('disabled', false);
                toasterError(response.errors);
            }
            if (response.message) {
                $(this).attr('disabled', false);
                form.trigger('reset');
                evaluateModal.hide();
                complaintModal.hide();
                toasterSuccess(response.message);
            }
        });
    </script>

@endsection
