-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpage.tsx
More file actions
38 lines (36 loc) · 885 Bytes
/
page.tsx
File metadata and controls
38 lines (36 loc) · 885 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
38
"use client";
import { useEffect, useState } from "react";
import * as chat from "~/api/chat/chat";
import { RoomWindow } from "~/components/chat/RoomWindow";
export default function Page({ params }: { params: { id: string } }) {
const id = Number.parseInt(params.id);
const [room, setRoom] = useState<
| ({
id: number;
isDM: true;
messages: {
id: number;
creator: number;
createdAt: Date;
content: string;
edited: boolean;
}[];
} & {
name: string;
thumbnail: string;
})
| null
>(null);
useEffect(() => {
(async () => {
const room = await chat.getDM(id);
setRoom(room);
})();
}, [id]);
return (
<>
<p>idは{id}です。</p>
{room ? <RoomWindow friendId={id} room={room} /> : <p>データないよ</p>}
</>
);
}