generated from Luis/nextjs-python-web-template
minimum progress
This commit is contained in:
committed by
Sara Pervana
parent
697d2685f3
commit
e06afab048
@@ -1,5 +1,26 @@
|
|||||||
const ConsumeAction = () => {
|
import { Button } from "@mui/material";
|
||||||
return <></>;
|
import useAxios from "../hooks/useAxios";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
|
const ConsumeAction = ({ endpoint }: { endpoint: string }) => {
|
||||||
|
|
||||||
|
const [currentEndpoint, setCurrentEndpoint] = useState("");
|
||||||
|
const [shouldFetch, setShouldFetch] = useState(false);
|
||||||
|
const { data, error } = useAxios(currentEndpoint, "GET", null, true, shouldFetch);
|
||||||
|
|
||||||
|
if (error) console.error("Error consuming:", error);
|
||||||
|
|
||||||
|
if (data) console.log('what the response', data)
|
||||||
|
|
||||||
|
const onConsume = () => {
|
||||||
|
setCurrentEndpoint(endpoint);
|
||||||
|
setShouldFetch(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return <Button onClick={onConsume} variant="outlined">
|
||||||
|
Consume
|
||||||
|
</Button>
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ConsumeAction;
|
export default ConsumeAction;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import EntityActions from "@/components/entity_actions";
|
import EntityActions from "@/components/entity_actions";
|
||||||
|
import ConsumeAction from "@/components/consume_action";
|
||||||
|
|
||||||
export const ClientTableConfig = [
|
export const ClientTableConfig = [
|
||||||
{
|
{
|
||||||
@@ -13,11 +14,9 @@ export const ClientTableConfig = [
|
|||||||
{
|
{
|
||||||
key: "endpoint_url",
|
key: "endpoint_url",
|
||||||
label: "End Point",
|
label: "End Point",
|
||||||
render: () => {
|
render: (value: any) => {
|
||||||
return (
|
return (
|
||||||
<Button disabled variant="outlined">
|
<ConsumeAction endpoint={value} />
|
||||||
Consume
|
|
||||||
</Button>
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user