Skip to content

Commit

Permalink
test(frontend): test graph
Browse files Browse the repository at this point in the history
  • Loading branch information
qmi03 committed May 18, 2024
1 parent b6779e2 commit 7b157e7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion smarthome/src/Pages/testing.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import { useEffect, useState } from "react";

import Mic from "../Components/Mic";
import RealTimeGraph from "../Components/Sensor/RealTimeGraph";
import { backendURL } from "../Utils/getENV";
const Testing = () => {
const [sensorIds, setSensorIds] = useState<string[]>([]);

useEffect(() => {
const fetchSensorIds = async () => {
try {
const response = await fetch(`${backendURL}/sensor/ids`);
const data: string[] = await response.json();
setSensorIds(data);
} catch (error) {
console.error("Error fetching sensor IDs:", error);
}
};

fetchSensorIds();
}, []);

const Testing = () => {
return (
<>
<Mic />
{sensorIds.map((sensorId) => (
<RealTimeGraph key={sensorId} sensorId={sensorId} />
))}
</>
);
};
Expand Down

0 comments on commit 7b157e7

Please sign in to comment.