bigbuffet-rw/app/soapbox/features/chats/index.tsx

56 lines
1.6 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router-dom';
2022-04-15 13:19:34 -07:00
import { launchChat } from 'soapbox/actions/chats';
import AccountSearch from 'soapbox/components/account_search';
2022-08-31 10:05:01 -07:00
import { Card, CardTitle, Stack } from '../../components/ui';
import ChatList from './components/chat-list';
const messages = defineMessages({
2022-08-30 11:08:04 -07:00
title: { id: 'column.chats', defaultMessage: 'Messages' },
searchPlaceholder: { id: 'chats.search_placeholder', defaultMessage: 'Start a chat with…' },
});
const ChatIndex: React.FC = () => {
const intl = useIntl();
const dispatch = useDispatch();
const history = useHistory();
const handleSuggestion = (accountId: string) => {
dispatch(launchChat(accountId, history, true));
};
const handleClickChat = (chat: { id: string }) => {
history.push(`/chats/${chat.id}`);
};
return (
2022-08-31 10:05:01 -07:00
<Card className='p-0' variant='rounded'>
2022-08-30 11:34:21 -07:00
<div className='grid grid-cols-9'>
2022-08-31 10:05:01 -07:00
<Stack className='col-span-3 p-6 bg-gradient-to-r from-white to-gray-100' space={6}>
<CardTitle title={intl.formatMessage(messages.title)} />
2022-08-30 11:34:21 -07:00
<AccountSearch
placeholder={intl.formatMessage(messages.searchPlaceholder)}
onSelected={handleSuggestion}
/>
2022-08-31 10:05:01 -07:00
<div className='-mx-3'>
<ChatList
onClickChat={handleClickChat}
useWindowScroll
/>
</div>
2022-08-30 11:34:21 -07:00
</Stack>
<Stack className='col-span-6'>Message area</Stack>
</div>
2022-08-31 10:05:01 -07:00
</Card>
);
};
export default ChatIndex;