search with feedback
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
Typography,
|
Typography,
|
||||||
Input,
|
Input,
|
||||||
|
CircularProgress,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { blueGrey } from '@mui/material/colors';
|
import { blueGrey } from '@mui/material/colors';
|
||||||
import { FiActivity, FiInbox, FiSearch } from 'react-icons/fi';
|
import { FiActivity, FiInbox, FiSearch } from 'react-icons/fi';
|
||||||
@@ -34,6 +35,7 @@ const Conversations = () => {
|
|||||||
}, [enqueueSnackbar, searchRef]);
|
}, [enqueueSnackbar, searchRef]);
|
||||||
|
|
||||||
const [searchUsersResults, setSearchUsersResults] = useState<User[]>([]);
|
const [searchUsersResults, setSearchUsersResults] = useState<User[]>([]);
|
||||||
|
const [searching, setSearching] = useState<boolean>(false);
|
||||||
|
|
||||||
useKey('Shift', onSearchFocus);
|
useKey('Shift', onSearchFocus);
|
||||||
|
|
||||||
@@ -46,12 +48,22 @@ const Conversations = () => {
|
|||||||
setSearchUsersResults(results);
|
setSearchUsersResults(results);
|
||||||
|
|
||||||
console.warn(results);
|
console.warn(results);
|
||||||
|
|
||||||
|
setSearching(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
500,
|
500,
|
||||||
[searchVal, enqueueSnackbar, setSearchUsersResults],
|
[searchVal, enqueueSnackbar, setSearchUsersResults],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleChangeSearchInput = useCallback(
|
||||||
|
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setSearching(true);
|
||||||
|
setSearchVal(e.target.value);
|
||||||
|
},
|
||||||
|
[setSearching, setSearchVal],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -71,12 +83,14 @@ const Conversations = () => {
|
|||||||
<FiSearch style={{ color: blueGrey[500] }} />
|
<FiSearch style={{ color: blueGrey[500] }} />
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
onChange={(e) => setSearchVal(e.target.value)}
|
onChange={handleChangeSearchInput}
|
||||||
value={searchVal}
|
value={searchVal}
|
||||||
placeholder={'Find or start a conversation'}
|
placeholder={'Find or start a conversation'}
|
||||||
inputRef={searchRef}
|
inputRef={searchRef}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{searching && <CircularProgress size={20} />}
|
||||||
|
|
||||||
<KeyboardShortcutLabel label="Shift" />
|
<KeyboardShortcutLabel label="Shift" />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
@@ -121,9 +135,7 @@ const Conversations = () => {
|
|||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|
||||||
<List
|
<List
|
||||||
sx={{
|
sx={{
|
||||||
pt: 2,
|
pt: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user