Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

redirects to last selected team on login

chelsey-gbc2f8bcdaee9
diff --git a/src/app/(main)/NavBar.tsx b/src/app/(main)/NavBar.tsx
index 5e0e3da26..53e25532b 100644
--- a/src/app/(main)/NavBar.tsx
+++ b/src/app/(main)/NavBar.tsx
@@ -10,6 +10,8 @@ import TeamsButton from 'components/input/TeamsButton';
import Icons from 'components/icons';
import { useMessages, useNavigation, useTeamUrl } from 'components/hooks';
import styles from './NavBar.module.css';
+import { useEffect } from 'react';
+import Cookies from 'js-cookie';
export function NavBar() {
const { formatMessage, labels } = useMessages();
@@ -74,10 +76,21 @@ export function NavBar() {
const handleTeamChange = (teamId: string) => {
const url = teamId ? `/teams/${teamId}` : '/';
-
+ Cookies.set('teamId', teamId);
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
};
+ useEffect(() => {
+ const teamIdCookie = Cookies.get('teamId');
+ if (teamIdCookie && pathname !== '/' && pathname !== '/dashboard') {
+ const url = '/';
+ router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
+ } else if (teamIdCookie) {
+ const url = `/teams/${teamIdCookie}/dashboard`;
+ router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
+ }
+ }, []);
+
return (
<div className={styles.navbar}>
<div className={styles.logo}>