replaces cookies with localStorage

This commit is contained in:
chelsey-g 2024-11-11 15:10:07 -05:00
parent bc2f8bcdae
commit ac302c9a96

View File

@ -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);
}
}, []);