diff --git a/src/api/index.js b/src/api/index.js
index a5f073295..49c70a63a 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -9,6 +9,14 @@ class APIService {
this.defaultHeaders = {
'Content-Type': 'application/json',
};
+
+ const i18n = this.services?.i18n;
+ if (i18n) {
+ this.setHeader('X-Lang', i18n.locale);
+ i18n.subscribe(locale => {
+ return this.setHeader('X-Lang', locale);
+ });
+ }
}
/**
@@ -41,6 +49,11 @@ class APIService {
delete this.defaultHeaders[name];
}
}
+
+ updateLanguageHeader(locale) {
+ this.languageHeader = locale;
+ this.setHeader('Accept-Language', locale);
+ }
}
export default APIService;
diff --git a/src/app/article/index.js b/src/app/article/index.js
index 54f037b64..78bc0b096 100644
--- a/src/app/article/index.js
+++ b/src/app/article/index.js
@@ -13,25 +13,31 @@ 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 listToTree from '../../utils/list-to-tree';
+import CommentList from '../../components/comment-list';
function Article() {
const store = useStore();
const dispatch = useDispatch();
- // Параметры из пути /articles/:id
const params = useParams();
useInit(() => {
- //store.actions.article.load(params.id);
+ // store.actions.article.load(params.id);
dispatch(articleActions.load(params.id));
+ dispatch(commentsActions.load(params.id));
+ // store.actions.comments.getCommentsById(params.id);
}, [params.id]);
const select = useSelector(
state => ({
article: state.article.data,
waiting: state.article.waiting,
+ comments: state.comments.data,
+ count: state.comments.count,
}),
shallowequal,
); // Нужно указать функцию для сравнения свойства объекта, так как хуком вернули объект
@@ -42,6 +48,14 @@ function Article() {
// Добавление в корзину
addToBasket: useCallback(_id => store.actions.basket.addToBasket(_id), [store]),
};
+
+ let buildComments = [];
+
+ if (Array.isArray(select?.comments) && select.comments.length > 0) {
+ buildComments = listToTree(select?.comments)[0].children;
+ } else {
+ console.log('Комментарии еще не загружены или пусты');
+ }
return (
<>
@@ -55,6 +69,7 @@ function Article() {
+
>
diff --git a/src/app/login/index.js b/src/app/login/index.js
index 32b86daa4..6a7ddcd90 100644
--- a/src/app/login/index.js
+++ b/src/app/login/index.js
@@ -47,6 +47,7 @@ function Login() {
e.preventDefault();
store.actions.session.signIn(data, () => {
// Возврат на страницу, с которой пришли
+ console.log('back', location.state?.back);
const back =
location.state?.back && location.state?.back !== location.pathname
? location.state?.back
diff --git a/src/components/article-card/index.js b/src/components/article-card/index.js
index d636d9f88..edccea820 100644
--- a/src/components/article-card/index.js
+++ b/src/components/article-card/index.js
@@ -7,7 +7,9 @@ import './style.css';
function ArticleCard(props) {
const { article, onAdd = () => {}, t = text => text } = props;
+
const cn = bem('ArticleCard');
+
return (
{article.description}
@@ -31,7 +33,7 @@ function ArticleCard(props) {
Цена:
{numberFormat(article.price)} ₽
-