1
1
import { ReactElement , useState } from "react" ;
2
2
import { useNavigate } from "react-router" ;
3
3
4
- import { Autocomplete , TextField } from "@mui/material" ;
4
+ import { Autocomplete , Box , TextField } from "@mui/material" ;
5
5
6
6
import { chatsApi , organizationsApi , profileApi } from "src/apis" ;
7
+ import { ProfileAvatar } from "src/components/ProfileAvatar" ;
7
8
import { Button } from "src/components/ui" ;
8
9
import { useTranslation } from "src/core/i18n" ;
9
10
import { CacheKeysConstants , useMutation , useQuery } from "src/core/query" ;
@@ -15,6 +16,7 @@ import { CreateChatPageSkeleton } from "./CreateChatPage.skeleton";
15
16
16
17
interface Option {
17
18
id : number ;
19
+ imageUrl ?: string ;
18
20
label : string ;
19
21
}
20
22
@@ -66,7 +68,7 @@ export function CreateChatPageContainer(): ReactElement {
66
68
}
67
69
68
70
const options = data
69
- . map ( ( x ) => ( { id : x . profileId , label : x . name } ) )
71
+ . map ( ( x ) => ( { id : x . profileId , label : x . name , imageUrl : x . imageUrl } ) )
70
72
. filter ( ( x ) => x . id !== currentProfileQuery . data . id ) ;
71
73
72
74
return (
@@ -76,6 +78,14 @@ export function CreateChatPageContainer(): ReactElement {
76
78
onChange = { ( _ , newValue ) => setMembers ( newValue ) }
77
79
options = { options }
78
80
renderInput = { ( params ) => < TextField label = "Members" { ...params } /> }
81
+ renderOption = { ( props , option ) => (
82
+ < Box { ...props } component = "li" >
83
+ < ProfileAvatar name = { option . label } src = { option . imageUrl } />
84
+ < Box component = "span" sx = { { pl : 2 } } >
85
+ { option . label }
86
+ </ Box >
87
+ </ Box >
88
+ ) }
79
89
value = { members }
80
90
/>
81
91
0 commit comments