-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser-lists.tsx
More file actions
40 lines (37 loc) · 1.11 KB
/
user-lists.tsx
File metadata and controls
40 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useSubscription } from "@trpc/tanstack-react-query";
import { useTRPC } from "./gateway/bff";
import { useQueryClient } from "@tanstack/react-query";
import UserList from "./user-list";
export function UserLists({ pool }: { pool: string }) {
const queryClient = useQueryClient();
const bff = useTRPC();
useSubscription(
bff.onUpdates.subscriptionOptions(
{ namespace: pool },
{
enabled: true,
onData: (data) => {
queryClient.setQueryData(bff.allUsers.queryOptions().queryKey, () => {
return data;
});
},
onError: (err) => console.error(err),
},
),
);
return (
<header className="w-full p-4 bg-gray-900">
<div className="grid grid-cols-3 gap-4">
<section className="space-y-4">
<UserList initialLetters={["l", "p", "g"]} />
</section>
<section className="space-y-4">
<UserList initialLetters={["e", "m", "n"]} />
</section>
<section className="space-y-4">
<UserList initialLetters={["c", "k"]} />
</section>
</div>
</header>
);
}