mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 16:22:59 +10:00
fix(printer/i18n): fix dates not showing up in resume language when printing
fix #729
This commit is contained in:
@ -3,6 +3,7 @@ import clsx from 'clsx';
|
|||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import { GetServerSideProps, NextPage } from 'next';
|
import { GetServerSideProps, NextPage } from 'next';
|
||||||
|
import { useRouter } from 'next/router';
|
||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ type QueryParams = {
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
resume?: Resume;
|
resume?: Resume;
|
||||||
|
locale: string;
|
||||||
redirect?: any;
|
redirect?: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,7 +37,13 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
|
|||||||
const resume = await fetchResumeByIdentifier({ username, slug, options: { secretKey } });
|
const resume = await fetchResumeByIdentifier({ username, slug, options: { secretKey } });
|
||||||
const displayLocale = resume.metadata.locale || locale || 'en';
|
const displayLocale = resume.metadata.locale || locale || 'en';
|
||||||
|
|
||||||
return { props: { resume, ...(await serverSideTranslations(displayLocale, ['common'])) } };
|
return {
|
||||||
|
props: {
|
||||||
|
resume,
|
||||||
|
locale: displayLocale,
|
||||||
|
...(await serverSideTranslations(displayLocale, ['common'])),
|
||||||
|
},
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
@ -46,7 +54,9 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Printer: NextPage<Props> = ({ resume: initialData }) => {
|
const Printer: NextPage<Props> = ({ resume: initialData, locale }) => {
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const resume = useAppSelector((state) => state.resume);
|
const resume = useAppSelector((state) => state.resume);
|
||||||
@ -55,6 +65,12 @@ const Printer: NextPage<Props> = ({ resume: initialData }) => {
|
|||||||
if (initialData) dispatch(setResume(initialData));
|
if (initialData) dispatch(setResume(initialData));
|
||||||
}, [dispatch, initialData]);
|
}, [dispatch, initialData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const { pathname, asPath, query } = router;
|
||||||
|
|
||||||
|
router.push({ pathname, query }, asPath, { locale });
|
||||||
|
}, [router, locale]);
|
||||||
|
|
||||||
if (!resume || isEmpty(resume)) return null;
|
if (!resume || isEmpty(resume)) return null;
|
||||||
|
|
||||||
const layout: string[][][] = get(resume, 'metadata.layout', []);
|
const layout: string[][][] = get(resume, 'metadata.layout', []);
|
||||||
|
|||||||
Reference in New Issue
Block a user