mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-17 01:47:22 +00:00
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
export interface AccountPageState {
|
|
accountInfoOpen: boolean;
|
|
securityOpen: boolean;
|
|
deleteAccountOpen: boolean;
|
|
}
|
|
|
|
export type AccountPageAction =
|
|
| { type: 'TOGGLE_ACCOUNT_INFO_VISIBILITY' }
|
|
| { type: 'TOGGLE_SECURITY_VISIBILITY' }
|
|
| { type: 'TOGGLE_DELETE_ACCOUNT_VISIBILITY' }
|
|
| { type: 'CLOSE_ALL' };
|
|
|
|
const accountPageReducer = (
|
|
state: AccountPageState,
|
|
action: AccountPageAction,
|
|
): AccountPageState => {
|
|
switch (action.type) {
|
|
case 'TOGGLE_ACCOUNT_INFO_VISIBILITY': {
|
|
return {
|
|
accountInfoOpen: !state.accountInfoOpen,
|
|
securityOpen: false,
|
|
deleteAccountOpen: false,
|
|
};
|
|
}
|
|
case 'TOGGLE_DELETE_ACCOUNT_VISIBILITY': {
|
|
return {
|
|
accountInfoOpen: false,
|
|
securityOpen: false,
|
|
deleteAccountOpen: !state.deleteAccountOpen,
|
|
};
|
|
}
|
|
case 'TOGGLE_SECURITY_VISIBILITY': {
|
|
return {
|
|
accountInfoOpen: false,
|
|
securityOpen: !state.securityOpen,
|
|
deleteAccountOpen: false,
|
|
};
|
|
}
|
|
case 'CLOSE_ALL': {
|
|
return {
|
|
accountInfoOpen: false,
|
|
securityOpen: false,
|
|
deleteAccountOpen: false,
|
|
};
|
|
}
|
|
default: {
|
|
throw new Error('Invalid action type.');
|
|
}
|
|
}
|
|
};
|
|
|
|
export default accountPageReducer;
|