From 417eb128b83c191225cbaf83a0c5583453cf4312 Mon Sep 17 00:00:00 2001 From: skykanin <3789764+skykanin@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:50:58 +0200 Subject: [PATCH] add more logging --- src/components/ProtectedRoute.tsx | 9 ++++++++- src/pages/TeamOverview/TeamOverview.tsx | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/ProtectedRoute.tsx b/src/components/ProtectedRoute.tsx index 0937b273..548ee04f 100644 --- a/src/components/ProtectedRoute.tsx +++ b/src/components/ProtectedRoute.tsx @@ -2,6 +2,8 @@ import { useEffect, useState } from 'react' import { useNavigate, Outlet } from 'react-router-dom' import { getUserProfile } from '../services/userProfile' import { fetchUserInformationFromAuthToken } from '../utils/services' +import { Effect } from 'effect' +import { customLogger } from '../utils/logger.ts' const ProtectedRoute = () => { const [isAuthenticated, setIsAuthenticated] = useState(false) @@ -17,7 +19,12 @@ const ProtectedRoute = () => { } const userProfileData = await fetchUserInformationFromAuthToken() - localStorage.setItem('userProfile', JSON.stringify(await getUserProfile(userProfileData.email))) + const userProfile = JSON.stringify(await getUserProfile(userProfileData.email)) + Effect.logInfo(`UserProfile set in localStorage: ${userProfile}`).pipe( + Effect.provide(customLogger), + Effect.runSync + ) + localStorage.setItem('userProfile', userProfile) setIsAuthenticated(true) } catch (error) { console.error('Error occurred when updating userProfile data') diff --git a/src/pages/TeamOverview/TeamOverview.tsx b/src/pages/TeamOverview/TeamOverview.tsx index 38c58c63..7d1f04b8 100644 --- a/src/pages/TeamOverview/TeamOverview.tsx +++ b/src/pages/TeamOverview/TeamOverview.tsx @@ -74,6 +74,10 @@ const TeamOverview = () => { useEffect(() => { const userProfileItem = localStorage.getItem('userProfile') + Effect.logInfo(`UserProfile from localStorage: ${userProfileItem}`).pipe( + Effect.provide(customLogger), + Effect.runSync + ) if (!userProfileItem) return const user = JSON.parse(userProfileItem) as User