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

View file

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

View file

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