This commit is contained in:
2022-11-25 20:52:59 -03:00
parent efed50cd7f
commit 9d1a1cc0f2
18 changed files with 786 additions and 1 deletions

View File

@ -0,0 +1,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js" integrity="sha512-aVKKRRi/Q/YV+4mjoKBsE4x3H+BkegoM/em46NNlCqNTmUYADjBbeNefNxYV7giUp0VxICtqdrbqU7iVaeZNXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.0/semantic.min.js" integrity="sha512-kcjXjSNAMuKRYv8VAk/rMsHzGC/M/thh4QRZAE3SM2HPAQs77N0aOVh35IpJAtLxFpzfHeYzFHf9upgnNFfQUQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
@include('layout.body.footer.scripts.main')
@stack('page_scripts')

View File

@ -0,0 +1,38 @@
<script type="text/javascript">
const Send = {
base_url: '{{$urls->api}}',
base: function({method, uri, data = null, dataType = 'json', contentType = 'application/json'}) {
const url = this.base_url + '/' + uri.replace(/^\//g, '')
const options = {
method,
url,
crossDomain: true,
headers: {
'Authorization': [
'Bearer {{$api_key}}'
]
},
dataType
}
if (method.toLowerCase() !== 'get' && data !== null) {
if (!(typeof data === 'string' || data instanceof String)) {
options['data'] = JSON.stringify(data)
}
options['contentType'] = contentType
}
return $.ajax(options)
},
get: function(uri, dataType = 'json') {
return this.base({method: 'get', uri, dataType})
},
post: function({uri, data, dataType = 'json', contentType = 'application/json'}) {
return this.base({method: 'post', uri, data, dataType, contentType})
},
put: function({uri, data, dataType = 'json', contentType = 'application/json'}) {
return this.base({method: 'put', uri, data, dataType, contentType})
},
delete: function({uri, data, dataType = 'json', contentType = 'application/json'}) {
return this.base({method: 'delete', uri, data, dataType, contentType})
}
}
</script>