mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-14 17:54:42 +00:00
26 lines
939 B
TypeScript
26 lines
939 B
TypeScript
import type { SectionAction, SectionState } from './types';
|
|
|
|
export const initialSectionState: SectionState = {
|
|
usernameOpen: false,
|
|
emailOpen: false,
|
|
profileOpen: false,
|
|
passwordOpen: false,
|
|
};
|
|
|
|
export const sectionReducer = (state: SectionState, action: SectionAction): SectionState => {
|
|
switch (action.type) {
|
|
case 'TOGGLE_USERNAME_VISIBILITY':
|
|
return { ...initialSectionState, usernameOpen: !state.usernameOpen };
|
|
case 'TOGGLE_EMAIL_VISIBILITY':
|
|
return { ...initialSectionState, emailOpen: !state.emailOpen };
|
|
case 'TOGGLE_PROFILE_VISIBILITY':
|
|
return { ...initialSectionState, profileOpen: !state.profileOpen };
|
|
case 'TOGGLE_PASSWORD_VISIBILITY':
|
|
return { ...initialSectionState, passwordOpen: !state.passwordOpen };
|
|
case 'CLOSE_ALL':
|
|
return initialSectionState;
|
|
default:
|
|
return state;
|
|
}
|
|
};
|