Skip to content

Commit 3564bfa

Browse files
committed
クエリパラメータで遷移
1 parent 2579584 commit 3564bfa

File tree

2 files changed

+6
-41
lines changed

2 files changed

+6
-41
lines changed

web/app/chat/components/Room.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

web/app/chat/components/RoomList.tsx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
import { Box, List, Typography } from "@mui/material";
44
import type { RoomOverview } from "common/types";
5-
import { useState } from "react";
6-
// import { useRouter } from "next/navigation";
5+
import { useRouter, useSearchParams } from "next/navigation";
76
import { HumanListItem } from "~/components/human/humanListItem";
87
import RoomPage from "./RoomPage";
98

@@ -13,14 +12,12 @@ type RoomListProps = {
1312

1413
export function RoomList(props: RoomListProps) {
1514
const { roomsData } = props;
16-
// const router = useRouter();
17-
18-
const [friendId, setFriendId] = useState<number | null>(null);
15+
const router = useRouter();
16+
const searchParams = useSearchParams();
17+
const friendId = searchParams.get("friendId");
1918

2019
const openRoom = (room: Extract<RoomOverview, { isDM: true }>) => {
21-
// TODO: room いらん
22-
setFriendId(room.friendId);
23-
// router.push(`/chat/${room.friendId}`);
20+
router.push(`/chat?friendId=${room.friendId}`);
2421
};
2522

2623
return (
@@ -87,7 +84,6 @@ export function RoomList(props: RoomListProps) {
8784
</Box>
8885
);
8986
}
90-
// if (room.matchingStatus === "matched")
9187
return (
9288
<Box
9389
key={room.friendId}
@@ -115,17 +111,7 @@ export function RoomList(props: RoomListProps) {
115111
})}
116112
</List>
117113
) : (
118-
<div className="h-screen w-screen bg-gray-200">
119-
<button
120-
type="button"
121-
onClick={() => {
122-
setFriendId(null);
123-
}}
124-
>
125-
x
126-
</button>
127-
<RoomPage id={friendId} />
128-
</div>
114+
<RoomPage id={Number.parseInt(friendId)} />
129115
)}
130116
</>
131117
);

0 commit comments

Comments
 (0)