Skip to content

Commit

Permalink
Merge pull request #1009 from nataliauvarova/staging
Browse files Browse the repository at this point in the history
#971: fix error on page /distance_map (for react 18)
  • Loading branch information
nataliauvarova authored Jul 17, 2023
2 parents dd3a448 + 199d760 commit 3777b1e
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/pages/DistanceMap/selectorLangGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class FilterDictionaries extends React.Component {
}

render() {

const { newProps } = this.props;

const { mainGroupDictionaresAndLanguages, onLangsDictsChange, selectedLanguages } = newProps;
Expand Down Expand Up @@ -151,12 +152,12 @@ FilterDictionaries.propTypes = {
}).isRequired
};

function SelectorLangGroup(props) {
const SelectorLangGroup = ((props) => {
const getTranslation = useContext(TranslationContext);

const location = useLocation();
const navigate = useNavigate();

/* Initializing here due to eact-hooks/rules-of-hooks, exact same hook order. */

const { actions, dataForTree, client, mainGroupDictionaresAndLanguages, selected, user } = props;
Expand All @@ -172,6 +173,7 @@ function SelectorLangGroup(props) {
}, [location, navigate]);

try {

if (!location.state) {
navigate("/distance_map");
return null;
Expand All @@ -186,20 +188,24 @@ function SelectorLangGroup(props) {
</div>
);
}

const { mainPerspectives } = location.state;
let selectedLanguagesChecken = [];
let rootLanguage = {};
const arrDictionariesGroup = [];
const parentId = mainPerspectives[0].parent_id;

client
useEffect(() => {

client
.query({
query: dictionaryName,
variables: { id: parentId }
})
.then(result => setMainDictionary(result.data.dictionary));

}, [mainDictionary]);

if (mainGroupDictsAndLangs.dictionaries) {
mainGroupDictsAndLangs.dictionaries.forEach(el =>
dataForTree.dictionaries.forEach(dict => {
Expand All @@ -217,6 +223,7 @@ function SelectorLangGroup(props) {
}
});
}

if (selected.id !== dataForTree.idLocale) {
client
.query({
Expand Down Expand Up @@ -244,7 +251,7 @@ function SelectorLangGroup(props) {
return <Placeholder />;
}

function send() {
const send = () => {
if (arrDictionariesGroup.length) {
arrDictionariesGroup.push(mainDictionary);
actions.setDictionariesGroup({ arrDictionariesGroup });
Expand All @@ -254,15 +261,15 @@ function SelectorLangGroup(props) {
});
actions.setCheckStateTreeFlat({ selectedLanguagesChecken });
}
}
};

function selectedLanguages(e) {
const selectedLanguages = (e) => {
selectedLanguagesChecken = e;
}
};

function onLangsDictsChange(list) {
const onLangsDictsChange = (list) => {
setMainGroupDictsAndLangs(list);
}
};

return (
<div className="lingvodoc-page">
Expand All @@ -287,6 +294,7 @@ function SelectorLangGroup(props) {
</Container>
</div>
)}

<Container>
<Button
style={{ margin: "24px 20px 0 0" }}
Expand Down Expand Up @@ -318,7 +326,7 @@ function SelectorLangGroup(props) {
navigate("/distance_map");
return null;
}
}
});

SelectorLangGroup.propTypes = {
actions: PropTypes.object.isRequired,
Expand Down

0 comments on commit 3777b1e

Please sign in to comment.