1
0
mirror of https://github.com/oceanprotocol/react.git synced 2025-01-08 21:04:03 +01:00
react/example/src/AllDdos.tsx

47 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2020-07-15 14:54:20 +02:00
import React from 'react'
2020-09-07 11:32:34 +02:00
import { useOcean } from '@oceanprotocol/react'
2020-07-31 11:12:32 +02:00
import { DDO } from '@oceanprotocol/lib'
2020-07-15 14:54:20 +02:00
import { useState } from 'react'
import { useEffect } from 'react'
import shortid from 'shortid'
2020-08-19 14:21:04 +02:00
import { MetadataExample } from './MetadataExample'
2020-09-07 13:11:46 +02:00
2020-07-15 14:54:20 +02:00
export function AllDdos() {
2020-10-02 12:59:11 +02:00
const { networkId, account, accountId, ocean } = useOcean()
2020-07-15 14:54:20 +02:00
2020-10-01 14:17:44 +02:00
const [ddos, setDdos] = useState<DDO[]>()
2020-07-15 14:54:20 +02:00
2020-07-16 11:25:01 +02:00
useEffect(() => {
async function init() {
2020-10-01 14:17:44 +02:00
if (!ocean || !accountId || !accountId) return
2020-07-31 11:12:32 +02:00
2020-10-05 09:09:42 +02:00
//const assets = await ocean.assets.ownerAssets(accountId)
const assets = await ocean.assets.query({
page: 1,
offset: 10,
query: {},
sort: { created: -1 }
})
2020-10-01 14:17:44 +02:00
console.log('assets', assets.results)
2020-09-10 16:59:39 +02:00
setDdos(assets.results.slice(0, 4))
2020-07-16 11:25:01 +02:00
}
init()
2020-10-02 12:59:11 +02:00
}, [ocean, account, networkId, accountId])
2020-07-15 14:54:20 +02:00
2020-07-16 11:25:01 +02:00
return (
<>
<div>Assets</div> <br />
<div style={{ flexDirection: 'column' }}>
{ddos?.map((ddo) => {
return (
<div key={shortid.generate()}>
2020-08-20 15:11:16 +02:00
<MetadataExample ddo={ddo} />
2020-07-16 11:25:01 +02:00
<br />
2020-07-15 14:54:20 +02:00
</div>
2020-07-16 11:25:01 +02:00
)
})}
</div>
</>
)
2020-07-15 14:54:20 +02:00
}