Merge branch 'main' of github.com:hainatravel/global-sales

2.0/email-builder
Jimmy Liow 10 months ago
commit e0e4e7c767

@ -42,6 +42,8 @@ import {DialogActions, DialogButtonsList} from '../../ui/Dialog';
import FileInput from '../../ui/FileInput';
import TextInput from '../../ui/TextInput';
import { postUploadFileItem } from '../../../../actions/CommonActions.js';
export type InsertImagePayload = Readonly<ImagePayload>;
// const getDOMSelection = (targetWindow: Window | null): Selection | null =>
@ -100,17 +102,28 @@ export function InsertImageUploadedDialogBody({
const isDisabled = src === '';
const loadImage = (files: FileList | null) => {
const reader = new FileReader();
reader.onload = function () {
if (typeof reader.result === 'string') {
setSrc(reader.result);
}
return '';
};
if (files !== null) {
reader.readAsDataURL(files[0]);
const [uploading, setUploading] = useState(false);
const loadImage = async (files: FileList | null) => {
setUploading(true);
const _tmpFile = files[0];
const suffix = _tmpFile.name.slice(_tmpFile.name.lastIndexOf('.') + 1).toLocaleLowerCase();
const newName = `${Date.now().toString(32)}.${suffix}`;
const { file_url } = await postUploadFileItem(_tmpFile, newName);
setUploading(false);
if (file_url) {
setSrc(file_url);
return file_url;
}
// const reader = new FileReader();
// reader.onload = function () {
// if (typeof reader.result === 'string') {
// setSrc(reader.result);
// }
// return '';
// };
// if (files !== null) {
// reader.readAsDataURL(files[0]);
// }
};
return (
@ -133,7 +146,7 @@ export function InsertImageUploadedDialogBody({
data-test-id="image-modal-file-upload-btn"
disabled={isDisabled}
onClick={() => onClick({altText, src})}>
Confirm
{uploading ? 'Pls wait...' : 'Confirm'}
</Button>
</DialogActions>
</>

@ -45,6 +45,8 @@ import FileInput from '../../ui/FileInput';
// import Select from '../../ui/Select';
import TextInput from '../../ui/TextInput';
import { postUploadFileItem } from '../../../../actions/CommonActions.js';
export type InsertInlineImagePayload = Readonly<InlineImagePayload>;
const getDOMSelection = (targetWindow: Window | null): Selection | null =>
@ -78,17 +80,28 @@ export function InsertInlineImageDialog({
setPosition(e.target.value as Position);
};
const loadImage = (files: FileList | null) => {
const reader = new FileReader();
reader.onload = function () {
if (typeof reader.result === 'string') {
setSrc(reader.result);
}
return '';
};
if (files !== null) {
reader.readAsDataURL(files[0]);
const [uploading, setUploading] = useState(false);
const loadImage = async (files: FileList | null) => {
setUploading(true);
const _tmpFile = files[0];
const suffix = _tmpFile.name.slice(_tmpFile.name.lastIndexOf('.') + 1).toLocaleLowerCase();
const newName = `${Date.now().toString(32)}.${suffix}`;
const { file_url } = await postUploadFileItem(_tmpFile, newName);
setUploading(false);
if (file_url) {
setSrc(file_url);
return file_url;
}
// const reader = new FileReader();
// reader.onload = function () {
// if (typeof reader.result === 'string') {
// setSrc(reader.result);
// }
// return '';
// };
// if (files !== null) {
// reader.readAsDataURL(files[0]);
// }
};
useEffect(() => {

@ -350,8 +350,15 @@ const messageSlice = (set, get) => ({
unread_msg_count: 0,
whatsapp_name: message.to, //message?.senderName || message?.sender || '',
customer_name: message.to, // message?.senderName || message?.sender || '',
whatsapp_phone_number: message.to,
conversation_expiretime: message?.conversation?.expireTime || '', // 保留使用UTC时间
whatsapp_phone_number: message.type === 'email' ? null : message.to,
show_default: message.to || '',
last_message: message,
channels: {
"email": message.type === 'email' ? message.from : null,
"phone_number": message.type === 'email' ? null : message.from,
"whatsapp_phone_number": message.type === 'email' ? null : message.from,
},
}];
}

@ -256,7 +256,7 @@ const ChatListItem = (({item, refreshConversationList,setListUpdateFlag,onSwitch
{...item}
key={item.sn}
id={item.sn}
letterItem={{ id: item.show_default, letter: (item.show_default).slice(0, 5) }}
letterItem={{ id: item.show_default, letter: (item?.show_default || '').split("@")[0].slice(0, 5) }}
alt={item.whatsapp_name}
title={
<span>

Loading…
Cancel
Save