Skip to content

Commit

Permalink
feat: verify if the user is authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
Josmar-jr authored and ataideverton committed Dec 9, 2024
1 parent afcfe6c commit 2231a50
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion react/components/WarningTopbarInactiveOrganization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useQuery } from 'react-apollo'
import { FormattedMessage } from 'react-intl'

import GET_B2B_SETTINGS from '../graphql/getB2BSettings.graphql'
import storageFactory from '../utils/storage'

function getContrastColor(hexColor: string) {
const color = hexColor.replace('#', '')
Expand All @@ -16,12 +17,21 @@ function getContrastColor(hexColor: string) {
return brightness > 128 ? '#000000' : '#FFFFFF'
}

const localStore = storageFactory(() => localStorage)
const isAuthenticated =
JSON.parse(String(localStore.getItem('b2b-organizations_isAuthenticated'))) ??
false

const WarningTopbarInactiveOrganization = () => {
const { data, loading } = useQuery(GET_B2B_SETTINGS, {
ssr: false,
})

if (loading || data?.getB2BSettings?.uiSettings?.autoApprove) {
if (
loading ||
data?.getB2BSettings?.uiSettings?.autoApprove ||
!isAuthenticated
) {
return <></>
}

Expand Down

0 comments on commit 2231a50

Please sign in to comment.