1
0
Fork 0
freesewing/sites/org/pages/new/apikey.mjs

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-04-22 15:01:57 +02:00
// Dependencies
import dynamic from 'next/dynamic'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
2023-08-21 16:14:58 +02:00
import { nsMerge } from 'shared/utils.mjs'
// Hooks
import { useTranslation } from 'next-i18next'
2023-04-22 15:01:57 +02:00
// Components
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
import { ns as authNs } from 'shared/components/wrappers/auth/index.mjs'
import { ns as apikeysNs } from 'shared/components/account/apikeys.mjs'
// Translation namespaces used on this page
2023-08-21 16:14:58 +02:00
const ns = nsMerge(apikeysNs, authNs, pageNs)
2023-04-22 15:01:57 +02:00
/*
* Some things should never generated as SSR
* So for these, we run a dynamic import and disable SSR rendering
*/
const DynamicAuthWrapper = dynamic(
() => import('shared/components/wrappers/auth/index.mjs').then((mod) => mod.AuthWrapper),
{ ssr: false }
)
const DynamicNewApikey = dynamic(
() => import('shared/components/account/apikeys.mjs').then((mod) => mod.NewApikey),
{ ssr: false }
)
/*
* Each page MUST be wrapped in the PageWrapper component.
* You also MUST spread props.page into this wrapper component
* when path and locale come from static props (as here)
* or set them manually.
*/
2023-08-21 16:14:58 +02:00
const NewApikeyPage = ({ page }) => {
const { t } = useTranslation(ns)
return (
<PageWrapper {...page} title={t('newApikey')}>
<DynamicAuthWrapper>
<DynamicNewApikey standalone title={false} />
</DynamicAuthWrapper>
</PageWrapper>
)
}
2023-04-22 15:01:57 +02:00
export default NewApikeyPage
2023-04-22 15:01:57 +02:00
export async function getStaticProps({ locale }) {
return {
props: {
2023-08-21 16:14:58 +02:00
...(await serverSideTranslations(locale, ns)),
2023-04-22 15:01:57 +02:00
page: {
locale,
2023-04-22 15:01:57 +02:00
path: ['new', 'apikey'],
},
},
}
}