Skip to content

Commit b871c12

Browse files
Update CreateTranslation Component (#7543)
Co-authored-by: David Glick <[email protected]>
1 parent 8979a40 commit b871c12

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/volto/news/7543.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Get translationObject from the store instead of directly from the response in CreateTranslation component. @rboixaderg

packages/volto/src/components/manage/Multilingual/CreateTranslation.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,20 @@ const CreateTranslation = (props) => {
1212
const dispatch = useDispatch();
1313
const { language, translationOf } = props.location.state;
1414
const [translationLocation, setTranslationLocation] = React.useState(null);
15-
const [translationObject, setTranslationObject] = React.useState(null);
1615
const languageFrom = useSelector((state) => state.intl.locale);
1716

17+
const translationObject = useSelector(
18+
(state) => state.content.subrequests['translationObject'],
19+
);
20+
1821
React.useEffect(() => {
1922
// Only on mount, we dispatch the locator query
2023
dispatch(getTranslationLocator(translationOf, language)).then((resp) => {
2124
setTranslationLocation(resp['@id']);
2225
});
2326

2427
//and we load the translationObject
25-
dispatch(getContent(translationOf, null, 'translationObject')).then(
26-
(resp) => {
27-
setTranslationObject(resp);
28-
},
29-
);
28+
dispatch(getContent(translationOf, null, 'translationObject'));
3029

3130
// On unmount we dispatch the language change
3231
return () => {
@@ -46,15 +45,16 @@ const CreateTranslation = (props) => {
4645

4746
return (
4847
translationLocation &&
49-
translationObject && (
48+
translationObject.data &&
49+
translationObject.loaded > 0 && (
5050
<Redirect
5151
to={{
5252
pathname: `${flattenToAppURL(translationLocation)}/add`,
5353
search: `?type=${props.location.state.type}`,
5454
state: {
5555
translationOf: props.location.state.translationOf,
5656
language: props.location.state.language,
57-
translationObject: translationObject,
57+
translationObject: translationObject.data,
5858
languageFrom,
5959
},
6060
}}

0 commit comments

Comments
 (0)