mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
Check for undefined RBAC_URL in permissions component
This commit is contained in:
parent
cbbc8904d9
commit
22cacdb577
@ -3,6 +3,7 @@ import { useWeb3 } from '../../providers/Web3'
|
|||||||
import rbacRequest from '../../utils/rbac'
|
import rbacRequest from '../../utils/rbac'
|
||||||
import Alert from '../atoms/Alert'
|
import Alert from '../atoms/Alert'
|
||||||
import Loader from '../atoms/Loader'
|
import Loader from '../atoms/Loader'
|
||||||
|
import appConfig from '../../../app.config'
|
||||||
|
|
||||||
export default function Permission({
|
export default function Permission({
|
||||||
eventType,
|
eventType,
|
||||||
@ -11,9 +12,11 @@ export default function Permission({
|
|||||||
eventType: string
|
eventType: string
|
||||||
children: ReactElement
|
children: ReactElement
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
|
const url = appConfig.rbacUrl
|
||||||
const [data, updateData] = useState<boolean>()
|
const [data, updateData] = useState<boolean>()
|
||||||
const { accountId } = useWeb3()
|
const { accountId } = useWeb3()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (url === undefined) return
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
if (accountId !== undefined) {
|
if (accountId !== undefined) {
|
||||||
const data = await rbacRequest(eventType, accountId)
|
const data = await rbacRequest(eventType, accountId)
|
||||||
@ -21,8 +24,8 @@ export default function Permission({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getData()
|
getData()
|
||||||
}, [eventType, accountId])
|
}, [eventType, accountId, url])
|
||||||
if (data === true) {
|
if (url === undefined || data === true) {
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
} else if (data === false) {
|
} else if (data === false) {
|
||||||
const message = `Sorry, you don't have permission to ${eventType}. Please make sure you have connected your registered address.`
|
const message = `Sorry, you don't have permission to ${eventType}. Please make sure you have connected your registered address.`
|
||||||
|
Loading…
Reference in New Issue
Block a user