|
1 | 1 | "use client"; |
2 | 2 | import type { Message, MessageID, SendMessage, UserID } from "common/types"; |
3 | 3 | import type { Content, DMRoom, PersonalizedDMRoom } from "common/zod/types"; |
| 4 | +import { useRouter } from "next/navigation"; |
4 | 5 | import { useSnackbar } from "notistack"; |
5 | 6 | import { useCallback, useEffect, useRef, useState } from "react"; |
6 | 7 | import * as chat from "~/api/chat/chat"; |
7 | 8 | import { useMessages } from "~/api/chat/hooks"; |
| 9 | +import request from "~/api/request"; |
8 | 10 | import * as user from "~/api/user"; |
9 | 11 | import { useMyID } from "~/api/user"; |
10 | 12 | import { getIdToken } from "~/firebase/auth/lib"; |
@@ -157,7 +159,10 @@ export function RoomWindow(props: Props) { |
157 | 159 | return ( |
158 | 160 | <> |
159 | 161 | {!room.isFriend && ( |
160 | | - <FloatingMessage message="この人とはマッチングしていません。" /> |
| 162 | + <FloatingMessage |
| 163 | + message="この人とはマッチングしていません。" |
| 164 | + friendId={friendId} |
| 165 | + /> |
161 | 166 | )} |
162 | 167 |
|
163 | 168 | <div className="fixed top-14 z-50 w-full bg-white"> |
@@ -253,19 +258,44 @@ export function RoomWindow(props: Props) { |
253 | 258 |
|
254 | 259 | type FloatingMessageProps = { |
255 | 260 | message: string; |
| 261 | + friendId: UserID; |
256 | 262 | }; |
257 | 263 |
|
258 | | -const FloatingMessage = ({ message }: FloatingMessageProps) => { |
| 264 | +const FloatingMessage = ({ message, friendId }: FloatingMessageProps) => { |
| 265 | + const router = useRouter(); |
259 | 266 | return ( |
260 | 267 | <div |
261 | 268 | className="fixed inset-0 z-50 flex items-center justify-center" |
262 | 269 | style={{ |
263 | | - pointerEvents: "none", |
| 270 | + pointerEvents: "none", // 背景はクリック可能にする |
264 | 271 | }} |
265 | 272 | > |
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> |
269 | 299 | </div> |
270 | 300 | ); |
271 | 301 | }; |
0 commit comments