generated from Luis/nextjs-python-web-template
[Functionality] Request Consumer / Producer
- request consumer, producer data for client-2 - refactored statements
This commit is contained in:
@@ -22,11 +22,7 @@ export default function AccessPoint() {
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
if (jsonData.length > 0) {
|
||||
setRepositoryData(jsonData);
|
||||
} else {
|
||||
setRepositoryData(APServiceRepositoryDummyData);
|
||||
}
|
||||
jsonData.length > 0 ? setRepositoryData(jsonData) : setRepositoryData(APServiceRepositoryDummyData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
|
||||
@@ -23,11 +23,7 @@ export default function Client1() {
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
if (jsonData.length > 0) {
|
||||
setConsumerData(jsonData);
|
||||
} else {
|
||||
setConsumerData(Client1ConsumerData);
|
||||
}
|
||||
jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client1ConsumerData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
@@ -40,11 +36,7 @@ export default function Client1() {
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
if (jsonData.length > 0) {
|
||||
setProducerData(jsonData);
|
||||
} else {
|
||||
setProducerData(Client1ProducerData);
|
||||
}
|
||||
jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client1ProducerData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
|
||||
@@ -9,8 +9,40 @@ import {
|
||||
Client2SummaryDetails,
|
||||
} from "@/mock/client_2";
|
||||
import CustomTable from "@/components/table";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
export default function Client1() {
|
||||
const [consumerData, setConsumerData] = useState([]);
|
||||
const [producerData, setProducerData] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("http://localhost:2979/api/v1/get_consumers", {
|
||||
method: "GET",
|
||||
// credentials: 'include',
|
||||
})
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client2ConsumerData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
.catch();
|
||||
|
||||
fetch("http://localhost:2979/api/v1/get_producers", {
|
||||
method: "GET",
|
||||
// credentials: 'include',
|
||||
})
|
||||
.then((resp) =>
|
||||
resp.json().then((jsonData) => {
|
||||
console.log(jsonData);
|
||||
jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client2ProducerData);
|
||||
}),
|
||||
)
|
||||
.then()
|
||||
.catch();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="m-10">
|
||||
<SummaryDetails
|
||||
@@ -24,14 +56,14 @@ export default function Client1() {
|
||||
<div>
|
||||
<h4>Consumer View</h4>
|
||||
<CustomTable
|
||||
data={Client2ConsumerData}
|
||||
data={consumerData}
|
||||
configuration={Client2ConsumerTableConfig}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Producer View</h4>
|
||||
<CustomTable
|
||||
data={Client2ProducerData}
|
||||
data={producerData}
|
||||
configuration={Client2ProducerTableConfig}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user