Files
mlb-gameday-dotnet-react/app/src/context/reducer.ts
2023-01-24 20:03:13 -06:00

29 lines
671 B
TypeScript

import { MessageBarType } from '@fluentui/react';
import { INotification } from '../models/INotification';
import { IAppContextState } from './IAppContextState';
export type Action = { type: 'SET_NOTIFICATION'; payload: INotification };
export const initialState: IAppContextState = {
notification: {
messageBarType: MessageBarType.info,
message: 'Blah blah blah',
isMultiline: false,
isVisible: true
}
};
export const reducer = (
state: IAppContextState,
action: Action
): IAppContextState => {
switch (action.type) {
case 'SET_NOTIFICATION': {
return {
...state,
notification: action.payload
};
}
}
};