accounts-frontend/packages/app/components/i18n/reducer.ts

21 lines
375 B
TypeScript

import i18n from 'app/services/i18n';
import { SET_LOCALE } from './actions';
export type State = { locale: string };
const defaultState = {
locale: i18n.detectLanguage(),
};
export default function(
state: State = defaultState,
{ type, payload }: { type: string; payload: State },
): State {
if (type === SET_LOCALE) {
return payload;
}
return state;
}