All files / src/redux actions.js

100% Statements 7/7
100% Branches 0/0
100% Functions 2/2
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                      9x   9x 1x               1x             9x   9x             9x    
import {LOGIN_SUCCESS, LOGIN_FAILURE} from './actionTypes'
import {SEARCH, SEARCH_CLEAR} from './actionTypes'
import {RECOMMENDATIONS} from './actionTypes'
import {createAction} from "redux-actions"
import {createActionThunk} from "redux-thunk-actions"
import {apiSearch, apiRecommendations} from "../spotify-api/api"
 
 
/**
 * LOGIN ACTIONS
 */
const loginSuccessAction = createAction(LOGIN_SUCCESS);
 
export const loginSuccess = (auth_token, refresh_token, expiration) => 
        loginSuccessAction({auth_token, refresh_token, expiration});
 
 
//export function loginSuccess() {
//    return {type: LOGIN_SUCCESS, auth_token, refresh_token, expiration}
//}
 
export function loginFailure(error) {
    return {type: LOGIN_FAILURE, error}
}
 
/**
 * SEARCH ACTIONS
 */
 
export const search = createActionThunk(SEARCH, apiSearch) ;
 
export const searchClear = createAction(SEARCH_CLEAR)
 
 
/**
 * RECOMMENDATIONS ACTIONS
 */
 
export const recommendations = createActionThunk(RECOMMENDATIONS, apiRecommendations)