-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage.tsx
More file actions
37 lines (31 loc) · 998 Bytes
/
page.tsx
File metadata and controls
37 lines (31 loc) · 998 Bytes
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
"use client";
import { useSearchParams } from "next/navigation";
import { Suspense } from "react";
import { useRoomsOverview } from "~/api/chat/hooks";
import RoomList from "~/components/chat/RoomList";
import { RoomWindow } from "~/components/chat/RoomWindow";
import FullScreenCircularProgress from "~/components/common/FullScreenCircularProgress";
export default function Chat() {
return (
<Suspense fallback={<FullScreenCircularProgress />}>
<ChatListContent />
</Suspense>
);
}
function ChatListContent() {
const searchParams = useSearchParams();
const friendId = searchParams.get("friendId");
const { state } = useRoomsOverview();
return friendId ? (
<>
<p>Chat - friend Id: {friendId}</p>
<RoomWindow />
</>
) : state.current === "loading" ? (
<FullScreenCircularProgress />
) : state.current === "error" ? (
<p className="decoration-red">Error: {state.error.message}</p>
) : (
<RoomList roomsData={state.data} />
);
}