Skip to content

Commit

Permalink
Show avatar in autocomplete conditionally (ohcnetwork#8948)
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar authored Oct 28, 2024
1 parent 01b6903 commit bc15ed9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/Common/UserAutocompleteFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function UserAutocomplete(props: UserSearchProps) {
optionLabel={formatName}
optionIcon={userOnlineDot}
optionImage={(option) => option.read_profile_picture_url}
avatar
optionDescription={(option) =>
`${option.user_type} - ${option.username}`
}
Expand Down
13 changes: 8 additions & 5 deletions src/components/Form/FormFields/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type AutocompleteProps<T, V = T> = {
isLoading?: boolean;
allowRawInput?: boolean;
error?: string;
avatar?: boolean;
} & (
| {
required?: false;
Expand Down Expand Up @@ -244,11 +245,13 @@ export const Autocomplete = <T, V>(props: AutocompleteProps<T, V>) => {
<div className="flex items-center">
<div className="flex flex-col">
<div className="relative">
<Avatar
className="mr-2 h-11 w-11 rounded-full"
name={option.label}
imageUrl={option.image}
/>
{(option.image || props.avatar) && (
<Avatar
className="mr-2 h-11 w-11 rounded-full"
name={option.label}
imageUrl={option.image}
/>
)}
<span className="absolute bottom-0 right-0 z-10">
{option.icon}
</span>
Expand Down

0 comments on commit bc15ed9

Please sign in to comment.