Merge pull request #127 from jedmund/fix-language-switch

Fix language switch in logged-out menu
This commit is contained in:
Justin Edmund 2023-01-03 23:13:36 -08:00 committed by GitHub
commit 81c6c22337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 12 deletions

View file

@ -88,8 +88,9 @@
display: block;
height: $diameter;
width: $diameter;
transition: transform 100ms;
transform: translateX(-2px);
position: absolute;
top: 3px;
left: 3px;
z-index: 3;
&:hover {
@ -98,7 +99,7 @@
&[data-state='checked'] {
background: $grey-100;
transform: translateX(17px);
left: 23px;
}
}

View file

@ -1,5 +1,5 @@
interface GranblueCookie {
account: AccountCookie
user: UserCookie
account?: AccountCookie
user?: UserCookie
locale: string
}

View file

@ -6,18 +6,20 @@ export default function retrieveCookies(
res?: NextApiResponse
): GranblueCookie | undefined {
const cookies = getCookies({ req, res })
if (!cookies) return undefined
const {
account: accountData,
user: userData,
NEXT_LOCALE: localeData,
} = cookies
if (!accountData || !userData) return undefined
if ((!accountData || !userData) && localeData)
return { account: undefined, user: undefined, locale: localeData }
if (accountData && userData) {
const account = JSON.parse(decodeURIComponent(accountData)) ?? undefined
const user = JSON.parse(decodeURIComponent(userData)) ?? undefined
const locale = localeData as string
return { account, user, locale }
}
}