@@ -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