more clenup and autocomplete with search working simple async calls
This commit is contained in:
@@ -5,6 +5,7 @@ import { ConversationMap } from '../util/types';
|
|||||||
import User from '@nirvana/core/models/user.model';
|
import User from '@nirvana/core/models/user.model';
|
||||||
import useAuth from './AuthProvider';
|
import useAuth from './AuthProvider';
|
||||||
import { useDebounce } from 'react-use';
|
import { useDebounce } from 'react-use';
|
||||||
|
import { userSearch } from '../api/NirvanaApi';
|
||||||
|
|
||||||
interface ISearchContext {
|
interface ISearchContext {
|
||||||
searchUsers?: (searchQuery: string) => void;
|
searchUsers?: (searchQuery: string) => void;
|
||||||
@@ -42,11 +43,8 @@ export function SearchProvider({ children }: { children: React.ReactNode }) {
|
|||||||
const [, cancel] = useDebounce(
|
const [, cancel] = useDebounce(
|
||||||
async () => {
|
async () => {
|
||||||
if (searchQuery) {
|
if (searchQuery) {
|
||||||
// let results = await firestoreSearchUsers(searchQuery);
|
const results = await userSearch(searchQuery);
|
||||||
// results = results.filter((userResult) => userResult. user._id);
|
setUserResultsResults(results.users ?? []);
|
||||||
|
|
||||||
const results = [];
|
|
||||||
setUserResultsResults(results);
|
|
||||||
|
|
||||||
console.warn('searched users', results);
|
console.warn('searched users', results);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export default function UserDetailRow({
|
|||||||
|
|
||||||
<Stack>
|
<Stack>
|
||||||
<Typography variant="subtitle2" color="info" gutterBottom={false}>
|
<Typography variant="subtitle2" color="info" gutterBottom={false}>
|
||||||
{user.givenName}
|
{user.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant={'overline'}>{user.email}</Typography>
|
<Typography variant={'overline'}>{user.email}</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export default function NewConversationDialog() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
||||||
|
|
||||||
const handleSubmitLocal = useCallback(async () => {
|
const handleSubmit = useCallback(async () => {
|
||||||
if (selectedUsers.length === 0) {
|
if (selectedUsers.length === 0) {
|
||||||
toast.error('Must select a person!');
|
toast.error('Must select a person!');
|
||||||
return;
|
return;
|
||||||
@@ -147,7 +147,9 @@ export default function NewConversationDialog() {
|
|||||||
value={selectedUsers}
|
value={selectedUsers}
|
||||||
onChange={handleChangeSelections}
|
onChange={handleChangeSelections}
|
||||||
filterSelectedOptions
|
filterSelectedOptions
|
||||||
isOptionEqualToValue={(optionUser, valueUser) => optionUser._id.equals(valueUser._id)}
|
isOptionEqualToValue={(optionUser, valueUser) =>
|
||||||
|
optionUser._id.toString() === valueUser._id.toString()
|
||||||
|
}
|
||||||
filterOptions={(options) => options}
|
filterOptions={(options) => options}
|
||||||
inputValue={searchQuery}
|
inputValue={searchQuery}
|
||||||
renderInput={(params) => (
|
renderInput={(params) => (
|
||||||
@@ -177,7 +179,7 @@ export default function NewConversationDialog() {
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={handleSubmitLocal}
|
onClick={handleSubmit}
|
||||||
disabled={selectedUsers.length === 0 || isSubmitting}
|
disabled={selectedUsers.length === 0 || isSubmitting}
|
||||||
variant={'contained'}
|
variant={'contained'}
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
@@ -15,5 +15,7 @@
|
|||||||
},
|
},
|
||||||
"jsx": "react-jsx"
|
"jsx": "react-jsx"
|
||||||
},
|
},
|
||||||
"include": ["src/**/*"]
|
"include": ["src/**/*"],
|
||||||
|
|
||||||
|
"exclude": ["**.js"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user