Skip to content

Commit 74bf9bc

Browse files
committed
fix: first_name, last_name and email undefined issue
Signed-off-by: Amit Amrutiya <[email protected]>
1 parent befe427 commit 74bf9bc

File tree

2 files changed

+12
-23
lines changed

2 files changed

+12
-23
lines changed

src/custom/InputSearchField/InputSearchField.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Option {
99
name: string;
1010
}
1111

12-
interface InputFieldSearchProps {
12+
interface InputSearchFieldProps {
1313
data: Option[];
1414
setFilterData: (data: Option[]) => void;
1515
label?: string;
@@ -22,7 +22,7 @@ interface InputFieldSearchProps {
2222
setSearchValue: (value: string) => void;
2323
}
2424

25-
const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
25+
const InputSearchField: React.FC<InputSearchFieldProps> = ({
2626
data,
2727
label,
2828
fetchSuggestions,
@@ -194,12 +194,7 @@ const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
194194
<Typography
195195
onClick={() => setShowAllItems(!showAllItems)}
196196
sx={{
197-
cursor: 'pointer',
198-
color: 'primary.main',
199-
fontWeight: '600',
200-
'&:hover': {
201-
color: 'primary.dark'
202-
}
197+
cursor: 'pointer'
203198
}}
204199
>
205200
{showAllItems ? '(hide)' : `(+${localSelectedData?.length - 1})`}
@@ -210,4 +205,4 @@ const InputFieldSearch: React.FC<InputFieldSearchProps> = ({
210205
);
211206
};
212207

213-
export default InputFieldSearch;
208+
export default InputSearchField;

src/custom/UserSearchField/UserSearchFieldInput.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
7373
setLocalUsersData(usersData || []);
7474
}, [usersData]);
7575

76-
// Combine current user with search results and filter appropriately
7776
const displayOptions = useMemo(() => {
7877
if (hasInitialFocus && !usersSearch && currentUserData) {
7978
return [currentUserData];
@@ -159,23 +158,23 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
159158
id="user-search-field"
160159
style={{ width: '100%' }}
161160
open={open}
161+
options={displayOptions}
162+
getOptionLabel={() => inputValue}
163+
isOptionEqualToValue={(option, value) => option.id === value.id}
162164
onOpen={() => setOpen(true)}
163165
onClose={() => setOpen(false)}
164166
inputValue={inputValue}
165167
onChange={handleAdd}
166168
onInputChange={handleInputChange}
167-
options={displayOptions}
168-
getOptionLabel={() => inputValue}
169-
isOptionEqualToValue={(option, value) => option.id === value.id}
170169
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
171170
// @ts-ignore
172171
filterOptions={(options, { inputValue }) => {
173172
return options.filter((option: User) => {
174173
const searchStr = inputValue.toLowerCase();
175174
return (
176-
option.first_name.toLowerCase().includes(searchStr) ||
177-
option.last_name.toLowerCase().includes(searchStr) ||
178-
option.email.toLowerCase().includes(searchStr)
175+
option.first_name?.toLowerCase().includes(searchStr) ||
176+
option.last_name?.toLowerCase().includes(searchStr) ||
177+
option.email?.toLowerCase().includes(searchStr)
179178
);
180179
});
181180
}}
@@ -187,6 +186,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
187186
blurOnSelect={true}
188187
clearOnBlur={true}
189188
popupIcon={null}
189+
forcePopupIcon={false}
190190
noOptionsText={isUserSearchLoading ? 'Loading...' : 'No users found'}
191191
renderInput={(params) => (
192192
<TextField
@@ -199,7 +199,6 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
199199
endAdornment: (
200200
<React.Fragment>
201201
{isUserSearchLoading ? <CircularProgress color="inherit" size={20} /> : null}
202-
{params.InputProps.endAdornment}
203202
</React.Fragment>
204203
)
205204
}}
@@ -307,12 +306,7 @@ const UserSearchField: React.FC<UserSearchFieldProps> = ({
307306
<Typography
308307
onClick={() => setShowAllUsers(!showAllUsers)}
309308
sx={{
310-
cursor: 'pointer',
311-
color: 'white',
312-
fontWeight: '600',
313-
'&:hover': {
314-
color: 'black'
315-
}
309+
cursor: 'pointer'
316310
}}
317311
>
318312
{showAllUsers ? '(hide)' : `(+${localUsersData.length - 1})`}

0 commit comments

Comments
 (0)