Skip to content

Commit

Permalink
refactor(language-menu): extract cookie max-age to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Sep 23, 2024
1 parent ddeaf6d commit 2f348f7
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Switch } from "../../../atoms/switch";

// This needs to match what's set in 'libs/constants.js' on the server/builder!
const PREFERRED_LOCALE_COOKIE_NAME = "preferredlocale";
const PREFERRED_LOCALE_COOKIE_MAX_AGE = 60 * 60 * 24 * 365 * 3; // 3 years.

export function LanguageMenu({
onClose,
Expand All @@ -46,7 +47,7 @@ export function LanguageMenu({
for (const translation of translations) {
if (translation.locale === newLocale) {
setCookieValue(PREFERRED_LOCALE_COOKIE_NAME, translation.locale, {
maxAge: 60 * 60 * 24 * 365 * 3,
maxAge: PREFERRED_LOCALE_COOKIE_MAX_AGE,
});
}
}
Expand Down

0 comments on commit 2f348f7

Please sign in to comment.