Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add /logout route, redirect there from logout button #574

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/components/Logout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import useApollo from '../hooks/useApollo';
import { useNavigate } from 'react-router-dom';

export default function Logout() {
const navigate = useNavigate();
const { logout } = useApollo();
logout();
realmayus marked this conversation as resolved.
Show resolved Hide resolved
navigate('/welcome');

return null;
realmayus marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const Settings: React.FC = () => {
name: 'Abmelden im Account',
documentTitle: 'Logout',
});
logout();
navigate('/logout');
}}
/>
</Column>
Expand Down
3 changes: 2 additions & 1 deletion src/routing/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import LoginToken from '../pages/LoginToken';
import { RequireAuth } from '../User';
import FullPageModal from '../modals/FullPageModal';
import { lazyWithRetry } from '../lazy';
import Logout from '../components/Logout';

// All other pages load lazy:
const NavigatorLazy = lazyWithRetry(() => import('./NavigatorLazy'), { prefetch: true });
Expand All @@ -25,7 +26,7 @@ export default function Navigator() {
<Routes>
<Route path="/login" element={<Login />} />
<Route path="/login-token" element={<LoginToken />} />

<Route path="/logout" element={<Logout />} />
<Route path="/welcome" element={<Welcome />} />

<Route
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/RequireScreeningSettingsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import NotificationPreferencesModal from '../modals/NotificationPreferencesModal
import DeactivateAccountModal from '../modals/DeactivateAccountModal';
import { ContactSupportModal } from '../modals/ContactSupportModal';
import useApollo from '../hooks/useApollo';
import { useNavigate } from 'react-router-dom';

const RequireScreeningSettingsDropdown = () => {
const { t } = useTranslation();
const [isNotificationPrefencesOpen, setIsNotificationPreferencesOpen] = useState(false);
const [isDeactivateAccountOpen, setIsDeactivateAccountOpen] = useState(false);
const [isContactSupportOpen, setIsContactSupportOpen] = useState(false);
const { logout } = useApollo();
const navigate = useNavigate();
return (
<>
<Menu
Expand All @@ -30,7 +31,7 @@ const RequireScreeningSettingsDropdown = () => {
<Menu.Item onPress={() => setIsContactSupportOpen(true)}>{t('requireScreening.contactSupport')}</Menu.Item>
<Divider />
<Menu.Item onPress={() => setIsDeactivateAccountOpen(true)}>{t('settings.account.deactivateAccount')}</Menu.Item>
<Menu.Item onPress={() => logout()}>{t('logout')}</Menu.Item>
<Menu.Item onPress={() => navigate('/logout')}>{t('logout')}</Menu.Item>
</Menu>
<DeactivateAccountModal isOpen={isDeactivateAccountOpen} onCloseModal={() => setIsDeactivateAccountOpen(false)} />
<NotificationPreferencesModal isOpen={isNotificationPrefencesOpen} onClose={() => setIsNotificationPreferencesOpen(false)} />
Expand Down
Loading