Skip to content

Commit

Permalink
Merge branch 'release/3.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
allohamora committed Mar 18, 2022
2 parents c2243a7 + 657c10b commit 0c180e2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/views/Comparison/ComparisonContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export const ComparisonContent: FC<Props> = ({ 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'),
Expand Down
16 changes: 10 additions & 6 deletions src/views/Comparison/index.tsx
Original file line number Diff line number Diff line change
@@ -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 <ComparisonContent pizzasIds={queryPizzasIds} removePizzas={urlRemovePizzas} isReady type="external" />;
}

Expand Down
7 changes: 4 additions & 3 deletions src/views/Pizza/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <Seo title={title ?? t('loading')} description={description ?? t('loading')} />;
const seo = <Seo title={titleText ?? t('loading')} description={description ?? t('loading')} />;

if (isLoading) {
return (
Expand All @@ -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) {
Expand Down Expand Up @@ -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'));

Expand Down

0 comments on commit 0c180e2

Please sign in to comment.