(tut)
| 14 | } |
| 15 | |
| 16 | export function completeTutorial(tut) { |
| 17 | return (dispatch, getState) => { |
| 18 | const user = getState().user.data; |
| 19 | const { tutorial } = getState(); |
| 20 | if (!user.id) throw new Error("No user found"); |
| 21 | |
| 22 | // if a tutorial is passed, use the argument, otherwise use current tutorial |
| 23 | const tempTour = tut ? `${tut}` : `${tutorial}`; |
| 24 | let tempTutorials = { |
| 25 | tutorials: { |
| 26 | [tempTour]: APP_VERSION, |
| 27 | }, |
| 28 | }; |
| 29 | |
| 30 | if (user.tutorials) { |
| 31 | tempTutorials = { |
| 32 | tutorials: { |
| 33 | ...user.tutorials, |
| 34 | [tempTour]: APP_VERSION, |
| 35 | }, |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | dispatch({ type: COMPLETE_TUTORIAL }); |
| 40 | return dispatch(updateUser(user.id, tempTutorials)); |
| 41 | }; |
| 42 | } |
| 43 | |
| 44 | export function resetTutorial(tuts) { |
| 45 | return (dispatch, getState) => { |
no test coverage detected