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 { useWeb3 } from '../../providers/Web3'
|
||||
import rbacRequest from '../../utils/rbac'
|
||||
import Alert from '../atoms/Alert'
|
||||
|
||||
@ -10,13 +11,14 @@ export default function Permission({
|
||||
children: ReactElement
|
||||
}): ReactElement {
|
||||
const [data, updateData] = useState<boolean>()
|
||||
const { accountId } = useWeb3()
|
||||
useEffect(() => {
|
||||
const getData = async () => {
|
||||
const data = await rbacRequest(eventType)
|
||||
const data = await rbacRequest(eventType, accountId)
|
||||
updateData(data)
|
||||
}
|
||||
getData()
|
||||
}, [eventType])
|
||||
}, [eventType, accountId])
|
||||
console.log('eventType', eventType)
|
||||
if (data === false) {
|
||||
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 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
|
||||
|
||||
console.log('address', address)
|
||||
if (url === 'false') {
|
||||
return true
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user