1
0
Fork 0
freesewing/sites/org/pages/account/newsletter.mjs

60 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-02-18 16:11:02 +01:00
// Dependencies
import dynamic from 'next/dynamic'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
2023-08-19 18:01:22 +02:00
import { nsMerge } from 'shared/utils.mjs'
// Hooks
import { useTranslation } from 'next-i18next'
2023-02-18 16:11:02 +01: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 newsletterNs } from 'shared/components/account/newsletter.mjs'
2023-02-18 16:11:02 +01:00
// Translation namespaces used on this page
2023-08-19 18:01:22 +02:00
const ns = nsMerge(newsletterNs, authNs, pageNs)
2023-02-18 16:11:02 +01: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),
2023-02-18 16:11:02 +01:00
{ ssr: false }
)
const DynamicNewsletter = dynamic(
() => import('shared/components/account/newsletter.mjs').then((mod) => mod.NewsletterSettings),
2023-02-18 16:11:02 +01:00
{ 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-19 18:01:22 +02:00
const AccountNewsletterPage = ({ page }) => {
const { t } = useTranslation(ns)
return (
2023-08-20 18:48:40 +02:00
<PageWrapper {...page} title={t('newsletter')}>
2023-08-19 18:01:22 +02:00
<DynamicAuthWrapper>
<DynamicNewsletter title />
</DynamicAuthWrapper>
</PageWrapper>
)
}
2023-02-18 16:11:02 +01:00
export default AccountNewsletterPage
2023-02-18 16:11:02 +01:00
export async function getStaticProps({ locale }) {
return {
props: {
2023-08-19 18:01:22 +02:00
...(await serverSideTranslations(locale, ns)),
2023-03-27 19:21:27 +02:00
page: {
locale,
2023-03-27 19:21:27 +02:00
path: ['account', 'newsletter'],
},
2023-02-18 16:11:02 +01:00
},
}
}