Skip to content

Commit

Permalink
fix: first_name, last_name and email undefined issue
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Amrutiya <[email protected]>
  • Loading branch information
amitamrutiya committed Nov 7, 2024
1 parent befe427 commit e1f9651
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
13 changes: 4 additions & 9 deletions src/custom/InputSearchField/InputSearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Option {
name: string;
}

interface InputFieldSearchProps {
interface InputSearchFieldProps {
data: Option[];
setFilterData: (data: Option[]) => void;
label?: string;
Expand All @@ -22,7 +22,7 @@ interface InputFieldSearchProps {
setSearchValue: (value: string) => void;
}

const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
const InputSearchField: React.FC<InputSearchFieldProps> = ({
data,
label,
fetchSuggestions,
Expand Down Expand Up @@ -194,12 +194,7 @@ const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
<Typography
onClick={() => setShowAllItems(!showAllItems)}
sx={{
cursor: 'pointer',
color: 'primary.main',
fontWeight: '600',
'&:hover': {
color: 'primary.dark'
}
cursor: 'pointer'
}}
>
{showAllItems ? '(hide)' : `(+${localSelectedData?.length - 1})`}
Expand All @@ -210,4 +205,4 @@ const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
);
};

export default InputFieldSearch;
export default InputSearchField;
15 changes: 4 additions & 11 deletions src/custom/UserSearchField/UserSearchFieldInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
setLocalUsersData(usersData || []);
}, [usersData]);

// Combine current user with search results and filter appropriately
const displayOptions = useMemo(() => {
if (hasInitialFocus && !usersSearch && currentUserData) {
return [currentUserData];
Expand Down Expand Up @@ -173,9 +172,9 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
return options.filter((option: User) => {
const searchStr = inputValue.toLowerCase();
return (
option.first_name.toLowerCase().includes(searchStr) ||
option.last_name.toLowerCase().includes(searchStr) ||
option.email.toLowerCase().includes(searchStr)
option.first_name?.toLowerCase().includes(searchStr) ||
option.last_name?.toLowerCase().includes(searchStr) ||
option.email?.toLowerCase().includes(searchStr)
);
});
}}
Expand All @@ -199,7 +198,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
endAdornment: (
<React.Fragment>
{isUserSearchLoading ? <CircularProgress color="inherit" size={20} /> : null}
{params.InputProps.endAdornment}
</React.Fragment>
)
}}
Expand Down Expand Up @@ -307,12 +305,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
<Typography
onClick={() => setShowAllUsers(!showAllUsers)}
sx={{
cursor: 'pointer',
color: 'white',
fontWeight: '600',
'&:hover': {
color: 'black'
}
cursor: 'pointer'
}}
>
{showAllUsers ? '(hide)' : `(+${localUsersData.length - 1})`}
Expand Down

0 comments on commit e1f9651

Please sign in to comment.