diff --git a/api-examples/comments.http b/api-examples/comments.http index fd797fb83..bf6bc3de0 100644 --- a/api-examples/comments.http +++ b/api-examples/comments.http @@ -1,6 +1,6 @@ # Комментрии к товару -GET http://query.rest/api/v1/comments?fields=items(_id,text,dateCreate,author(profile(name)),parent(_id,_type),isDeleted),count&limit=*&search[parent]=670260bb7dd498df5525e5ed +GET http://query.rest/api/v1/comments?field=items(_id,text,dateCreate,author(profile(name)),paren(_id,_type),isDeleted),count&limit=*&search[parent]=670260bb7dd498df5525e5ed # Остальные методы в http://query.rest/api/v1/docs/ (http://localhost:8010/api/v1/docs/) diff --git a/src/api/index.js b/src/api/index.js index a5f073295..b7d9ebdf2 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -8,6 +8,7 @@ class APIService { this.config = config; this.defaultHeaders = { 'Content-Type': 'application/json', + 'X-Lang': 'ru', }; } @@ -41,6 +42,11 @@ class APIService { delete this.defaultHeaders[name]; } } + + setLangHeader(value) { + this.setHeader('X-Lang', value); + } + } export default APIService; diff --git a/src/app/article/index.js b/src/app/article/index.js index 54f037b64..e2d6b4496 100644 --- a/src/app/article/index.js +++ b/src/app/article/index.js @@ -14,8 +14,11 @@ import { useDispatch, useSelector } from 'react-redux'; import shallowequal from 'shallowequal'; import articleActions from '../../store-redux/article/actions'; import HeadLayout from '../../components/head-layout'; +import Comments from "../../containers/comments"; + function Article() { + const { t, lang } = useTranslate(); const store = useStore(); const dispatch = useDispatch(); @@ -26,7 +29,7 @@ function Article() { useInit(() => { //store.actions.article.load(params.id); dispatch(articleActions.load(params.id)); - }, [params.id]); + }, [params.id, lang]); const select = useSelector( state => ({ @@ -36,8 +39,6 @@ function Article() { shallowequal, ); // Нужно указать функцию для сравнения свойства объекта, так как хуком вернули объект - const { t } = useTranslate(); - const callbacks = { // Добавление в корзину addToBasket: useCallback(_id => store.actions.basket.addToBasket(_id), [store]), @@ -56,6 +57,7 @@ function Article() { + ); diff --git a/src/app/main/index.js b/src/app/main/index.js index d9fb1c6c2..a160e0a03 100644 --- a/src/app/main/index.js +++ b/src/app/main/index.js @@ -13,17 +13,16 @@ import HeadLayout from '../../components/head-layout'; function Main() { const store = useStore(); + const { t, lang } = useTranslate(); useInit( async () => { await Promise.all([store.actions.catalog.initParams(), store.actions.categories.load()]); }, - [], + [lang], true, ); - const { t } = useTranslate(); - return ( <> diff --git a/src/app/profile/index.js b/src/app/profile/index.js index 166d127fb..c3fdd30bd 100644 --- a/src/app/profile/index.js +++ b/src/app/profile/index.js @@ -37,7 +37,7 @@ function Profile() { - + diff --git a/src/components/article-card/index.js b/src/components/article-card/index.js index d636d9f88..f1939c78d 100644 --- a/src/components/article-card/index.js +++ b/src/components/article-card/index.js @@ -13,22 +13,22 @@ function ArticleCard(props) {
{article.description}
-
Страна производитель:
+
{t('article.madeIn')}:
{article.madeIn?.title} ({article.madeIn?.code})
-
Категория:
+
{t('article.category')}:
{article.category?.title}
-
Год выпуска:
+
{t('article.edition')}:
{article.edition}
-
Цена:
+
{t('article.price')}:
{numberFormat(article.price)} ₽