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

View File

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

View File

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

View File

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

View File

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