mirador
Version:
An open-source, web-based 'multi-up' viewer that supports zoom-pan-rotate functionality, ability to display/compare simple images, and images with annotations.
60 lines (57 loc) • 1.53 kB
JavaScript
import omit from 'lodash/omit';
import ActionTypes from '../actions/action-types';
/** */
export function accessTokensReducer(state = {}, action) {
switch (action.type) {
case ActionTypes.RESOLVE_AUTHENTICATION_REQUEST:
return {
...state,
[]: {
authId: action.id,
id: action.tokenServiceId,
isFetching: true,
},
};
case ActionTypes.REQUEST_ACCESS_TOKEN:
return {
...state,
[]: {
authId: action.authId,
id: action.serviceId,
isFetching: true,
},
};
case ActionTypes.RECEIVE_ACCESS_TOKEN:
return {
...state,
[]: {
...state[action.serviceId],
isFetching: false,
json: action.json,
},
};
case ActionTypes.RECEIVE_ACCESS_TOKEN_FAILURE:
return {
...state,
[]: {
...state[action.serviceId],
error: action.error,
isFetching: false,
},
};
case ActionTypes.RESET_AUTHENTICATION_STATE:
return omit(state, action.tokenServiceId);
case ActionTypes.RECEIVE_INFO_RESPONSE:
if (!action.tokenServiceId) return state;
if (state[action.tokenServiceId].success) return state;
return {
...state,
[]: {
...state[action.tokenServiceId],
success: true,
},
};
default:
return state;
}
}