2022-06-04 00:22:36 -07:00
|
|
|
import { Record as ImmutableRecord } from 'immutable';
|
|
|
|
|
2024-08-24 06:01:17 -07:00
|
|
|
import { DROPDOWN_MENU_OPEN, DROPDOWN_MENU_CLOSE } from '../actions/dropdown-menu';
|
2022-06-04 00:22:36 -07:00
|
|
|
|
|
|
|
import type { AnyAction } from 'redux';
|
|
|
|
|
|
|
|
const ReducerRecord = ImmutableRecord({
|
2023-02-09 09:42:46 -08:00
|
|
|
isOpen: false,
|
2022-06-04 00:22:36 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
type State = ReturnType<typeof ReducerRecord>;
|
|
|
|
|
2024-05-12 16:18:04 -07:00
|
|
|
const dropdownMenu = (state: State = ReducerRecord(), action: AnyAction) => {
|
2022-06-04 00:22:36 -07:00
|
|
|
switch (action.type) {
|
|
|
|
case DROPDOWN_MENU_OPEN:
|
2023-02-09 09:42:46 -08:00
|
|
|
return state.set('isOpen', true);
|
2022-06-04 00:22:36 -07:00
|
|
|
case DROPDOWN_MENU_CLOSE:
|
2023-02-09 09:42:46 -08:00
|
|
|
return state.set('isOpen', false);
|
2022-06-04 00:22:36 -07:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2024-05-12 16:18:04 -07:00
|
|
|
};
|
|
|
|
|
2024-05-13 10:00:42 -07:00
|
|
|
export { dropdownMenu as default };
|