Merge from dev #8

Merged
Horhik merged 2 commits from dev into master 2020-04-22 18:51:42 +00:00
5 changed files with 14 additions and 8 deletions
Showing only changes of commit d72ed24dfa - Show all commits

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,