Skip to content

Commit bc15ed9

Browse files
Show avatar in autocomplete conditionally (ohcnetwork#8948)
1 parent 01b6903 commit bc15ed9

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/components/Common/UserAutocompleteFormField.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default function UserAutocomplete(props: UserSearchProps) {
8181
optionLabel={formatName}
8282
optionIcon={userOnlineDot}
8383
optionImage={(option) => option.read_profile_picture_url}
84+
avatar
8485
optionDescription={(option) =>
8586
`${option.user_type} - ${option.username}`
8687
}

src/components/Form/FormFields/Autocomplete.tsx

+8-5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type AutocompleteProps<T, V = T> = {
8787
isLoading?: boolean;
8888
allowRawInput?: boolean;
8989
error?: string;
90+
avatar?: boolean;
9091
} & (
9192
| {
9293
required?: false;
@@ -244,11 +245,13 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
244245
<div className="flex items-center">
245246
<div className="flex flex-col">
246247
<div className="relative">
247-
<Avatar
248-
className="mr-2 h-11 w-11 rounded-full"
249-
name={option.label}
250-
imageUrl={option.image}
251-
/>
248+
{(option.image || props.avatar) && (
249+
<Avatar
250+
className="mr-2 h-11 w-11 rounded-full"
251+
name={option.label}
252+
imageUrl={option.image}
253+
/>
254+
)}
252255
<span className="absolute bottom-0 right-0 z-10">
253256
{option.icon}
254257
</span>

0 commit comments

Comments
 (0)