<script>
    function refreshLockAjaxUpdate(resourceType, resourceId = false, timeInterval = false) {
        let interval = timeInterval ? timeInterval * 1000 : parseInt("{{config('resource_lock.ajax_refresh_time')}}") * 1000;
        resourceId = resourceId ? resourceId : 0;
        setInterval(function () {
            $.ajax({
                url: "{{route('refresh_resource_lock')}}",
                type: "POST",
                data: {
                    "_token": "{{csrf_token()}}",
                    "resource_type": resourceType,
                    "resource_id": resourceId
                }
            }).done(function (response) {

            }).fail(function () {

            });
        }, interval);

    }

    @isset($callResourceLockRefresh)
    $(document).ready(function () {
        // okidanje cim se udje u vest
        $.ajax({
            url: "{{route('refresh_resource_lock')}}",
            type: "POST",
            data: {
                "_token": "{{csrf_token()}}",
                "resource_type": "{{$callResourceLockRefresh['resourceType']}}", 
                "resource_id": "{{$callResourceLockRefresh['resourceId']}}"
            }
        }).done(function (response) {

        }).fail(function () {

        });

        // okidanje nakon 15sec
        refreshLockAjaxUpdate("{{$callResourceLockRefresh['resourceType']}}", "{{$callResourceLockRefresh['resourceId']}}");
    });
    @endisset
</script>