mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
passing address to rbac component
This commit is contained in:
parent
1c6c300cf6
commit
c1d6a3b036
@ -1,4 +1,5 @@
|
|||||||
import React, { ReactElement, useEffect, useState } from 'react'
|
import React, { ReactElement, useEffect, useState } from 'react'
|
||||||
|
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'
|
||||||
|
|
||||||
@ -10,13 +11,14 @@ export default function Permission({
|
|||||||
children: ReactElement
|
children: ReactElement
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const [data, updateData] = useState<boolean>()
|
const [data, updateData] = useState<boolean>()
|
||||||
|
const { accountId } = useWeb3()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const data = await rbacRequest(eventType)
|
const data = await rbacRequest(eventType, accountId)
|
||||||
updateData(data)
|
updateData(data)
|
||||||
}
|
}
|
||||||
getData()
|
getData()
|
||||||
}, [eventType])
|
}, [eventType, accountId])
|
||||||
console.log('eventType', eventType)
|
console.log('eventType', eventType)
|
||||||
if (data === false) {
|
if (data === false) {
|
||||||
const message = `Sorry, you don't have permission to ${eventType}. Please make sure you are logged in.`
|
const message = `Sorry, you don't have permission to ${eventType}. Please make sure you are logged in.`
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
import fetch from 'cross-fetch'
|
import fetch from 'cross-fetch'
|
||||||
import appConfig from '../../app.config'
|
import appConfig from '../../app.config'
|
||||||
|
|
||||||
export default async function rbacRequest(eventType: string): Promise<boolean> {
|
export default async function rbacRequest(
|
||||||
|
eventType: string,
|
||||||
|
address: string
|
||||||
|
): Promise<boolean> {
|
||||||
const url = appConfig.rbacUrl
|
const url = appConfig.rbacUrl
|
||||||
|
console.log('address', address)
|
||||||
if (url === 'false') {
|
if (url === 'false') {
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user