File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ type HumanListItemProps = {
1414 onAccept ?: ( id : number ) => void ;
1515 onReject ?: ( id : number ) => void ;
1616 onCancel ?: ( id : number ) => void ;
17+ onRequest ?: ( id : number ) => void ;
1718 hasDots ?: boolean ;
1819 dotsActions ?: object ;
1920} ;
@@ -32,6 +33,7 @@ export function HumanListItem(props: HumanListItemProps) {
3233 onAccept,
3334 onReject,
3435 onCancel,
36+ onRequest,
3537 hasDots,
3638 } = props ;
3739
@@ -70,7 +72,7 @@ export function HumanListItem(props: HumanListItemProps) {
7072 ) }
7173 </ div >
7274 </ button >
73- < div className = "flex items-center space-x-2" >
75+ < div className = "mr-3 flex items-center space-x-2" >
7476 { unreadCount ? (
7577 < span className = "badge badge-primary" > { unreadCount } </ span >
7678 ) : undefined }
@@ -107,6 +109,15 @@ export function HumanListItem(props: HumanListItemProps) {
107109 キャンセル
108110 </ button >
109111 ) }
112+ { onRequest && (
113+ // biome-ignore lint/a11y/useButtonType: <explanation>
114+ < button
115+ className = "btn btn-sm bg-primary text-white"
116+ onClick = { ( ) => onRequest ( id ) }
117+ >
118+ リクエスト
119+ </ button >
120+ ) }
110121 { hasDots && (
111122 < Dots
112123 actions = { [
Original file line number Diff line number Diff line change 11"use client" ;
22import { useMemo } from "react" ;
3- import { useAll , useMyID } from "~/api/user" ;
3+ import request from "~/api/request" ;
4+ import { useAll , useMatched , useMyID , usePendingFromMe } from "~/api/user" ;
45import { useModal } from "../common/modal/ModalProvider" ;
56import { HumanListItem } from "../human/humanListItem" ;
67
@@ -21,6 +22,19 @@ export default function UserTable({ query }: { query: string }) {
2122 )
2223 : initialData ;
2324
25+ const {
26+ state : { data : matches } ,
27+ } = useMatched ( ) ;
28+
29+ const {
30+ state : { data : pending } ,
31+ } = usePendingFromMe ( ) ;
32+
33+ // ユーザーがリクエストを送ってない人だけリストアップする
34+ const canRequest = ( userId : number ) =>
35+ ! matches ?. some ( ( match ) => match . id === userId ) &&
36+ ! pending ?. some ( ( pending ) => pending . id === userId ) ;
37+
2438 return (
2539 < div >
2640 { users ?. map ( ( user ) => (
@@ -30,6 +44,14 @@ export default function UserTable({ query }: { query: string }) {
3044 name = { user . name }
3145 pictureUrl = { user . pictureUrl }
3246 onOpen = { ( ) => openModal ( user ) }
47+ onRequest = {
48+ canRequest ( user . id )
49+ ? ( ) => {
50+ request . send ( user . id ) ;
51+ location . reload ( ) ;
52+ }
53+ : undefined
54+ }
3355 />
3456 ) ) }
3557 </ div >
You can’t perform that action at this time.
0 commit comments