Skip to content

Commit

Permalink
bugfix: remove error message from withSuperAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
lcampbell2 committed Apr 22, 2024
1 parent 15e9877 commit 5e4b3de
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions frontend/src/app/withSuperAdmin.js
@@ -1,19 +1,13 @@
import React from 'react'
import { useQuery } from '@apollo/client'
import { IS_USER_SUPER_ADMIN } from '../graphql/queries'
import { ErrorFallbackMessage } from '../components/ErrorFallbackMessage'
import { LoadingMessage } from '../components/LoadingMessage'
import { useUserVar } from '../utilities/userState'

const withSuperAdmin = (Component) => {
const WrappedComponent = (props) => {
const { isLoggedIn } = useUserVar()
const { loading, error, data: { isUserSuperAdmin } = {} } = useQuery(IS_USER_SUPER_ADMIN)
const { loading, data: { isUserSuperAdmin } = {} } = useQuery(IS_USER_SUPER_ADMIN)

if (!isLoggedIn) return null
if (loading) return <LoadingMessage />
if (error) return <ErrorFallbackMessage error={error} />

return isUserSuperAdmin ? <Component {...props} /> : null
}

Expand Down

0 comments on commit 5e4b3de

Please sign in to comment.