Skip to content

Commit 2a19ef3

Browse files
johanbookJohan Book
and
Johan Book
authored
feat(web-ui): include profile avatar when creating chat (#850)
Co-authored-by: Johan Book <{ID}+{username}@users.noreply.github.com>
1 parent 616964e commit 2a19ef3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

services/web-ui/src/features/chat/pages/CreateChatPage/CreateChatPage.container.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { ReactElement, useState } from "react";
22
import { useNavigate } from "react-router";
33

4-
import { Autocomplete, TextField } from "@mui/material";
4+
import { Autocomplete, Box, TextField } from "@mui/material";
55

66
import { chatsApi, organizationsApi, profileApi } from "src/apis";
7+
import { ProfileAvatar } from "src/components/ProfileAvatar";
78
import { Button } from "src/components/ui";
89
import { useTranslation } from "src/core/i18n";
910
import { CacheKeysConstants, useMutation, useQuery } from "src/core/query";
@@ -15,6 +16,7 @@ import { CreateChatPageSkeleton } from "./CreateChatPage.skeleton";
1516

1617
interface Option {
1718
id: number;
19+
imageUrl?: string;
1820
label: string;
1921
}
2022

@@ -66,7 +68,7 @@ export function CreateChatPageContainer(): ReactElement {
6668
}
6769

6870
const options = data
69-
.map((x) => ({ id: x.profileId, label: x.name }))
71+
.map((x) => ({ id: x.profileId, label: x.name, imageUrl: x.imageUrl }))
7072
.filter((x) => x.id !== currentProfileQuery.data.id);
7173

7274
return (
@@ -76,6 +78,14 @@ export function CreateChatPageContainer(): ReactElement {
7678
onChange={(_, newValue) => setMembers(newValue)}
7779
options={options}
7880
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+
)}
7989
value={members}
8090
/>
8191

0 commit comments

Comments
 (0)