1- import {
2- Box ,
3- ListItem ,
4- ListItemAvatar ,
5- Stack ,
6- Typography ,
7- } from "@mui/material" ;
81import UserAvatar from "./avatar" ;
92
103import Dots from "../common/Dots" ;
@@ -48,91 +41,30 @@ export function HumanListItem(props: HumanListItemProps) {
4841 } ;
4942
5043 return (
51- < ListItem
52- key = { id . toString ( ) }
53- secondaryAction = {
54- < Stack direction = "row" spacing = { 1 } >
55- { onAccept && (
56- < button
57- type = "button"
58- onClick = { ( ) => onAccept ( id ) }
59- className = "btn border-primary bg-white text-primary"
60- >
61- 承認
62- </ button >
63- ) }
64- { onReject && (
65- < button
66- type = "button"
67- onClick = { ( ) => onReject ( id ) }
68- className = "btn border-primary bg-white text-primary"
69- >
70- 拒否
71- </ button >
72- ) }
73- { onCancel && (
74- < button
75- type = "button"
76- onClick = { ( ) => onCancel ( id ) }
77- className = "btn border-primary bg-white text-primary"
78- >
79- キャンセル
80- </ button >
81- ) }
82- </ Stack >
83- }
84- sx = { {
85- pr : 2 ,
86- } }
87- >
88- < button
89- type = "button"
90- onClick = { handleOpenClick }
91- className = "w-full items-center justify-start"
92- >
93- < ListItemAvatar sx = { { marginLeft : "8px" } } >
44+ < li key = { id . toString ( ) } >
45+ < button type = "button" onClick = { handleOpenClick } className = "btn cm-li-btn" >
46+ < div className = "flex flex-1 gap-6" >
9447 < UserAvatar pictureUrl = { pictureUrl } width = "50px" height = "50px" />
95- </ ListItemAvatar >
96- < Box
97- sx = { {
98- display : "flex" ,
99- flexDirection : "column" ,
100- justifyContent : "center" ,
101- marginLeft : "20px" ,
102- } }
103- >
104- < Typography
105- variant = "body1"
106- noWrap
107- color = { "text.primary" }
108- sx = { { textAlign : "left" } }
109- >
110- { name }
111- </ Typography >
112- { rollUpName && (
113- < Typography
114- variant = "body2"
115- color = "text.secondary"
116- noWrap
117- sx = { {
118- minHeight : "1rem" ,
119- maxWidth : "60vw" ,
120- } }
121- >
122- { lastMessage }
123- </ Typography >
124- ) }
125- </ Box >
48+ < div className = "flex flex-1 flex-col justify-center" >
49+ < p className = "whitespace-nowrap text-left text-lg" > { name } </ p >
50+ { rollUpName && (
51+ < p className = "min-h-[1rem] max-w-[60vw] whitespace-nowrap text-left text-gray-500 text-sm" >
52+ { lastMessage }
53+ </ p >
54+ ) }
55+ </ div >
56+ </ div >
57+ < ActionMenu
58+ onAccept = { onAccept }
59+ onReject = { onReject }
60+ onCancel = { onCancel }
61+ id = { id }
62+ />
12663 </ button >
64+
65+ { /* TODO: button の中に移す */ }
12766 { hasDots && (
128- < Box
129- sx = { {
130- position : "absolute" ,
131- right : "16px" ,
132- top : "50%" ,
133- transform : "translateY(-50%)" , // コンポーネントの自身の高さの半分だけ上にずらす
134- } }
135- >
67+ < div className = "absolute top-[50%] right-4 translate-y-[-50%]" >
13668 < Dots
13769 actions = { [
13870 {
@@ -154,8 +86,52 @@ export function HumanListItem(props: HumanListItemProps) {
15486 } ,
15587 ] }
15688 />
157- </ Box >
89+ </ div >
90+ ) }
91+ </ li >
92+ ) ;
93+ }
94+
95+ function ActionMenu ( {
96+ onAccept,
97+ onReject,
98+ onCancel,
99+ id,
100+ } : {
101+ onAccept ?: ( id : number ) => void ;
102+ onReject ?: ( id : number ) => void ;
103+ onCancel ?: ( id : number ) => void ;
104+ id : number ;
105+ } ) {
106+ return (
107+ < div className = "flex items-center gap-2" >
108+ { onAccept && (
109+ < button
110+ type = "button"
111+ onClick = { ( ) => onAccept ( id ) }
112+ className = "btn btn-sm btn-primary"
113+ >
114+ 承認
115+ </ button >
116+ ) }
117+ { onReject && (
118+ < button
119+ type = "button"
120+ onClick = { ( ) => onReject ( id ) }
121+ className = "btn btn-sm btn-outline btn-primary"
122+ >
123+ 拒否
124+ </ button >
125+ ) }
126+ { onCancel && (
127+ < button
128+ type = "button"
129+ onClick = { ( ) => onCancel ( id ) }
130+ className = "btn btn-sm btn-outline btn-primary"
131+ >
132+ キャンセル
133+ </ button >
158134 ) }
159- </ ListItem >
135+ </ div >
160136 ) ;
161137}
0 commit comments