
@push("js")
    <script>
        var changeStatus = function ($button , callback) {
            const status_code = $button.data('status-id');
            const orderId = $button.data('order-id');
            const confirmMessage = $button.data('confirm-message');
            const badgeDot = $button.data('bagde-dot');

            confirmMessage({
                title: '{{__("Order Status")}}',
                html : badgeDot+" "+confirmMessage+" ?",
                icon: 'question',
                showCancelButton: true,
                confirmButtonText: '{{__("Yes")}}',
                cancelButtonText: '{{__("No")}}',
                showLoaderOnConfirm: true,
                reverseButtons: true,
                allowOutsideClick : false,

                preConfirm : (value) => {
                    let  data = {
                        status_code,
                    };

                    return  request("{{route("admin.orders.set-status")}}/"+orderId,{ body:data,method:"put"} ,false)
                        .then( response => {
                            if(response.success){
                                console.log("successfully" );
                               callback();
                            }
                            else{
                                swal.showValidationMessage(`${response.message}`);
                                console.log("transaction init failed" );
                            }
                        })
                        .catch (error  => {
                            swal.showValidationMessage(`{{__("Error")}} : ${error}`)
                        });
                },
            })
            .then((result) => {
                if (result.isConfirmed) {

                }
            });
        };
    </script>
@endpush
