diff --git a/packages/frontend/src/components/RootComponent.js b/packages/frontend/src/components/RootComponent.js index 846ab61ad..c08da2125 100644 --- a/packages/frontend/src/components/RootComponent.js +++ b/packages/frontend/src/components/RootComponent.js @@ -64,6 +64,7 @@ export default function RootComponent() {
Home Blocks + Data Contracts diff --git a/packages/frontend/src/index.js b/packages/frontend/src/index.js index 4fc211f9d..9f8d4e2c4 100644 --- a/packages/frontend/src/index.js +++ b/packages/frontend/src/index.js @@ -17,6 +17,7 @@ import TransactionRoute, { loader as transactionLoader, } from "./routes/transaction/transaction.route"; import DataContractRoute, {loader as dataContractLoader} from "./routes/dataContract/data.contract.route"; +import DataContractsRoute from "./routes/dataContracts/data.contracts.route"; const router = createBrowserRouter([ { @@ -49,6 +50,10 @@ const router = createBrowserRouter([ element: , loader: dataContractLoader, }, + { + path: "dataContracts", + element: , + }, ] } ]); diff --git a/packages/frontend/src/routes/dataContracts/data.contracts.route.js b/packages/frontend/src/routes/dataContracts/data.contracts.route.js new file mode 100644 index 000000000..5c5a49a40 --- /dev/null +++ b/packages/frontend/src/routes/dataContracts/data.contracts.route.js @@ -0,0 +1,45 @@ +import React, {useEffect, useState} from 'react'; +import './data_contracts.css' +import * as Api from '../../util/Api' +import {Link} from "react-router-dom"; + +function DataContracts({dataContracts}) { + return
+ { + dataContracts.map((dataContract) => + ) + } +
+} + +function DataContract({dataContract}) { + return
+ {dataContract.identifier} +
+} + +function DataContractsRoute() { + const [dataContracts, setDataContracts] = useState(null) + const [loading, setLoading] = useState(null) + const [error, setError] = useState(null) + + + useEffect(() => { + Api.getDataContracts() + .then((dataContracts) => setDataContracts(dataContracts)) + .catch((err) => { + setError(err) + }) + .finally(() => setLoading(false)) + }, []) + + return (
+ {error &&
Error {error}
} + {loading &&
Loading data contracts from API
} + {dataContracts && } +
); +} + +export default DataContractsRoute; diff --git a/packages/frontend/src/routes/dataContracts/data_contracts.css b/packages/frontend/src/routes/dataContracts/data_contracts.css new file mode 100644 index 000000000..ab3984584 --- /dev/null +++ b/packages/frontend/src/routes/dataContracts/data_contracts.css @@ -0,0 +1,23 @@ +.data_contracts_list { + color: white; + text-decoration: none; + background-color: #1a491c; +} + +.data_contracts_item { + text-decoration: none; + padding: 5px; + margin-left: 10px; + margin-right: 10px; + background-color: #1a491c; +} + +.data_contracts_item a { + text-decoration: none; + color: white; +} + +.data_contracts_item a:hover { + text-decoration: underline; + color: #76b2d2; +} diff --git a/packages/frontend/src/util/Api.js b/packages/frontend/src/util/Api.js index acb1aed77..8a920721b 100644 --- a/packages/frontend/src/util/Api.js +++ b/packages/frontend/src/util/Api.js @@ -66,6 +66,10 @@ const getDataContractByIdentifier = (identifier) => { return call(`dataContract/${identifier}`, 'GET') } +const getDataContracts = () => { + return call(`dataContracts`, 'GET') +} + const getStatus = () => { return call(`status`, 'GET') } @@ -78,4 +82,4 @@ const decodeTx = (base64) => { return call(`transaction/decode`, 'POST', {base64}) } -export {getStatus, getBlocks, getBlockByHash, getTransactions, getTransaction, search, decodeTx, getDataContractByIdentifier} +export {getStatus, getBlocks, getBlockByHash, getTransactions, getTransaction, search, decodeTx, getDataContractByIdentifier, getDataContracts}