ChatPageNew: support account search to start a new chat

environments/review-chats-g56n7m/deployments/1169
Alex Gleason 2022-09-28 19:35:28 -05:00
rodzic acdd999c5c
commit f8199ab701
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -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>
);
};