diff --git a/CHANGELOG.md b/CHANGELOG.md index 4307efa..ac9a274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [3.1.1](https://github.com/allohamora/chepi-front/compare/v3.1.0...v3.1.1) (2022-03-18) + +### Bug Fixes + +- add language to comparison share url ([66b66f2](https://github.com/allohamora/chepi-front/commits/66b66f214a169e9092ab9f60ff576b87f39db200)) +- fix pizza seo title and description ([9f9eaaa](https://github.com/allohamora/chepi-front/commits/9f9eaaa12395fa953be6f75dd3d2b7f1e80eb28a)) +- normalize comparison query ids ([cf5b6d6](https://github.com/allohamora/chepi-front/commits/cf5b6d669be53fb500d8390904b9842a0df72b20)) + ## [3.1.0](https://github.com/allohamora/chepi-front/compare/v3.0.0...v3.1.0) (2022-03-17) ### Features diff --git a/package-lock.json b/package-lock.json index 0df3e52..a78acab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "chepi-front", - "version": "3.1.0", + "version": "3.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "chepi-front", - "version": "3.1.0", + "version": "3.1.1", "license": "MIT", "dependencies": { "@ant-design/icons": "^4.7.0", diff --git a/package.json b/package.json index ecf0675..4cf1ac1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chepi-front", - "version": "3.1.0", + "version": "3.1.1", "description": "front-end for chepi", "author": "https://github.com/allohamora", "private": true, diff --git a/src/views/Comparison/ComparisonContent.tsx b/src/views/Comparison/ComparisonContent.tsx index fcb4028..9ceb908 100644 --- a/src/views/Comparison/ComparisonContent.tsx +++ b/src/views/Comparison/ComparisonContent.tsx @@ -96,10 +96,10 @@ export const ComparisonContent: FC = ({ pizzasIds, removePizzas, isReady, }; const shareHandler = async () => { - const searchParams = new URLSearchParams([['isUrl', '1'], ...pizzasIds.map((id) => [id, '1'])]); + const searchParams = new URLSearchParams([['isExternal', '1'], ...pizzasIds.map((id) => ['ids', id])]); 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'), diff --git a/src/views/Comparison/index.tsx b/src/views/Comparison/index.tsx index 168b5e1..2c2c81c 100644 --- a/src/views/Comparison/index.tsx +++ b/src/views/Comparison/index.tsx @@ -1,26 +1,30 @@ 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 = () => { const router = useRouter(); const { - query: { isUrl, ...query }, + query: { isExternal, ids: queryIds }, } = router; const comparison = useComparison(); + const { + config: { language }, + } = useConfig(); - const queryPizzasIds = Object.keys(query); - const isUrlVariant = isUrl === '1'; + const queryPizzasIds = (typeof queryIds === 'string' ? [queryIds] : queryIds) ?? []; + const isExternalVariant = isExternal === '1'; const urlRemovePizzas = (...ids: string[]) => { const newIds = queryPizzasIds.filter((id) => !ids.includes(id)); - const urlSearchParams = new URLSearchParams([['isUrl', '1'], ...newIds.map((id) => [id, '1'])]); + const urlSearchParams = new URLSearchParams([['isExternal', '1'], ...newIds.map((id) => ['ids', id])]); - router.replace(`/comparison?${urlSearchParams.toString()}`); + router.replace(`${language}/comparison?${urlSearchParams.toString()}`); }; - if (isUrlVariant) { + if (isExternalVariant) { return ; } diff --git a/src/views/Pizza/index.tsx b/src/views/Pizza/index.tsx index 4051967..c9028d5 100644 --- a/src/views/Pizza/index.tsx +++ b/src/views/Pizza/index.tsx @@ -40,10 +40,12 @@ export const Pizza: FC = () => { const titleKey = `${lang as Lang}_title` as const; const title = data?.[titleKey]; + const titleText = createTitleText(title as string, data?.size ?? null, tValue('cm')); + const descriptionKey = `${lang as Lang}_description` as const; const description = data?.[descriptionKey]; - const seo = ; + const seo = ; if (isLoading) { return ( @@ -68,7 +70,7 @@ export const Pizza: FC = () => { ); } - const { country, city, lang: pizzaLang, image, link, price, size, weight, historyOfChanges } = data as PizzaType; + const { country, city, lang: pizzaLang, image, link, price, weight, historyOfChanges } = data as PizzaType; const getChangeTitle = (key: string) => { if (key === titleKey) { @@ -98,7 +100,6 @@ export const Pizza: FC = () => { detectedAt: change.detectedAt, })) ?? []; - const titleText = createTitleText(title as string, size, tValue('cm')); const weightText = createWeightText(weight, tValue('gram')); const pirceText = createPriceText(price, tValue('uah'));