김서영

add reducers

......@@ -23,13 +23,14 @@ export const load = () => async (dispatch) =>{
export const submit = (text) => async (dispatch) => {
dispatch( {type:START});
try{
const response = await sendSearch(text.nativeEvent.text);
let tempScore = scoring(response.return_data).full;
await sqlite.insert(tempScore);
const response = await readTest()
//const response = await sendSearch(text.nativeEvent.text);
let tempScore = scoring(response.return_data);
await sqlite.insert(tempScore.full);
let past = await sqlite.select();
past = past.map( elem => elem.score );
//dispatch( { type:SUCCESS, result:response }
dispatch( { type:SUCCESS, result:response, past: past})
dispatch( { type:SUCCESS, result:response, past: past, score:tempScore})
}
catch(err){
console.log(err);
......@@ -51,6 +52,7 @@ const initialState = {
searchResults: []
}
},
score : {},
isLoading: false,
pastScore: [10,10,10,10,10,10],
};
......@@ -60,7 +62,8 @@ export default ToggleLoading = (state = initialState, action) => {
case CHANGE:
return {...state, query: action.text};
case SUCCESS:
return {...state, isLoading:false,result: action.result, pastScore: action.past};
return {...state, isLoading:false, score: action.score,
result: action.result, pastScore: action.past};
case FAILURE:
return {...state, isLoading:false};
case START:
......