pass locale related info into oauth guide page props

This commit is contained in:
myl7 2022-02-08 17:17:21 +08:00
parent 3773a3a2cf
commit ed6dcc926f
No known key found for this signature in database
GPG key ID: 04F1013B67177C88
3 changed files with 21 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import Head from 'next/head'
import Image from 'next/image'
import { useRouter } from 'next/router'
import { useTranslation, Trans } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import siteConfig from '../../config/site.config'
import apiConfig from '../../config/api.config'
@ -145,3 +146,11 @@ export default function OAuthStep1() {
</div>
)
}
export async function getServerSideProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ['common']))
}
}
}

View file

@ -4,6 +4,7 @@ import { useRouter } from 'next/router'
import { useState } from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useTranslation, Trans } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import siteConfig from '../../config/site.config'
import Navbar from '../../components/Navbar'
@ -138,3 +139,11 @@ export default function OAuthStep2() {
</div>
)
}
export async function getServerSideProps({ locale }) {
return {
props: {
...(await serverSideTranslations(locale, ['common']))
}
}
}

View file

@ -4,6 +4,7 @@ import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useTranslation, Trans } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import siteConfig from '../../config/site.config'
import Navbar from '../../components/Navbar'
@ -221,7 +222,7 @@ export default function OAuthStep3({ accessToken, expiryTime, refreshToken, erro
)
}
export async function getServerSideProps({ query }) {
export async function getServerSideProps({ query, locale }) {
const { authCode } = query
// Return if no auth code is present
@ -255,6 +256,7 @@ export async function getServerSideProps({ query }) {
expiryTime,
accessToken,
refreshToken,
...(await serverSideTranslations(locale, ['common']))
},
}
}