Skip to content

Commit

Permalink
Question UI
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 18, 2020
1 parent 4813183 commit 8fe4c00
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/Reducer/RootReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ const initialState = {
const RootReducer = (state=initialState, action) =>{
switch(action.type){
case 'ADD_QUESTIONS':
let filtered_actions = action.payload.filter(question => {
return question.id;
})
return {
...state,
questions: filtered_actions
questions: action.payload
}
default:
return state;
Expand Down
1 change: 0 additions & 1 deletion src/actionCreators/AddQuestion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const addQuestions = (id,data) => {
return {
type: 'ADD_QUESTIONS',
id:id,
payload: data
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/actionCreators/AddThunkQuestion.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import addQuestions from './AddQuestion';
// import { useState } from 'react';

const AddThunkQuestion = () => {
return (dispatch) => {
fetch('http://localhost:3001/questions')
.then(res => res.json())
.then(res => {dispatch(addQuestions(Math.floor(Math.random()*3)+1,res))})
.then(res => {dispatch(addQuestions(res))})
};
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/QuestionBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ const QuestionBox = () => {
)
}

export default QuestionBox;
//Math.floor(Math.random()*3)+1
export default QuestionBox;

0 comments on commit 8fe4c00

Please sign in to comment.