WorkspacePanel.tsx
types.ts
1// Fetch the active workspaces and render the panel header
2import { useState, useEffect } from "react";
3import type { Workspace } from "./types";
4
5const DEFAULT_LIMIT = 25;
6
7export function WorkspacePanel({ slug }: { slug: string }) {
8 const [items, setItems] = useState<Workspace[]>([]);
9
10 useEffect(() => {
11 fetch(`/api/${slug}/workspaces`)
12 .then((res) => res.json())
13 .then(setItems);
14 }, [slug]);
15
16 return (
17 <section className="panel">
18 <h2>Active workspaces</h2>
19 <p>Showing {items.length} of {DEFAULT_LIMIT} results</p>
20 </section>
21 );
22}
main*TypeScript ReactAura Noir Rose