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) =>
|
.then((resp) =>
|
||||||
resp.json().then((jsonData) => {
|
resp.json().then((jsonData) => {
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
if (jsonData.length > 0) {
|
jsonData.length > 0 ? setRepositoryData(jsonData) : setRepositoryData(APServiceRepositoryDummyData);
|
||||||
setRepositoryData(jsonData);
|
|
||||||
} else {
|
|
||||||
setRepositoryData(APServiceRepositoryDummyData);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.then()
|
.then()
|
||||||
|
|||||||
@@ -23,11 +23,7 @@ export default function Client1() {
|
|||||||
.then((resp) =>
|
.then((resp) =>
|
||||||
resp.json().then((jsonData) => {
|
resp.json().then((jsonData) => {
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
if (jsonData.length > 0) {
|
jsonData.length > 0 ? setConsumerData(jsonData) : setConsumerData(Client1ConsumerData);
|
||||||
setConsumerData(jsonData);
|
|
||||||
} else {
|
|
||||||
setConsumerData(Client1ConsumerData);
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.then()
|
.then()
|
||||||
@@ -37,15 +33,11 @@ export default function Client1() {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
// credentials: 'include',
|
// credentials: 'include',
|
||||||
})
|
})
|
||||||
.then((resp) =>
|
.then((resp) =>
|
||||||
resp.json().then((jsonData) => {
|
resp.json().then((jsonData) => {
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
if (jsonData.length > 0) {
|
jsonData.length > 0 ? setProducerData(jsonData) : setProducerData(Client1ProducerData);
|
||||||
setProducerData(jsonData);
|
}),
|
||||||
} else {
|
|
||||||
setProducerData(Client1ProducerData);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
.then()
|
.then()
|
||||||
.catch();
|
.catch();
|
||||||
|
|||||||
@@ -9,8 +9,40 @@ import {
|
|||||||
Client2SummaryDetails,
|
Client2SummaryDetails,
|
||||||
} from "@/mock/client_2";
|
} from "@/mock/client_2";
|
||||||
import CustomTable from "@/components/table";
|
import CustomTable from "@/components/table";
|
||||||
|
import {useEffect, useState} from "react";
|
||||||
|
|
||||||
export default function Client1() {
|
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 (
|
return (
|
||||||
<div className="m-10">
|
<div className="m-10">
|
||||||
<SummaryDetails
|
<SummaryDetails
|
||||||
@@ -24,14 +56,14 @@ export default function Client1() {
|
|||||||
<div>
|
<div>
|
||||||
<h4>Consumer View</h4>
|
<h4>Consumer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={Client2ConsumerData}
|
data={consumerData}
|
||||||
configuration={Client2ConsumerTableConfig}
|
configuration={Client2ConsumerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4>Producer View</h4>
|
<h4>Producer View</h4>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
data={Client2ProducerData}
|
data={producerData}
|
||||||
configuration={Client2ProducerTableConfig}
|
configuration={Client2ProducerTableConfig}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user