SidebarMenu: make accounts clickable

revert-5af0e40a
Alex Gleason 2022-04-25 18:26:17 -05:00
rodzic 3788980856
commit b8955d63e2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 25 dodań i 24 usunięć

Wyświetl plik

@ -79,28 +79,29 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
onClose(); onClose();
}; };
const handleSwitchAccount = (account: AccountEntity): React.EventHandler<React.MouseEvent> => { const handleSwitchAccount = (account: AccountEntity): React.MouseEventHandler => {
return (e) => { return (e) => {
e.preventDefault(); e.preventDefault();
switchAccount(account);
dispatch(switchAccount(account.id)); dispatch(switchAccount(account.id));
}; };
}; };
const onClickLogOut: React.EventHandler<React.MouseEvent> = (e) => { const onClickLogOut: React.MouseEventHandler = (e) => {
e.preventDefault(); e.preventDefault();
dispatch(logOut(intl)); dispatch(logOut(intl));
}; };
const handleSwitcherClick: React.EventHandler<React.MouseEvent> = (e) => { const handleSwitcherClick: React.MouseEventHandler = (e) => {
e.preventDefault(); e.preventDefault();
setSwitcher((prevState) => (!prevState)); setSwitcher((prevState) => (!prevState));
}; };
const renderAccount = (account: AccountEntity) => ( const renderAccount = (account: AccountEntity) => (
<a href='/' className='block py-2' onClick={handleSwitchAccount(account)} key={account.id}> <a href='#' className='block py-2' onClick={handleSwitchAccount(account)} key={account.id}>
<Account account={account} showProfileHoverCard={false} /> <div className='pointer-events-none'>
<Account account={account} showProfileHoverCard={false} withRelationship={false} />
</div>
</a> </a>
); );
@ -155,15 +156,16 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
<Account account={account} showProfileHoverCard={false} /> <Account account={account} showProfileHoverCard={false} />
</Link> </Link>
{/* TODO: make this available to everyone */}
{account.staff && (
<Stack> <Stack>
<button type='button' onClick={handleSwitcherClick} className='py-1'> <button type='button' onClick={handleSwitcherClick} className='py-1'>
<HStack alignItems='center' justifyContent='between'> <HStack alignItems='center' justifyContent='between'>
<Text tag='span' size='sm' weight='medium'>Switch accounts</Text> <Text tag='span' size='sm' weight='medium'>Switch accounts</Text>
<Icon <Icon
src={switcher ? require('@tabler/icons/icons/chevron-up.svg') : require('@tabler/icons/icons/chevron-down.svg')} className='sidebar-menu-profile__caret' src={require('@tabler/icons/icons/chevron-down.svg')}
className={classNames('text-black dark:text-white transition-transform', {
'rotate-180': switcher,
})}
/> />
</HStack> </HStack>
</button> </button>
@ -174,7 +176,6 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
</div> </div>
)} )}
</Stack> </Stack>
)}
</Stack> </Stack>
<ProfileStats <ProfileStats