Fix update fields bug

now fields named "Sound", "Examples", and "Pronunciation" updating
  normaly
This commit is contained in:
horhik 2020-04-22 06:19:44 +03:00
parent f906787cc2
commit d72ed24dfa
5 changed files with 14 additions and 8 deletions

View File

@ -36,7 +36,7 @@ const setDictioanry = dictioanry => ({
type: SET_PARSED_DICTIONARY,
payload: dictioanry,
});
const setLoadingState = status => ({
export const setLoadingState = status => ({
type: SET_LOADING_STATE,
payload: status,
});
@ -54,7 +54,6 @@ export const wordInfo = word => async dispatch => {
}
*/
//function which return universal template for more simple interaction with api
dispatch(setLoadingState(false));
//TODO available dictionary instead api1
await dispatch(setAvailableApi(api1));
const wordDictionary = await createDictionary(api1);

View File

@ -55,6 +55,8 @@ const FieldList = props => {
setLoadingState(false);
}
});
useEffect(() => {
}, [pronunciation])
const submit = () => {
props.setFields(props.fields);
@ -80,7 +82,7 @@ const FieldList = props => {
role={EXAMPLES}
data={{
label: 'Usage example',
values: examples || ['can not find the example'],
values: props.response.examples || ['can not find the example'],
}}
/>
<FieldEditor
@ -90,7 +92,7 @@ const FieldList = props => {
role: SOUND,
})
}
data={{values: [sound], label: 'Sound'}}
data={{values: [props.response.sound], label: 'Sound'}}
role={SOUND}
/>
<FieldEditor
@ -101,7 +103,7 @@ const FieldList = props => {
})
}
role={PRONUNCIATION}
data={{values: [pronunciation], label: 'Pronunciation'}}
data={{values: [props.response.pronunciation], label: 'Pronunciation'}}
/>
<Button style={{marginTop: 10}} onPress={submit}>
<Text>Submit</Text>

View File

@ -11,6 +11,7 @@ import FieldEditor from './Form/field-editor';
import FieldList from './Form/field-list';
import {WORD} from "../constants/anki-constants";
import {sendField} from "../actions/form-actions";
import {setLoadingState} from "../actions/api/dictionary";
const AnkiForm = props => {
const [target, setTarget] = useState('');
@ -30,8 +31,9 @@ const AnkiForm = props => {
setTarget(word);
};
const submit = () => {
props.setLoadingState(false);
props.wordInfo(target);
setSubmitted(true);
setSubmitted(props.available)
props.sendField({
text: target,
role: WORD
@ -59,10 +61,13 @@ export default connect(
data: state,
word: state.api.availableApi.word,
available: state.api.apiIsLoaded,
}),
{
checkAnkiLanModelForExisting,
wordInfo,
sendField
sendField,
setLoadingState,
},
)(AnkiForm);

View File

@ -113,7 +113,6 @@ const ankiReducer = (state = initialState, action) => {
};
}
case WORD: {
alert(action.payload);
return {
...state,
currentFields: {...state.currentFields, word: action.payload},

View File

@ -35,6 +35,7 @@ const apiReducer = (state = initialState, action) => {
availableApiName: action.payload.source,
};
case SET_PARSED_DICTIONARY:
console.log("HEEERWELFDSKFj")
return {
...state,
parsedDictionary: action.payload,