diff --git a/src/api/index.js b/src/api/index.js index a5f073295..6a87d7ca1 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -8,7 +8,12 @@ class APIService { this.config = config; this.defaultHeaders = { 'Content-Type': 'application/json', + 'X-Lang': services.i18n.getLang(), }; + + this.services.i18n.subscribe((lang) => { + return this.setHeader('X-Lang', lang); + }); } /** diff --git a/src/app/article/index.js b/src/app/article/index.js index 54f037b64..1cab6eda6 100644 --- a/src/app/article/index.js +++ b/src/app/article/index.js @@ -13,10 +13,14 @@ 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 CommentList from '../../containers/comment-list'; + function Article() { const store = useStore(); + const { t, lang } = useTranslate(); const dispatch = useDispatch(); // Параметры из пути /articles/:id @@ -26,7 +30,8 @@ function Article() { useInit(() => { //store.actions.article.load(params.id); dispatch(articleActions.load(params.id)); - }, [params.id]); + dispatch(commentsActions.load(params.id)); + }, [params.id, lang]); const select = useSelector( state => ({ @@ -36,13 +41,13 @@ function Article() { shallowequal, ); // Нужно указать функцию для сравнения свойства объекта, так как хуком вернули объект - const { t } = useTranslate(); const callbacks = { // Добавление в корзину addToBasket: useCallback(_id => store.actions.basket.addToBasket(_id), [store]), }; + return ( <> @@ -56,6 +61,7 @@ function Article() { + ); diff --git a/src/app/login/index.js b/src/app/login/index.js index 32b86daa4..e5f44f1af 100644 --- a/src/app/login/index.js +++ b/src/app/login/index.js @@ -46,6 +46,7 @@ function Login() { e => { e.preventDefault(); store.actions.session.signIn(data, () => { + console.log(location.state); // Возврат на страницу, с которой пришли const back = location.state?.back && location.state?.back !== location.pathname @@ -69,7 +70,12 @@ function Login() { -
+ { await Promise.all([store.actions.catalog.initParams(), store.actions.categories.load()]); }, - [], + [lang], true, ); - const { t } = useTranslate(); return ( <> diff --git a/src/components/comment-input/index.js b/src/components/comment-input/index.js new file mode 100644 index 000000000..038942531 --- /dev/null +++ b/src/components/comment-input/index.js @@ -0,0 +1,35 @@ +import { memo, useCallback, useLayoutEffect, useState } from 'react'; +import PropTypes from 'prop-types'; +import { cn as bem } from '@bem-react/classname'; + +import './style.css'; + +function CommentInput(props) { + const { onChange = () => {}, type = 'text' } = props; + + // Обработчик изменений в поле + const onChangeHandler = event => { + onChange(event.target.value); + }; + + + const cn = bem('CommentInput'); + return ( +