You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
693 B
TypeScript
38 lines
693 B
TypeScript
5 years ago
|
import { SectionType } from '../../components/session/ActionsPanel';
|
||
|
|
||
|
export const FOCUS_SECTION = 'FOCUS_SECTION';
|
||
|
|
||
|
const focusSection = (section: SectionType) => {
|
||
|
return {
|
||
|
type: FOCUS_SECTION,
|
||
|
payload: section,
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export const actions = {
|
||
|
focusSection,
|
||
|
};
|
||
|
|
||
|
const initialState = { focusedSection: SectionType.Message };
|
||
|
export type SectionStateType = {
|
||
|
focusedSection: SectionType;
|
||
|
};
|
||
|
|
||
|
export const reducer = (
|
||
|
state: any = initialState,
|
||
|
{
|
||
|
type,
|
||
|
payload,
|
||
|
}: {
|
||
|
type: string;
|
||
|
payload: SectionType;
|
||
|
}
|
||
|
): SectionStateType => {
|
||
|
switch (type) {
|
||
|
case FOCUS_SECTION:
|
||
|
return { focusedSection: payload };
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
};
|