Skip to content

Commit 2a850dd

Browse files
committed
chat画面のモーダルを追加
1 parent 6b80726 commit 2a850dd

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

web/components/chat/RoomWindow.tsx

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"use client";
22
import type { Message, MessageID, SendMessage, UserID } from "common/types";
33
import type { Content, DMRoom, PersonalizedDMRoom } from "common/zod/types";
4+
import { useRouter } from "next/navigation";
45
import { useSnackbar } from "notistack";
56
import { useCallback, useEffect, useRef, useState } from "react";
67
import * as chat from "~/api/chat/chat";
78
import { useMessages } from "~/api/chat/hooks";
9+
import request from "~/api/request";
810
import * as user from "~/api/user";
911
import { useMyID } from "~/api/user";
1012
import { getIdToken } from "~/firebase/auth/lib";
@@ -157,7 +159,10 @@ export function RoomWindow(props: Props) {
157159
return (
158160
<>
159161
{!room.isFriend && (
160-
<FloatingMessage message="この人とはマッチングしていません。" />
162+
<FloatingMessage
163+
message="この人とはマッチングしていません。"
164+
friendId={friendId}
165+
/>
161166
)}
162167

163168
<div className="fixed top-14 z-50 w-full bg-white">
@@ -253,19 +258,44 @@ export function RoomWindow(props: Props) {
253258

254259
type FloatingMessageProps = {
255260
message: string;
261+
friendId: UserID;
256262
};
257263

258-
const FloatingMessage = ({ message }: FloatingMessageProps) => {
264+
const FloatingMessage = ({ message, friendId }: FloatingMessageProps) => {
265+
const router = useRouter();
259266
return (
260267
<div
261268
className="fixed inset-0 z-50 flex items-center justify-center"
262269
style={{
263-
pointerEvents: "none",
270+
pointerEvents: "none", // 背景はクリック可能にする
264271
}}
265272
>
266-
<p className="w-11/12 max-w-md rounded-lg bg-white p-6 text-center shadow-lg">
267-
{message}
268-
</p>
273+
<div
274+
className="w-11/12 max-w-md rounded-lg bg-white p-6 text-center shadow-lg"
275+
style={{
276+
pointerEvents: "auto", // モーダル内はクリック可能にする
277+
}}
278+
>
279+
<p>{message}</p>
280+
{/* biome-ignore lint/a11y/useButtonType: <explanation> */}
281+
<button
282+
className="btn btn-success btn-sm"
283+
onClick={() => {
284+
request.accept(friendId).then(() => router.push("/chat"));
285+
}}
286+
>
287+
承認
288+
</button>
289+
{/* biome-ignore lint/a11y/useButtonType: <explanation> */}
290+
<button
291+
className="btn btn-error btn-sm"
292+
onClick={() => {
293+
request.reject(friendId).then(() => router.push("/chat"));
294+
}}
295+
>
296+
拒否
297+
</button>
298+
</div>
269299
</div>
270300
);
271301
};

web/components/human/humanListItem.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export function HumanListItem(props: HumanListItemProps) {
6969
<button
7070
className="btn btn-success btn-sm"
7171
onClick={(e) => {
72-
e.stopPropagation(); // クリックイベントの伝播を防止
73-
onAccept(id); // IDをonAcceptに渡す
72+
e.stopPropagation();
73+
onAccept(id);
7474
}}
7575
>
7676
承認
@@ -81,8 +81,8 @@ export function HumanListItem(props: HumanListItemProps) {
8181
<button
8282
className="btn btn-error btn-sm"
8383
onClick={(e) => {
84-
e.stopPropagation(); // クリックイベントの伝播を防止
85-
onReject(id); // IDをonAcceptに渡す
84+
e.stopPropagation();
85+
onReject(id);
8686
}}
8787
>
8888
拒否

0 commit comments

Comments
 (0)