|
|
|
@ -1,16 +1,39 @@
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { useState, useEffect } from 'react';
|
|
|
|
|
import { Button, ConfigProvider, Dropdown, Flex } from 'antd';
|
|
|
|
|
import { DownOutlined } from '@ant-design/icons';
|
|
|
|
|
import EmailEditorPopup from './EmailEditorPopup';
|
|
|
|
|
import useStyleStore from '@/stores/StyleStore';
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore';
|
|
|
|
|
// import { isEmpty, } from '@/utils/commons';
|
|
|
|
|
// import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
|
import { useOrderStore, } from "@/stores/OrderStore";
|
|
|
|
|
|
|
|
|
|
const EmailComposer = ({ ...props }) => {
|
|
|
|
|
const [mobile] = useStyleStore((state) => [state.mobile]);
|
|
|
|
|
|
|
|
|
|
const {userId, username, emailList} = useAuthStore((state) => state.loginUser);
|
|
|
|
|
// const websocketOpened = useConversationStore((state) => state.websocketOpened);
|
|
|
|
|
// const currentConversation = useConversationStore((state) => state.currentConversation);
|
|
|
|
|
const currentConversation = useConversationStore((state) => state.currentConversation);
|
|
|
|
|
// const talkabled = !isEmpty(currentConversation.sn) && websocketOpened;
|
|
|
|
|
const { orderDetail, } = useOrderStore();
|
|
|
|
|
|
|
|
|
|
const emailListOption = emailList?.map(ele => ({ ...ele, label: ele.email, key: ele.email })) || [];
|
|
|
|
|
|
|
|
|
|
const [pickEmail, setPickEmail] = useState({});
|
|
|
|
|
const [fromUser, setFromUser] = useState();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const order_opi = Number(orderDetail?.opi_sn || userId)
|
|
|
|
|
setFromUser(order_opi);
|
|
|
|
|
|
|
|
|
|
const find =
|
|
|
|
|
emailListOption?.find((ele) => ele.opi_sn === order_opi && ele.default === true) ||
|
|
|
|
|
emailListOption?.find((ele) => ele.opi_sn === order_opi && ele.backup === true) ||
|
|
|
|
|
emailListOption?.find((ele) => ele.opi_sn === order_opi)
|
|
|
|
|
setPickEmail(find)
|
|
|
|
|
return () => {}
|
|
|
|
|
}, [orderDetail])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
const [fromEmail, setFromEmail] = useState('');
|
|
|
|
@ -18,7 +41,6 @@ const EmailComposer = ({ ...props }) => {
|
|
|
|
|
setOpen(true);
|
|
|
|
|
setFromEmail(email_addr);
|
|
|
|
|
};
|
|
|
|
|
const [pickEmail, setPickEmail] = useState({ label: 'LYT', key: 'lyt@hainatravel.com' });
|
|
|
|
|
return (
|
|
|
|
|
<Flex gap={8} className='p-2 bg-gray-200 rounded rounded-b-none border-gray-300 border-solid border border-b-0 border-x-0' align={'center'} justify={'flex-end'}>
|
|
|
|
|
<span>新邮件:</span>
|
|
|
|
@ -27,21 +49,18 @@ const EmailComposer = ({ ...props }) => {
|
|
|
|
|
// disabled={!talkabled}
|
|
|
|
|
menu={{
|
|
|
|
|
selectable: true,
|
|
|
|
|
items: [
|
|
|
|
|
{ email: 'lyt@hainatravel.com', label: 'LYT <lyt@hainatravel.com>', key: 'lyt@hainatravel.com' },
|
|
|
|
|
{ email: 'lot@hainatravel.com', label: 'LOT <lot@hainatravel.com>', key: 'lot@hainatravel.com' },
|
|
|
|
|
],
|
|
|
|
|
items: emailListOption,
|
|
|
|
|
onClick: ({ key }) => {
|
|
|
|
|
// todo: 读取邮箱列表
|
|
|
|
|
console.log(key);
|
|
|
|
|
setPickEmail({ label: key, key });
|
|
|
|
|
const find = emailListOption?.find(ele => ele.email === key);
|
|
|
|
|
setPickEmail(find);
|
|
|
|
|
openEditor(key);
|
|
|
|
|
},
|
|
|
|
|
selectedKeys: [pickEmail?.email],
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => openEditor(pickEmail.key)}
|
|
|
|
|
type='primary' className='w-auto'
|
|
|
|
|
icon={<DownOutlined />}>
|
|
|
|
|
{pickEmail.label} <{pickEmail.key}>
|
|
|
|
|
{pickEmail?.email}
|
|
|
|
|
</Dropdown.Button>
|
|
|
|
|
</ConfigProvider>
|
|
|
|
|
{/* {[
|
|
|
|
@ -57,7 +76,7 @@ const EmailComposer = ({ ...props }) => {
|
|
|
|
|
</Button>
|
|
|
|
|
))} */}
|
|
|
|
|
{/* <EmailEditor {...{ open, setOpen }} fromEmail={fromEmail} key={'email-editor'} /> */}
|
|
|
|
|
<EmailEditorPopup {...{ open, setOpen }} fromEmail={fromEmail} key={'email-editor-popup'} />
|
|
|
|
|
<EmailEditorPopup {...{ open, setOpen }} fromEmail={fromEmail} fromUser={fromUser} key={'email-editor-popup'} />
|
|
|
|
|
{/* <EmailEditorPopup2 {...{ open, setOpen }} fromEmail={fromEmail} key={'email-editor-popup2'} /> */}
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|