fix sentry issue: 28c5a41aea3c4435902046e56c435e56

This commit is contained in:
Amruth Pillai
2022-11-24 15:38:21 +01:00
parent 13d972b8f3
commit 2e62eea351
2 changed files with 5 additions and 3 deletions

View File

@ -61,10 +61,12 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {
}, [dispatch, initialData]); }, [dispatch, initialData]);
useEffect(() => { useEffect(() => {
if (!isEmpty(resume) && router.locale !== resume.metadata.locale) { const locale = get(resume, 'metadata.locale', 'en');
if (!isEmpty(resume) && router.locale !== locale) {
const { pathname, asPath, query } = router; const { pathname, asPath, query } = router;
router.push({ pathname, query }, asPath, { locale: resume.metadata.locale }); router.push({ pathname, query }, asPath, { locale });
} }
}, [resume, router]); }, [resume, router]);

View File

@ -35,7 +35,7 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
if (isEmpty(secretKey)) throw new Error('There is no secret key!'); if (isEmpty(secretKey)) throw new Error('There is no secret key!');
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 = get(resume, 'metadata.locale') ?? locale ?? 'en';
return { return {
props: { props: {