function formAction(elem)
{
    event.preventDefault();
    var action = $(elem).attr('action');
    var method = $(elem).attr('method');
    if(method == 'GET')
    {
        var dataform = $(elem).serialize();
    }
    else
    {
        var dataform = new FormData( $(elem)[0]);
    }

    $.ajax
    ({
        url : action,
        type: method,
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        data: dataform,
        dataType:'json',
        contentType: false,
        processData: false,
        success:function(data)
        {
            if('data' in data)
            {
                toasterSuccess(data.message);
                setTimeout(
                    function()
                    {
                        window.location.href = data.data
                    }, 1000);
            }
            else
            {
                toasterError(Object.values(data.errors)[0]);
            }
        }
        ,error:function(data)
        {
            toasterError(Object.values(data.responseJSON.errors)[0]);
        }
    })
}


function copyClipboard(elem)
{
    let textCopy = $(elem).attr('clipboard-id');
    navigator.clipboard.writeText(textCopy)
}
