mirror of
https://github.com/umami-software/umami.git
synced 2026-02-16 02:25:35 +01:00
replaces cookies with localStorage
This commit is contained in:
parent
bc2f8bcdae
commit
ac302c9a96
1 changed files with 5 additions and 6 deletions
|
|
@ -11,7 +11,6 @@ import Icons from 'components/icons';
|
||||||
import { useMessages, useNavigation, useTeamUrl } from 'components/hooks';
|
import { useMessages, useNavigation, useTeamUrl } from 'components/hooks';
|
||||||
import styles from './NavBar.module.css';
|
import styles from './NavBar.module.css';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import Cookies from 'js-cookie';
|
|
||||||
|
|
||||||
export function NavBar() {
|
export function NavBar() {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
@ -76,17 +75,17 @@ export function NavBar() {
|
||||||
|
|
||||||
const handleTeamChange = (teamId: string) => {
|
const handleTeamChange = (teamId: string) => {
|
||||||
const url = teamId ? `/teams/${teamId}` : '/';
|
const url = teamId ? `/teams/${teamId}` : '/';
|
||||||
Cookies.set('teamId', teamId);
|
localStorage.setItem('teamId', teamId);
|
||||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const teamIdCookie = Cookies.get('teamId');
|
const teamIdLocal = localStorage.getItem('teamId');
|
||||||
if (teamIdCookie && pathname !== '/' && pathname !== '/dashboard') {
|
if (teamIdLocal && pathname !== '/' && pathname !== '/dashboard') {
|
||||||
const url = '/';
|
const url = '/';
|
||||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||||
} else if (teamIdCookie) {
|
} else if (teamIdLocal) {
|
||||||
const url = `/teams/${teamIdCookie}/dashboard`;
|
const url = `/teams/${teamIdLocal}/dashboard`;
|
||||||
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
router.push(cloudMode ? `${process.env.cloudUrl}${url}` : url);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue