|
Server : Apache System : Linux s1230 5.15.0-139-generic #149~20.04.1 SMP Tue Jul 14 11:21:49 UTC 2026 x86_64 User : p141464 ( 418825) PHP Version : 7.4.33.12 Disable Function : NONE Directory : /html/relaunch-kmu/wp-content/plugins/wp-gdpr-compliance/Resources/js/components/ |
Upload File : |
import { _saveCookie, ajax, ajaxDataParams } from '../utils/helpers'
export const _setConsentCookie = async (checked = 'all') => {
const prefix = wpgdprcFront.prefix
const ajaxUrl = wpgdprcFront.ajaxUrl
const ajaxNonce = wpgdprcFront.ajaxNonce
const ajaxArg = wpgdprcFront.ajaxArg
const cookieName = wpgdprcFront.cookieName
let isLoading = true
// Do the call
try {
await ajax(ajaxUrl, {
action: prefix + '_consent_cookie',
[ajaxArg]: ajaxNonce,
...ajaxDataParams({
checked: checked
})
}, 'POST').then(response => {
return response.json()
}).then(response => {
isLoading = false
const success = typeof response.success !== 'undefined' ? response.success : false
if (!success) {
console.dir(response)
return
}
const message = typeof response.message !== 'undefined' ? response.message : false
_saveCookie(cookieName, message)
window.location.reload(true)
})
} catch (error) {
console.error(error)
isLoading = false
}
return isLoading
}