김서영

add reducers

...@@ -23,13 +23,14 @@ export const load = () => async (dispatch) =>{ ...@@ -23,13 +23,14 @@ export const load = () => async (dispatch) =>{
23 export const submit = (text) => async (dispatch) => { 23 export const submit = (text) => async (dispatch) => {
24 dispatch( {type:START}); 24 dispatch( {type:START});
25 try{ 25 try{
26 - const response = await sendSearch(text.nativeEvent.text); 26 + const response = await readTest()
27 - let tempScore = scoring(response.return_data).full; 27 + //const response = await sendSearch(text.nativeEvent.text);
28 - await sqlite.insert(tempScore); 28 + let tempScore = scoring(response.return_data);
29 + await sqlite.insert(tempScore.full);
29 let past = await sqlite.select(); 30 let past = await sqlite.select();
30 past = past.map( elem => elem.score ); 31 past = past.map( elem => elem.score );
31 //dispatch( { type:SUCCESS, result:response } 32 //dispatch( { type:SUCCESS, result:response }
32 - dispatch( { type:SUCCESS, result:response, past: past}) 33 + dispatch( { type:SUCCESS, result:response, past: past, score:tempScore})
33 } 34 }
34 catch(err){ 35 catch(err){
35 console.log(err); 36 console.log(err);
...@@ -51,6 +52,7 @@ const initialState = { ...@@ -51,6 +52,7 @@ const initialState = {
51 searchResults: [] 52 searchResults: []
52 } 53 }
53 }, 54 },
55 + score : {},
54 isLoading: false, 56 isLoading: false,
55 pastScore: [10,10,10,10,10,10], 57 pastScore: [10,10,10,10,10,10],
56 }; 58 };
...@@ -60,7 +62,8 @@ export default ToggleLoading = (state = initialState, action) => { ...@@ -60,7 +62,8 @@ export default ToggleLoading = (state = initialState, action) => {
60 case CHANGE: 62 case CHANGE:
61 return {...state, query: action.text}; 63 return {...state, query: action.text};
62 case SUCCESS: 64 case SUCCESS:
63 - return {...state, isLoading:false,result: action.result, pastScore: action.past}; 65 + return {...state, isLoading:false, score: action.score,
66 + result: action.result, pastScore: action.past};
64 case FAILURE: 67 case FAILURE:
65 return {...state, isLoading:false}; 68 return {...state, isLoading:false};
66 case START: 69 case START:
......