SumOfUs/Champaign

View on GitHub
app/javascript/modules/cookie-consent/index.ts

Summary

Maintainability
A
0 mins
Test Coverage
import EEA_LIST from '../../shared/eea-list';

export default {
  show() {
    const cookieconsent = window['cookieconsent'];
    const I18n = window['I18n'];
    cookieconsent.initialise({
      theme: 'edgeless',
      position: 'top',
      content: {
        message: I18n.t('cookie_consent.message'),
        dismiss: I18n.t('cookie_consent.dismiss_button_text'),
        link: I18n.t('cookie_consent.privacy_policy_link_text'),
        href: I18n.lookup('cookie_consent.privacy_policy_url') || '/privacy',
      },
    });
  },

  init(countryCode: string) {
    if (EEA_LIST.includes(countryCode)) {
      import('cookieconsent').then(() => this.show());
    }
  },
};