better flow for submitting
This commit is contained in:
@@ -21,7 +21,7 @@ root.render(
|
||||
maxSnack={3}
|
||||
anchorOrigin={{
|
||||
vertical: 'top',
|
||||
horizontal: 'right',
|
||||
horizontal: 'left',
|
||||
}}
|
||||
>
|
||||
<ErrorParent>
|
||||
|
||||
@@ -34,7 +34,7 @@ export default function NewConversationDialog({
|
||||
}: {
|
||||
open: boolean;
|
||||
handleClose: () => void;
|
||||
handleSubmit: (selectedUsers: User[], conversationName?: string) => void;
|
||||
handleSubmit: (selectedUsers: User[], conversationName?: string) => Promise<void>;
|
||||
}) {
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
const { user } = useAuth();
|
||||
@@ -112,7 +112,7 @@ export default function NewConversationDialog({
|
||||
|
||||
setIsSubmitting(true);
|
||||
|
||||
handleSubmit(selectedUsers, conversationName);
|
||||
await handleSubmit(selectedUsers, conversationName);
|
||||
|
||||
// clear form for next time
|
||||
setSelectedUsers([]);
|
||||
@@ -148,9 +148,6 @@ export default function NewConversationDialog({
|
||||
<FiX />
|
||||
</IconButton>
|
||||
|
||||
{isSubmitting ? (
|
||||
<CircularProgress />
|
||||
) : (
|
||||
<Container
|
||||
maxWidth="sm"
|
||||
sx={{
|
||||
@@ -170,9 +167,7 @@ export default function NewConversationDialog({
|
||||
onInputChange={handleChangeSearchInput}
|
||||
options={searchUsersResults}
|
||||
renderOption={renderOption}
|
||||
getOptionLabel={(option) =>
|
||||
typeof option === 'string' ? option : option.displayName
|
||||
}
|
||||
getOptionLabel={(option) => (typeof option === 'string' ? option : option.displayName)}
|
||||
value={selectedUsers}
|
||||
onChange={handleChangeSelections}
|
||||
filterSelectedOptions
|
||||
@@ -207,15 +202,14 @@ export default function NewConversationDialog({
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleSubmitLocal}
|
||||
disabled={selectedUsers.length === 0}
|
||||
disabled={selectedUsers.length === 0 || isSubmitting}
|
||||
variant={'contained'}
|
||||
color="primary"
|
||||
>
|
||||
Connect
|
||||
{isSubmitting ? <CircularProgress /> : 'Connect'}
|
||||
</Button>
|
||||
</Stack>
|
||||
</Container>
|
||||
)}
|
||||
</Container>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user