fix language difference when printing resume

This commit is contained in:
Amruth Pillai
2022-09-15 19:49:57 +02:00
parent 2faa15db5a
commit ec27e5e6ab
12 changed files with 1077 additions and 1129 deletions

View File

@ -98,7 +98,7 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {
try {
const url = await mutateAsync({ username, slug });
download(`/api${url}`);
download(url);
} catch {
toast.error('Something went wrong, please try again later.');
}

View File

@ -3,6 +3,7 @@ import clsx from 'clsx';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { GetServerSideProps, NextPage } from 'next';
import { useRouter } from 'next/router';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useEffect } from 'react';
@ -54,10 +55,20 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
};
const Printer: NextPage<Props> = ({ resume: initialData, locale }) => {
const router = useRouter();
const dispatch = useAppDispatch();
const resume = useAppSelector((state) => state.resume.present);
useEffect(() => {
if (router.locale !== locale) {
const { pathname, asPath, query } = router;
router.push({ pathname, query }, asPath, { locale });
}
}, [router, locale]);
useEffect(() => {
if (initialData) dispatch(setResume(initialData));
}, [dispatch, initialData]);