-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoomList.tsx
More file actions
65 lines (61 loc) · 1.74 KB
/
RoomList.tsx
File metadata and controls
65 lines (61 loc) · 1.74 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { Box, List, Typography } from "@mui/material";
import type { RoomOverview } from "common/types";
import { useNavigate } from "react-router-dom";
import { HumanListItem } from "~/components/human/humanListItem";
type RoomListProps = {
roomsData: RoomOverview[] | null;
};
export function RoomList(props: RoomListProps) {
const { roomsData } = props;
const navigate = useNavigate();
return (
<List disablePadding>
<p
style={{
marginLeft: "40px",
marginRight: "40px",
}}
>
{roomsData && roomsData.length === 0 && (
<>
誰ともマッチングしていません。
<br />
リクエストを送りましょう!
</>
)}
</p>
{roomsData?.map((room) => {
if (room.isDM) {
return (
<Box
key={room.friendId}
onClick={() => {
// `state`を使って`room`データを渡す
navigate(`./${room.friendId}`, { state: { room } });
}}
>
<HumanListItem
key={room.friendId}
id={room.friendId}
name={room.name}
pictureUrl={room.thumbnail}
rollUpName={true}
lastMessage={
room.lastMsg?.isPicture
? "画像を送信しました"
: room.lastMsg?.content
}
/>
</Box>
);
}
return (
<Typography key={room.roomId} variant="body2" sx={{ mb: 1 }}>
グループチャット: {room.name}
</Typography>
);
})}
</List>
);
}
export default RoomList;