diff --git a/src/api/index.js b/src/api/index.js index a5f073295..61293f1d8 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -9,8 +9,18 @@ class APIService { this.defaultHeaders = { 'Content-Type': 'application/json', }; + this.unsubscribe = this.services.i18n.subscribe((locale) => { + this.updateLanguageHeader(locale); + }); + + this.updateLanguageHeader(this.services.i18n.getLocale()); + + } + updateLanguageHeader(locale) { + this.defaultHeaders['Accept-Language'] = locale || 'ru'; } + /** * HTTP запрос * @param url @@ -41,6 +51,12 @@ class APIService { delete this.defaultHeaders[name]; } } + destroy() { + if (this.unsubscribe) { + this.unsubscribe(); + this.unsubscribe = null; + } + } } export default APIService; diff --git a/src/app/article/index.js b/src/app/article/index.js index 54f037b64..50d9646bd 100644 --- a/src/app/article/index.js +++ b/src/app/article/index.js @@ -13,7 +13,9 @@ import TopHead from '../../containers/top-head'; import { useDispatch, useSelector } from 'react-redux'; import shallowequal from 'shallowequal'; import articleActions from '../../store-redux/article/actions'; +import commentsActions from '../../store-redux/comments/actions'; import HeadLayout from '../../components/head-layout'; +import CommentsWrapper from '../../components/comments-wrapper'; function Article() { const store = useStore(); @@ -26,11 +28,14 @@ function Article() { useInit(() => { //store.actions.article.load(params.id); dispatch(articleActions.load(params.id)); + dispatch(commentsActions.load(params.id)); }, [params.id]); const select = useSelector( state => ({ article: state.article.data, + comments: state.comments.data, + commentsWaiting: state.comments.waiting, waiting: state.article.waiting, }), shallowequal, @@ -42,7 +47,6 @@ function Article() { // Добавление в корзину addToBasket: useCallback(_id => store.actions.basket.addToBasket(_id), [store]), }; - return ( <> @@ -56,6 +60,18 @@ function Article() { + {select.commentsWaiting ? ( +
+ Загрузка комментариев... +
+ ) : ( + + )} ); diff --git a/src/app/login/index.js b/src/app/login/index.js index 32b86daa4..3fb13833b 100644 --- a/src/app/login/index.js +++ b/src/app/login/index.js @@ -15,6 +15,7 @@ import useInit from '../../hooks/use-init'; import HeadLayout from '../../components/head-layout'; import Form from '../../components/form'; + function Login() { const { t } = useTranslate(); const location = useLocation(); diff --git a/src/components/article-card/index.js b/src/components/article-card/index.js index d636d9f88..76ef8706c 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(`product.country`)}:
{article.madeIn?.title} ({article.madeIn?.code})
-
Категория:
+
{t(`product.category`)}:
{article.category?.title}
-
Год выпуска:
+
{t(`product.year`)}:
{article.edition}
-
Цена:
+
{t(`product.price`)}:
{numberFormat(article.price)} ₽