From 03764bd32419f58fa2aad72de84f39e6d4068e88 Mon Sep 17 00:00:00 2001 From: skykanin <3789764+skykanin@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:20:59 +0100 Subject: [PATCH] fix linting errors --- .../ProtectedAuthorizedUserRoute.tsx | 2 +- src/components/ProtectedRoute.tsx | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/ProtectedAuthorizedUserRoute.tsx b/src/components/ProtectedAuthorizedUserRoute.tsx index 1b3f57c..1aa7a1d 100644 --- a/src/components/ProtectedAuthorizedUserRoute.tsx +++ b/src/components/ProtectedAuthorizedUserRoute.tsx @@ -25,7 +25,7 @@ const ProtectedAuthorizedUserRoute = () => { const daplaAdmin: boolean = yield* Effect.promise(() => isDaplaAdmin(user.principal_name)) yield* Effect.sync(() => setIsAuthorized(O.some(isAuthorizedToCreateTeam(daplaAdmin, user.job_title)))) - }).pipe(Effect.runPromise) + }).pipe(Effect.runPromise) }) return option( diff --git a/src/components/ProtectedRoute.tsx b/src/components/ProtectedRoute.tsx index bf82a7e..bf96b79 100644 --- a/src/components/ProtectedRoute.tsx +++ b/src/components/ProtectedRoute.tsx @@ -15,18 +15,18 @@ const ProtectedRoute = () => { const navigate = useNavigate() const from = location.pathname - const fetchUserProfile = (): Effect.Effect => - Effect.gen(function* () { - const userProfileData = yield* Effect.promise(fetchUserInformationFromAuthToken) - const userProfile = yield* Effect.tryPromise(() => getUserProfile(userProfileData.email)).pipe( - Effect.flatMap((x) => (x instanceof ApiError ? Effect.fail(x) : Effect.succeed(x))) - ) - yield* Effect.sync(() => localStorage.setItem('userProfile', JSON.stringify(userProfile))) - yield* Effect.sync(() => setUser(userProfile)) - yield* Effect.sync(() => setIsAuthenticated(true)) - }).pipe(Effect.provide(customLogger)) - useEffect(() => { + const fetchUserProfile = (): Effect.Effect => + Effect.gen(function* () { + const userProfileData = yield* Effect.promise(fetchUserInformationFromAuthToken) + const userProfile = yield* Effect.tryPromise(() => getUserProfile(userProfileData.email)).pipe( + Effect.flatMap((x) => (x instanceof ApiError ? Effect.fail(x) : Effect.succeed(x))) + ) + yield* Effect.sync(() => localStorage.setItem('userProfile', JSON.stringify(userProfile))) + yield* Effect.sync(() => setUser(userProfile)) + yield* Effect.sync(() => setIsAuthenticated(true)) + }).pipe(Effect.provide(customLogger)) + const cachedUserProfile: O.Option = O.fromNullable(localStorage.getItem('userProfile')).pipe( O.flatMap(O.liftThrowable(JSON.parse)) ) @@ -44,7 +44,7 @@ const ProtectedRoute = () => { fetchUserProfile() ).pipe(Effect.provide(customLogger)), }).pipe(Effect.runPromise) - }, [from, navigate, fetchUserProfile, setUser]) + }, [from, navigate, setUser]) return isAuthenticated ? : null }