Tile windowing system
This commit is contained in:
parent
c6e6c5ca48
commit
43318fb8cd
35 changed files with 4659 additions and 360 deletions
25
app/components/panels/PowerPanel.tsx
Normal file
25
app/components/panels/PowerPanel.tsx
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"use client";
|
||||
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { getPower, type PowerData } from "../../lib/getPower";
|
||||
import PowerGrid from "../PowerGrid";
|
||||
|
||||
export default function PowerPanel({ isAuthed }: { isAuthed: boolean }) {
|
||||
const [power, setPower] = useState<PowerData | null>(null);
|
||||
|
||||
const fetchPower = useCallback(async () => {
|
||||
try { setPower(await getPower()); } catch {}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
fetchPower();
|
||||
const id = setInterval(fetchPower, 3000);
|
||||
return () => clearInterval(id);
|
||||
}, [fetchPower]);
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<PowerGrid power={power} onRefresh={fetchPower} showControls={isAuthed} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue