|
|
@ -1,20 +1,23 @@
|
|
|
|
import { useEffect, useContext } from 'react';
|
|
|
|
import { useEffect, useContext } from 'react';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
import { Layout } from 'antd';
|
|
|
|
import { Layout, List, Avatar } from 'antd';
|
|
|
|
import Messages from './Components/Messages';
|
|
|
|
import Messages from './Components/Messages';
|
|
|
|
import InputBox from './Components/InputBox';
|
|
|
|
import InputBox from './Components/InputBox';
|
|
|
|
import Conversations from './Components/Conversations';
|
|
|
|
import Conversations from './Components/ConversationsList';
|
|
|
|
import CustomerProfile from './Components/CustomerProfile';
|
|
|
|
import CustomerProfile from './Components/CustomerProfile';
|
|
|
|
|
|
|
|
|
|
|
|
import WebSocketLib from '@/lib/websocketLib';
|
|
|
|
import WebSocketLib from '@/lib/websocketLib';
|
|
|
|
import { useStore } from '@/stores/StoreContext.js';
|
|
|
|
import { useStore } from '@/stores/StoreContext.js';
|
|
|
|
|
|
|
|
import { stringToColour } from '@/utils/utils';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import './Conversations.css';
|
|
|
|
|
|
|
|
|
|
|
|
const customer = { url: 'ws://202.103.68.144:8888/whatever/', authToken: 'customer1Token' };
|
|
|
|
const customer = { url: 'ws://202.103.68.144:8888/whatever/', authToken: 'customer1Token' };
|
|
|
|
// Create a WebSocketLib instance for each customer
|
|
|
|
// Create a WebSocketLib instance for each customer
|
|
|
|
// const wsConnect = new WebSocketLib(customer.url, customer.authToken, 'WhatApp');
|
|
|
|
// const wsConnect = new WebSocketLib(customer.url, customer.authToken, 'WhatApp');
|
|
|
|
// const wsConnect = new WebSocketLib(customer.url, customer.authToken, 'aaa');
|
|
|
|
// const wsConnect = new WebSocketLib(customer.url, customer.authToken, 'aaa');
|
|
|
|
|
|
|
|
|
|
|
|
const { Sider, Content } = Layout;
|
|
|
|
const { Sider, Content, Header, Footer } = Layout;
|
|
|
|
|
|
|
|
|
|
|
|
const CList = [
|
|
|
|
const CList = [
|
|
|
|
{ name: 'Customer_1', label: 'Customer_1', key: 'Customer_1', value: 'Customer_1' },
|
|
|
|
{ name: 'Customer_1', label: 'Customer_1', key: 'Customer_1', value: 'Customer_1' },
|
|
|
@ -32,24 +35,52 @@ const ChatWindow = observer(() => {
|
|
|
|
const { conversationsStore } = useStore();
|
|
|
|
const { conversationsStore } = useStore();
|
|
|
|
const { sendMessage, messages } = conversationsStore;
|
|
|
|
const { sendMessage, messages } = conversationsStore;
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
return () => {};
|
|
|
|
}, []);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Layout style={{maxHeight: 'calc(100% - 150px)', height: 'calc(100% - 150px)'}}>
|
|
|
|
<Layout className='full-height' style={{ maxHeight: 'calc(100% - 150px)', height: 'calc(100% - 150px)' }}>
|
|
|
|
<Sider width={300} theme={'light'} style={{ height: '70vh' }}>
|
|
|
|
<Sider width={220} theme={'light'} className='scrollable-column' style={{ height: '70vh' }}>
|
|
|
|
<Conversations conversations={CList} />
|
|
|
|
<Conversations conversations={CList} />
|
|
|
|
</Sider>
|
|
|
|
</Sider>
|
|
|
|
|
|
|
|
|
|
|
|
<Content className='h70' style={{maxHeight: '70vh', height: '70vh'}}>
|
|
|
|
<Content className='h70' style={{ maxHeight: '70vh', height: '70vh' }}>
|
|
|
|
<Layout style={{ height: '100%' }}>
|
|
|
|
<Layout style={{ height: '100%' }}>
|
|
|
|
<Messages />
|
|
|
|
<Header className='ant-layout-sider-light ant-card' style={{paddingLeft: '10px'}}>
|
|
|
|
<InputBox onSend={(v) => sendMessage(v)} />
|
|
|
|
<List
|
|
|
|
|
|
|
|
dataSource={[{ name: 'Customer_1', label: 'Customer_1', key: 'Customer_1', value: 'Customer_1' }]}
|
|
|
|
|
|
|
|
renderItem={(item, ii) => (
|
|
|
|
|
|
|
|
<List.Item actions={[<a key='list-loadmore-edit'>mark</a>]}>
|
|
|
|
|
|
|
|
<List.Item.Meta
|
|
|
|
|
|
|
|
avatar={
|
|
|
|
|
|
|
|
<Avatar
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
backgroundColor: stringToColour(item.name),
|
|
|
|
|
|
|
|
verticalAlign: 'middle',
|
|
|
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
{item.name}
|
|
|
|
|
|
|
|
</Avatar>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
title={item.name}
|
|
|
|
|
|
|
|
description='{最近的消息}'
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</List.Item>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Header>
|
|
|
|
|
|
|
|
<Content style={{ maxHeight: '70vh', height: '70vh' }}>
|
|
|
|
|
|
|
|
<div className='scrollable-column' >
|
|
|
|
|
|
|
|
<Messages />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</Content>
|
|
|
|
|
|
|
|
<Footer className='ant-layout-sider-light' style={{padding: '10px'}}>
|
|
|
|
|
|
|
|
<InputBox onSend={(v) => sendMessage(v)} />
|
|
|
|
|
|
|
|
</Footer>
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
|
|
|
|
|
|
|
{/* <InputBox onSend={(v) => sendMessage(v)} /> */}
|
|
|
|
</Content>
|
|
|
|
</Content>
|
|
|
|
|
|
|
|
|
|
|
|
<Sider width={300} theme={'light'}>
|
|
|
|
<Sider width={300} theme={'light'} className='scrollable-column' style={{ maxHeight: '70vh', height: '70vh' }}>
|
|
|
|
<CustomerProfile customer={{}} />
|
|
|
|
<CustomerProfile customer={{}} />
|
|
|
|
</Sider>
|
|
|
|
</Sider>
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
|
|
|