mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-05 17:05:46 +01:00
replaces cookies with localStorage
This commit is contained in:
parent
bc2f8bcdae
commit
ac302c9a96
@ -11,7 +11,6 @@ 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();
|
||||
@ -76,17 +75,17 @@ export function NavBar() {
|
||||
|
||||
const handleTeamChange = (teamId: string) => {
|
||||
const url = teamId ? `/teams/${teamId}` : '/';
|
||||
Cookies.set('teamId', teamId);
|
||||
localStorage.setItem('teamId', teamId);
|
||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const teamIdCookie = Cookies.get('teamId');
|
||||
if (teamIdCookie && pathname !== '/' && pathname !== '/dashboard') {
|
||||
const teamIdLocal = localStorage.getItem('teamId');
|
||||
if (teamIdLocal && pathname !== '/' && pathname !== '/dashboard') {
|
||||
const url = '/';
|
||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||
} else if (teamIdCookie) {
|
||||
const url = `/teams/${teamIdCookie}/dashboard`;
|
||||
} else if (teamIdLocal) {
|
||||
const url = `/teams/${teamIdLocal}/dashboard`;
|
||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||
}
|
||||
}, []);
|
||||
|
Loading…
Reference in New Issue
Block a user