diff --git a/src/components/header/CategoryList.js b/src/components/header/CategoryList.js index fb4a12c..b65a63e 100644 --- a/src/components/header/CategoryList.js +++ b/src/components/header/CategoryList.js @@ -25,7 +25,7 @@ class CategoryList extends Component { componentDidMount() { if (!this.state.categories || this.state.categories.length === 0) { - window.categoryService.get(209).then((response) => { + window.categoryService.get(209,this.props.languageContext?.currentLanguage || this.props.i18n.language).then((response) => { console.log("response", response); if (response.children && response.children.length > 0) { this.setState({ @@ -43,7 +43,23 @@ class CategoryList extends Component { } componentDidUpdate(prevProps) { - console.log("componentDidUpdate", this.props.activeCategoryId); + console.log("componentDidUpdate", prevProps.languageContext?.currentLanguage, this.props.languageContext?.currentLanguage); + if(prevProps.languageContext?.currentLanguage !== this.props.languageContext?.currentLanguage) { + this.setState({ + categories: [], + activeCategoryId: null + },() => { + window.categoryService.get(209,this.props.languageContext?.currentLanguage || this.props.i18n.language).then((response) => { + console.log("response", response); + if (response.children && response.children.length > 0) { + this.setState({ + categories: response.children, + activeCategoryId: this.setLevel1CategoryId(this.props.activeCategoryId) + }); + } + }); + }); + } if (prevProps.activeCategoryId !== this.props.activeCategoryId) { //detect path here console.log("activeCategoryId updated", this.props.activeCategoryId);