import React from 'react'; import type { NextPage, GetServerSideProps, GetServerSidePropsContext } from 'next'; import { useTranslation } from 'next-i18next'; import { serverSideTranslations } from 'next-i18next/serverSideTranslations'; import Link from 'next/link'; import { forgotPasswordErrorCode } from '~/interfaces/errors/forgot-password'; import type { CommonProps } from './utils/commons'; import { getNextI18NextConfig, getServerSideCommonProps } from './utils/commons'; type Props = CommonProps & { errorCode?: forgotPasswordErrorCode }; const ForgotPasswordErrorsPage: NextPage = (props: Props) => { const { t } = useTranslation(); const { errorCode } = props; return (

lock_open

{ t('forgot_password.reset_password') }

{ errorCode == null && (

errorCode Unknown

)} { errorCode === forgotPasswordErrorCode.PASSWORD_RESET_IS_UNAVAILABLE && (

{ t('forgot_password.feature_is_unavailable') }

)} { (errorCode === forgotPasswordErrorCode.PASSWORD_RESET_ORDER_IS_NOT_APPROPRIATE || errorCode === forgotPasswordErrorCode.TOKEN_NOT_FOUND) && (

{ t('forgot_password.incorrect_token_or_expired_url') }

key { t('forgot_password.forgot_password') }
) }
); }; async function injectNextI18NextConfigurations(context: GetServerSidePropsContext, props: Props, namespacesRequired?: string[] | undefined): Promise { const nextI18NextConfig = await getNextI18NextConfig(serverSideTranslations, context, namespacesRequired); props._nextI18Next = nextI18NextConfig._nextI18Next; } export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => { const result = await getServerSideCommonProps(context); // check for presence // see: https://github.com/vercel/next.js/issues/19271#issuecomment-730006862 if (!('props' in result)) { throw new Error('invalid getSSP result'); } const props: Props = result.props as Props; const errorCode = context.query.errorCode; if (typeof errorCode === 'string') { props.errorCode = errorCode as forgotPasswordErrorCode; } await injectNextI18NextConfigurations(context, props, ['translation']); return { props, }; }; export default ForgotPasswordErrorsPage;