hedgedoc/src/redux/banner/reducers.ts

25 lines
619 B
TypeScript

/*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { Reducer } from 'redux'
import { BannerActions, BannerActionType, BannerState, SetBannerAction } from './types'
export const initialState: BannerState = {
text: undefined,
lastModified: null
}
export const BannerReducer: Reducer<BannerState, BannerActions> = (
state: BannerState = initialState,
action: BannerActions
) => {
switch (action.type) {
case BannerActionType.SET_BANNER:
return (action as SetBannerAction).state
default:
return state
}
}