ChatPageNew: support account search to start a new chat

This commit is contained in:
Alex Gleason 2022-09-28 19:35:28 -05:00
parent acdd999c5c
commit f8199ab701
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -1,15 +1,30 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import AccountSearch from 'soapbox/components/account_search';
import { CardTitle, Stack } from 'soapbox/components/ui';
import { useChats } from 'soapbox/queries/chats';
interface IChatPageNew {
}
/** New message form to create a chat. */
const ChatPageNew: React.FC<IChatPageNew> = () => {
const history = useHistory();
const { getOrCreateChatByAccountId } = useChats();
const handleAccountSelected = async (accountId: string) => {
const { data } = await getOrCreateChatByAccountId(accountId);
history.push(`/chats/${data.id}`);
};
return (
<Stack className='h-full p-6 space-y-8'>
<CardTitle title='New Message' />
<AccountSearch
onSelected={handleAccountSelected}
/>
</Stack>
);
};