-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from ctcusc/yq-connect-video-to-questions
Yq connect video to questions
- Loading branch information
Showing
12 changed files
with
346 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,66 @@ | ||
const initialState = { | ||
videos: [] | ||
} | ||
|
||
|
||
const initialState = | ||
[{ | ||
questionID: 1, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 2, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 3, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 4, | ||
uri: null, | ||
questionText: null, | ||
},{ | ||
questionID: 5, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 6, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 7, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 8, | ||
uri: null, | ||
questionText: null, | ||
},{ | ||
questionID: 9, | ||
uri: null, | ||
questionText: null, | ||
}, | ||
{ | ||
questionID: 10, | ||
uri: null, | ||
questionText: null, | ||
}] | ||
|
||
function rootReducer(state = initialState, action) { | ||
if (action.type === 'SAVE_VIDEO') { | ||
return { | ||
...state, | ||
videos: state.videos.concat(action.payload) | ||
} | ||
return state.map(videoObj => { | ||
// found: update video | ||
if (videoObj.questionID === action.payload.questionID) { | ||
return action.payload | ||
} | ||
// not the video we are looking for continue | ||
return videoObj | ||
}) | ||
} | ||
return state | ||
} | ||
|
||
export default rootReducer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.