Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
skykanin committed Dec 10, 2024
1 parent 1347522 commit 03764bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/components/ProtectedAuthorizedUserRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 12 additions & 12 deletions src/components/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ const ProtectedRoute = () => {
const navigate = useNavigate()
const from = location.pathname

const fetchUserProfile = (): Effect.Effect<void, Cause.UnknownException | ApiError> =>
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<void, Cause.UnknownException | ApiError> =>
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<User> = O.fromNullable(localStorage.getItem('userProfile')).pipe(
O.flatMap(O.liftThrowable(JSON.parse))
)
Expand All @@ -44,7 +44,7 @@ const ProtectedRoute = () => {
fetchUserProfile()
).pipe(Effect.provide(customLogger)),
}).pipe(Effect.runPromise)
}, [from, navigate, fetchUserProfile, setUser])
}, [from, navigate, setUser])

return isAuthenticated ? <Outlet /> : null
}
Expand Down

0 comments on commit 03764bd

Please sign in to comment.