Skip to content

Commit

Permalink
fix(accept-necessary): correct setter
Browse files Browse the repository at this point in the history
Resolves #13.
  • Loading branch information
dargmuesli committed Dec 14, 2022
1 parent b45b9dd commit f0881a7
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/runtime/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ import { LOCALE_DEFAULT } from './constants'
import { Cookie, ModuleOptions, Translatable } from './types'

export const useAcceptNecessary = () => {
const { cookiesEnabled, isConsentGiven, moduleOptions } = useCookieControl()
const { cookiesEnabled, /* isConsentGiven, */ moduleOptions } =
useCookieControl()
// const nuxtApp = useNuxtApp()

return () =>
acceptNecessary(
// nuxtApp,
cookiesEnabled,
isConsentGiven,
// isConsentGiven,
moduleOptions.cookies?.necessary
)
}

export const acceptNecessary = (
// nuxtApp: NuxtApp,
cookiesEnabledRef: Ref<Cookie[]>,
isConsentGivenRef: Ref<boolean>,
// isConsentGivenRef: Ref<boolean>,
cookiesNecessary: Cookie[] = []
) => {
const expires = new Date()
Expand All @@ -34,17 +35,14 @@ export const acceptNecessary = (
)

setCookies({
isConsentGiven: isConsentGivenRef.value,
isConsentGiven: true,
cookieIds: necessaryCookieIds,
expires,
})

isConsentGivenRef.value = true

if (process.client) {
setHead(/* nuxtApp, */ cookiesEnabledRef.value)
// callAcceptedFunctions(nuxtApp, enabled.value)
}
setHead(/* nuxtApp, */ cookiesEnabledRef.value)
// callAcceptedFunctions(nuxtApp, enabled.value)
window.location.reload()
}

export const useResolveTranslatable = (locale = LOCALE_DEFAULT) => {
Expand Down

0 comments on commit f0881a7

Please sign in to comment.