add the very basics of a plot

Also troubleshoot to fix vite config for deduplicating react and
react-dom
This commit is contained in:
2026-02-18 19:52:08 -08:00
parent e7d8d09fbc
commit 35b0c2396f
8 changed files with 189 additions and 20 deletions
+29
View File
@@ -0,0 +1,29 @@
import { useQuery } from '@tanstack/react-query'
// {"id":1001,"city":"Salem","temp":66.7,"feels_like":67.17,"humidity":87,"conditions":"scattered clouds","fetched_at":"2026-02-18T22:16:38.067097Z"}
interface WeatherHistory {
id: number;
city: string;
temp: number;
feels_like: number;
humidity: number;
conditions: string;
fetched_at: string;
}
async function fetchWeatherHistory(): Promise<WeatherHistory[]>{
const res = await fetch("/api/weather/history");
if(!res.ok) throw new Error("Failed to fetch weather history");
return res.json();
}
function WeatherHistory() {
const {data, isLoading, error} = useQuery({
queryKey: ["weather-history"],
queryFn: fetchWeatherHistory,
});
return {data, isLoading, error}
}
export default WeatherHistory