Skip to content

Commit

Permalink
fix: add language to comparison share url
Browse files Browse the repository at this point in the history
  • Loading branch information
allohamora committed Mar 18, 2022
1 parent 9f9eaaa commit 66b66f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/views/Comparison/ComparisonContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const ComparisonContent: FC<Props> = ({ pizzasIds, removePizzas, isReady,
const searchParams = new URLSearchParams([['isUrl', '1'], ...pizzasIds.map((id) => [id, '1'])]);
const query = searchParams.toString();

await navigator.clipboard.writeText(join(basePath, `/comparison?${query}`));
await navigator.clipboard.writeText(join(basePath, `${language}/comparison?${query}`));

notification.open({
message: t('copied'),
Expand Down
6 changes: 5 additions & 1 deletion src/views/Comparison/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FC } from 'react';
import { useRouter } from 'next/router';
import { useComparison } from 'src/providers/ComparisonProvider';
import { useConfig } from 'src/providers/ConfigProvider';
import { ComparisonContent } from './ComparisonContent';

export const Comparison: FC = () => {
Expand All @@ -9,6 +10,9 @@ export const Comparison: FC = () => {
query: { isUrl, ...query },
} = router;
const comparison = useComparison();
const {
config: { language },
} = useConfig();

const queryPizzasIds = Object.keys(query);
const isUrlVariant = isUrl === '1';
Expand All @@ -17,7 +21,7 @@ export const Comparison: FC = () => {
const newIds = queryPizzasIds.filter((id) => !ids.includes(id));
const urlSearchParams = new URLSearchParams([['isUrl', '1'], ...newIds.map((id) => [id, '1'])]);

router.replace(`/comparison?${urlSearchParams.toString()}`);
router.replace(`${language}/comparison?${urlSearchParams.toString()}`);
};

if (isUrlVariant) {
Expand Down

0 comments on commit 66b66f2

Please sign in to comment.