mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
28 lines
828 B
TypeScript
28 lines
828 B
TypeScript
import {
|
|
CorrelationIdAction,
|
|
CorrelationIDActionTypes,
|
|
SetCorrelationIdAction
|
|
} from './correlation-id.actions';
|
|
import { AppState } from '../app.reducer';
|
|
|
|
const initialState = null;
|
|
|
|
export const correlationIdSelector = (state: AppState) => state.correlationId;
|
|
|
|
/**
|
|
* Reducer that handles actions to update the correlation ID
|
|
* @param {string} state the previous correlation ID (null if unset)
|
|
* @param {CorrelationIdAction} action the action to perform
|
|
* @return {string} the new correlation ID
|
|
*/
|
|
export const correlationIdReducer = (state = initialState, action: CorrelationIdAction): string => {
|
|
switch (action.type) {
|
|
case CorrelationIDActionTypes.SET: {
|
|
return (action as SetCorrelationIdAction).payload;
|
|
}
|
|
default: {
|
|
return state;
|
|
}
|
|
}
|
|
};
|