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