@webinex/chatify 2.0.0-alpha13 → 2.0.0-alpha14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chatify-CwAfN1wu.js → Chatify-CP2jgo8d.js} +191 -118
- package/dist/Chatify-CP2jgo8d.js.map +1 -0
- package/dist/Chatify.css +28 -0
- package/dist/audit.js +3 -2
- package/dist/audit.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/types/audit/index.d.ts +17 -15
- package/dist/types/ui/Chat/ChatContext.d.ts +2 -0
- package/dist/types/ui/Chat/ChatPanel.d.ts +7 -0
- package/dist/types/ui/Chat/ChatView.d.ts +4 -2
- package/dist/types/ui/ChatGroup/ChatGroupContext.d.ts +4 -1
- package/dist/types/ui/ChatGroup/ChatGroupPanel.d.ts +21 -2
- package/dist/types/ui/Conversation/Conversation.d.ts +1 -0
- package/dist/types/ui/Conversation/ConversationContext.d.ts +1 -0
- package/dist/types/ui/Conversation/ConversationHeader.d.ts +4 -1
- package/dist/types/ui/localizer.d.ts +4 -1
- package/dist/types/ui/useCompact.d.ts +4 -0
- package/package.json +81 -81
- package/src/audit/AuditChatList.tsx +25 -25
- package/src/audit/AuditConversationPanel.tsx +49 -48
- package/src/audit/AuditPanel.tsx +76 -76
- package/src/audit/AuditPanelCustomizeValue.ts +11 -11
- package/src/audit/AuditSearch.tsx +89 -89
- package/src/audit/AuditSearchValue.tsx +42 -42
- package/src/audit/auditApi.tsx +113 -113
- package/src/audit/index.d.ts +18 -18
- package/src/audit/index.tsx +28 -28
- package/src/audit/styles.scss +72 -72
- package/src/core/api/api.ts +675 -675
- package/src/core/api/baseApi.ts +38 -38
- package/src/core/api/index.ts +1 -1
- package/src/core/client.ts +298 -298
- package/src/core/constants.ts +1 -1
- package/src/core/debounce.ts +90 -90
- package/src/core/index.ts +4 -4
- package/src/core/types.tsx +182 -182
- package/src/index.ts +2 -2
- package/src/styles/aside.scss +34 -26
- package/src/styles/chat-list.scss +138 -138
- package/src/styles/chat.scss +11 -11
- package/src/styles/conversation.scss +199 -200
- package/src/styles/index.scss +227 -220
- package/src/styles/input.scss +148 -148
- package/src/styles/keyframes.scss +14 -14
- package/src/styles/members.scss +30 -13
- package/src/styles/mixins.scss +38 -25
- package/src/styles/variables.scss +13 -13
- package/src/ui/Chat/ChatContext.tsx +32 -30
- package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
- package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
- package/src/ui/Chat/ChatPanel.tsx +46 -30
- package/src/ui/Chat/ChatView.tsx +122 -115
- package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
- package/src/ui/Chat/Members/ChatMembersPanel.tsx +128 -112
- package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
- package/src/ui/Chat/Members/index.ts +13 -13
- package/src/ui/Chat/index.ts +6 -6
- package/src/ui/ChatGroup/AutoReply/AutoReplyButton.tsx +21 -21
- package/src/ui/ChatGroup/AutoReply/AutoReplyForm.tsx +50 -50
- package/src/ui/ChatGroup/AutoReply/AutoReplyPanel.tsx +94 -94
- package/src/ui/ChatGroup/AutoReply/AutoReplyPeriodInput.tsx +22 -22
- package/src/ui/ChatGroup/AutoReply/AutoReplyTextInput.tsx +22 -22
- package/src/ui/ChatGroup/AutoReply/index.ts +19 -19
- package/src/ui/ChatGroup/ChatGroupContext.tsx +63 -61
- package/src/ui/ChatGroup/ChatGroupPanel.tsx +110 -75
- package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
- package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
- package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
- package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
- package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
- package/src/ui/ChatGroup/Create/index.ts +19 -19
- package/src/ui/ChatGroup/Layout/ChatGroupActions.tsx +15 -15
- package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
- package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +17 -10
- package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
- package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
- package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +21 -19
- package/src/ui/ChatGroup/Layout/index.ts +22 -22
- package/src/ui/ChatGroup/List/ChatListPanel.tsx +28 -28
- package/src/ui/ChatGroup/List/index.ts +8 -8
- package/src/ui/ChatGroup/index.ts +6 -6
- package/src/ui/Chatify.tsx +15 -15
- package/src/ui/Conversation/Conversation.tsx +96 -92
- package/src/ui/Conversation/ConversationActions.tsx +12 -12
- package/src/ui/Conversation/ConversationBody.tsx +28 -28
- package/src/ui/Conversation/ConversationContext.ts +31 -30
- package/src/ui/Conversation/ConversationHeader.tsx +35 -19
- package/src/ui/Conversation/ConversationName.tsx +7 -7
- package/src/ui/Conversation/InputBox/InputBox.tsx +126 -126
- package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -38
- package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -21
- package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -78
- package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -26
- package/src/ui/Conversation/InputBox/InputTextBox.tsx +63 -61
- package/src/ui/Conversation/InputBox/index.ts +23 -23
- package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
- package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
- package/src/ui/Conversation/Message/MessageContent.tsx +15 -15
- package/src/ui/Conversation/Message/MessageFile.tsx +54 -54
- package/src/ui/Conversation/Message/MessageFileList.tsx +14 -14
- package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
- package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
- package/src/ui/Conversation/Message/MessageText.tsx +7 -7
- package/src/ui/Conversation/Message/index.ts +28 -28
- package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
- package/src/ui/Conversation/NextObserver/index.ts +1 -1
- package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
- package/src/ui/Conversation/ReadObserver/index.ts +1 -1
- package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
- package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
- package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
- package/src/ui/Conversation/SendingMessage/index.ts +16 -16
- package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
- package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
- package/src/ui/Conversation/SystemMessage/index.ts +10 -10
- package/src/ui/Conversation/index.ts +13 -13
- package/src/ui/Thread/ThreadActions.tsx +22 -22
- package/src/ui/Thread/ThreadContext.ts +13 -13
- package/src/ui/Thread/ThreadPanel.tsx +128 -127
- package/src/ui/Thread/index.tsx +3 -3
- package/src/ui/color.ts +20 -20
- package/src/ui/common/Avatar.tsx +20 -20
- package/src/ui/common/ChatList/ChatList.tsx +83 -84
- package/src/ui/common/ChatList/ChatListItemAvatar.tsx +22 -22
- package/src/ui/common/ChatList/ChatListItemBox.tsx +32 -32
- package/src/ui/common/ChatList/ChatListItemLastMessage.tsx +15 -15
- package/src/ui/common/ChatList/ChatListItemLastMessageAuthor.tsx +15 -15
- package/src/ui/common/ChatList/ChatListItemLastMessageContent.tsx +21 -21
- package/src/ui/common/ChatList/ChatListItemLastMessageSentAt.tsx +22 -22
- package/src/ui/common/ChatList/ChatListItemName.tsx +8 -8
- package/src/ui/common/ChatList/ChatListItemUnreadCount.tsx +12 -12
- package/src/ui/common/ChatList/ChatListValue.ts +9 -9
- package/src/ui/common/ChatList/index.ts +32 -32
- package/src/ui/common/Icon.tsx +48 -48
- package/src/ui/common/MessageSkeleton.tsx +20 -20
- package/src/ui/common/index.ts +14 -14
- package/src/ui/customize.tsx +51 -51
- package/src/ui/index.ts +11 -11
- package/src/ui/localizer.tsx +148 -137
- package/src/ui/useCompact.tsx +32 -0
- package/src/ui/useFormatter.tsx +17 -17
- package/dist/Chatify-CwAfN1wu.js.map +0 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { chatifyApi } from '../../../core';
|
|
2
|
-
import { Tooltip } from 'antd';
|
|
3
|
-
import { customize } from '../../customize';
|
|
4
|
-
import { Avatar as AntdAvatar } from 'antd';
|
|
5
|
-
import { Avatar } from '../../common/Avatar';
|
|
6
|
-
import { useChatContext } from '../ChatContext';
|
|
7
|
-
|
|
8
|
-
export const ChatMembersPreview = customize('ChatMembersPreview', () => {
|
|
9
|
-
const { id } = useChatContext();
|
|
10
|
-
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
11
|
-
|
|
12
|
-
if (!chat?.members) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<AntdAvatar.Group max={{ count: 5 }}>
|
|
18
|
-
{chat.members.map((x) => (
|
|
19
|
-
<Tooltip key={x.id} title={x.name}>
|
|
20
|
-
<Avatar account={x} />
|
|
21
|
-
</Tooltip>
|
|
22
|
-
))}
|
|
23
|
-
</AntdAvatar.Group>
|
|
24
|
-
);
|
|
25
|
-
});
|
|
1
|
+
import { chatifyApi } from '../../../core';
|
|
2
|
+
import { Tooltip } from 'antd';
|
|
3
|
+
import { customize } from '../../customize';
|
|
4
|
+
import { Avatar as AntdAvatar } from 'antd';
|
|
5
|
+
import { Avatar } from '../../common/Avatar';
|
|
6
|
+
import { useChatContext } from '../ChatContext';
|
|
7
|
+
|
|
8
|
+
export const ChatMembersPreview = customize('ChatMembersPreview', () => {
|
|
9
|
+
const { id } = useChatContext();
|
|
10
|
+
const { data: chat } = chatifyApi.useGetChatQuery({ id });
|
|
11
|
+
|
|
12
|
+
if (!chat?.members) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<AntdAvatar.Group max={{ count: 5 }}>
|
|
18
|
+
{chat.members.map((x) => (
|
|
19
|
+
<Tooltip key={x.id} title={x.name}>
|
|
20
|
+
<Avatar account={x} />
|
|
21
|
+
</Tooltip>
|
|
22
|
+
))}
|
|
23
|
+
</AntdAvatar.Group>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ChatMembersButton } from './ChatMembersButton';
|
|
2
|
-
import { ChatMembersPanel } from './ChatMembersPanel';
|
|
3
|
-
import { ChatMembersPreview } from './ChatMembersPreview';
|
|
4
|
-
|
|
5
|
-
export * from './ChatMembersButton';
|
|
6
|
-
export * from './ChatMembersPanel';
|
|
7
|
-
export * from './ChatMembersPreview';
|
|
8
|
-
|
|
9
|
-
export interface ChatMembersCustomizeValue {
|
|
10
|
-
ChatMembersButton?: typeof ChatMembersButton.Component | null;
|
|
11
|
-
ChatMembersPanel?: typeof ChatMembersPanel.Component | null;
|
|
12
|
-
ChatMembersPreview?: typeof ChatMembersPreview.Component | null;
|
|
13
|
-
}
|
|
1
|
+
import { ChatMembersButton } from './ChatMembersButton';
|
|
2
|
+
import { ChatMembersPanel } from './ChatMembersPanel';
|
|
3
|
+
import { ChatMembersPreview } from './ChatMembersPreview';
|
|
4
|
+
|
|
5
|
+
export * from './ChatMembersButton';
|
|
6
|
+
export * from './ChatMembersPanel';
|
|
7
|
+
export * from './ChatMembersPreview';
|
|
8
|
+
|
|
9
|
+
export interface ChatMembersCustomizeValue {
|
|
10
|
+
ChatMembersButton?: typeof ChatMembersButton.Component | null;
|
|
11
|
+
ChatMembersPanel?: typeof ChatMembersPanel.Component | null;
|
|
12
|
+
ChatMembersPreview?: typeof ChatMembersPreview.Component | null;
|
|
13
|
+
}
|
package/src/ui/Chat/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './Members';
|
|
2
|
-
export * from './ChatView';
|
|
3
|
-
export * from './ChatContext';
|
|
4
|
-
export * from './ChatEditableHeaderName';
|
|
5
|
-
export * from './ChatHeaderActions';
|
|
6
|
-
export * from './ChatPanel';
|
|
1
|
+
export * from './Members';
|
|
2
|
+
export * from './ChatView';
|
|
3
|
+
export * from './ChatContext';
|
|
4
|
+
export * from './ChatEditableHeaderName';
|
|
5
|
+
export * from './ChatHeaderActions';
|
|
6
|
+
export * from './ChatPanel';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Button } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { useChatGroupContext } from '../ChatGroupContext';
|
|
4
|
-
import { useLocalizer } from '../../localizer';
|
|
5
|
-
import { Icon } from '../../common/Icon';
|
|
6
|
-
|
|
7
|
-
export const AutoReplyButton = customize('AutoReplyButton', () => {
|
|
8
|
-
const { toggleAutoReply } = useChatGroupContext();
|
|
9
|
-
const localizer = useLocalizer();
|
|
10
|
-
const titleText = localizer.autoReply.buttonTitle();
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<Button
|
|
14
|
-
className="wxchtf-add-btn-settings"
|
|
15
|
-
onClick={toggleAutoReply}
|
|
16
|
-
icon={<Icon type="settings" />}
|
|
17
|
-
title={titleText}
|
|
18
|
-
aria-label={titleText}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
});
|
|
1
|
+
import { Button } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { useChatGroupContext } from '../ChatGroupContext';
|
|
4
|
+
import { useLocalizer } from '../../localizer';
|
|
5
|
+
import { Icon } from '../../common/Icon';
|
|
6
|
+
|
|
7
|
+
export const AutoReplyButton = customize('AutoReplyButton', () => {
|
|
8
|
+
const { toggleAutoReply } = useChatGroupContext();
|
|
9
|
+
const localizer = useLocalizer();
|
|
10
|
+
const titleText = localizer.autoReply.buttonTitle();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Button
|
|
14
|
+
className="wxchtf-add-btn-settings"
|
|
15
|
+
onClick={toggleAutoReply}
|
|
16
|
+
icon={<Icon type="settings" />}
|
|
17
|
+
title={titleText}
|
|
18
|
+
aria-label={titleText}
|
|
19
|
+
/>
|
|
20
|
+
);
|
|
21
|
+
});
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Button, Form } from 'antd';
|
|
2
|
-
import { Dayjs } from 'dayjs';
|
|
3
|
-
import { customize } from '../../customize';
|
|
4
|
-
import { useLocalizer } from '../../localizer';
|
|
5
|
-
import { AutoReplyPeriodInput } from './AutoReplyPeriodInput';
|
|
6
|
-
import { AutoReplyTextInput } from './AutoReplyTextInput';
|
|
7
|
-
import { useEffect } from 'react';
|
|
8
|
-
|
|
9
|
-
export interface AutoReplyFormValue {
|
|
10
|
-
period: [Dayjs, Dayjs];
|
|
11
|
-
text: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface AutoReplyFormProps {
|
|
15
|
-
value: AutoReplyFormValue;
|
|
16
|
-
onSubmit: (value: AutoReplyFormValue) => void;
|
|
17
|
-
busy?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const AUTO_REPLY_FORM_INITIAL_VALUE: AutoReplyFormValue = {
|
|
21
|
-
period: [] as unknown as [Dayjs, Dayjs],
|
|
22
|
-
text: '',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const AutoReplyForm = customize('AutoReplyForm', (props: AutoReplyFormProps) => {
|
|
26
|
-
const { value, busy = false, onSubmit } = props;
|
|
27
|
-
const localizer = useLocalizer();
|
|
28
|
-
|
|
29
|
-
const [form] = Form.useForm<AutoReplyFormValue>();
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
form.setFieldsValue(value);
|
|
33
|
-
}, [value, form]);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<Form<AutoReplyFormValue>
|
|
37
|
-
form={form}
|
|
38
|
-
layout="vertical"
|
|
39
|
-
onFinish={onSubmit}
|
|
40
|
-
disabled={busy}
|
|
41
|
-
initialValues={value}
|
|
42
|
-
>
|
|
43
|
-
<AutoReplyPeriodInput name="period" />
|
|
44
|
-
<AutoReplyTextInput name="text" />
|
|
45
|
-
<Button loading={busy} type="primary" block htmlType="submit">
|
|
46
|
-
{localizer.autoReply.submitBtn()}
|
|
47
|
-
</Button>
|
|
48
|
-
</Form>
|
|
49
|
-
);
|
|
50
|
-
});
|
|
1
|
+
import { Button, Form } from 'antd';
|
|
2
|
+
import { Dayjs } from 'dayjs';
|
|
3
|
+
import { customize } from '../../customize';
|
|
4
|
+
import { useLocalizer } from '../../localizer';
|
|
5
|
+
import { AutoReplyPeriodInput } from './AutoReplyPeriodInput';
|
|
6
|
+
import { AutoReplyTextInput } from './AutoReplyTextInput';
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
|
|
9
|
+
export interface AutoReplyFormValue {
|
|
10
|
+
period: [Dayjs, Dayjs];
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AutoReplyFormProps {
|
|
15
|
+
value: AutoReplyFormValue;
|
|
16
|
+
onSubmit: (value: AutoReplyFormValue) => void;
|
|
17
|
+
busy?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const AUTO_REPLY_FORM_INITIAL_VALUE: AutoReplyFormValue = {
|
|
21
|
+
period: [] as unknown as [Dayjs, Dayjs],
|
|
22
|
+
text: '',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const AutoReplyForm = customize('AutoReplyForm', (props: AutoReplyFormProps) => {
|
|
26
|
+
const { value, busy = false, onSubmit } = props;
|
|
27
|
+
const localizer = useLocalizer();
|
|
28
|
+
|
|
29
|
+
const [form] = Form.useForm<AutoReplyFormValue>();
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
form.setFieldsValue(value);
|
|
33
|
+
}, [value, form]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Form<AutoReplyFormValue>
|
|
37
|
+
form={form}
|
|
38
|
+
layout="vertical"
|
|
39
|
+
onFinish={onSubmit}
|
|
40
|
+
disabled={busy}
|
|
41
|
+
initialValues={value}
|
|
42
|
+
>
|
|
43
|
+
<AutoReplyPeriodInput name="period" />
|
|
44
|
+
<AutoReplyTextInput name="text" />
|
|
45
|
+
<Button loading={busy} type="primary" block htmlType="submit">
|
|
46
|
+
{localizer.autoReply.submitBtn()}
|
|
47
|
+
</Button>
|
|
48
|
+
</Form>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import { useCallback, useMemo } from 'react';
|
|
3
|
-
import { Button } from 'antd';
|
|
4
|
-
import { customize } from '../../customize';
|
|
5
|
-
import { useLocalizer } from '../../localizer';
|
|
6
|
-
import { useChatGroupContext } from '../ChatGroupContext';
|
|
7
|
-
import { Icon } from '../../common/Icon';
|
|
8
|
-
import { AutoReply } from '../../../core';
|
|
9
|
-
import { chatifyApi } from '../../../core';
|
|
10
|
-
import { AUTO_REPLY_FORM_INITIAL_VALUE, AutoReplyForm, AutoReplyFormValue } from './AutoReplyForm';
|
|
11
|
-
|
|
12
|
-
function mapToFormValue(autoReply?: AutoReply | null): AutoReplyFormValue {
|
|
13
|
-
if (!autoReply) {
|
|
14
|
-
return AUTO_REPLY_FORM_INITIAL_VALUE;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
period: [dayjs(autoReply.period.start), dayjs(autoReply.period.end)],
|
|
19
|
-
text: autoReply.text,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function useValue() {
|
|
24
|
-
const { data: me } = chatifyApi.useGeCurrentUserAccountQuery();
|
|
25
|
-
|
|
26
|
-
const value = useMemo<AutoReplyFormValue>(() => {
|
|
27
|
-
return mapToFormValue(me?.autoReply);
|
|
28
|
-
}, [me]);
|
|
29
|
-
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function useAutoReplyActions() {
|
|
34
|
-
const meId = chatifyApi.settings.me();
|
|
35
|
-
const [updateAccount, { isLoading }] = chatifyApi.useUpdateAccountMutation();
|
|
36
|
-
|
|
37
|
-
const onSubmit = useCallback(
|
|
38
|
-
(value: AutoReplyFormValue) =>
|
|
39
|
-
updateAccount({
|
|
40
|
-
id: meId,
|
|
41
|
-
autoReply: {
|
|
42
|
-
hasValue: true,
|
|
43
|
-
value: {
|
|
44
|
-
text: value.text,
|
|
45
|
-
period: {
|
|
46
|
-
start: value.period[0].toISOString(),
|
|
47
|
-
end: value.period[1].toISOString(),
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
}).unwrap(),
|
|
52
|
-
[updateAccount, meId],
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const onClear = useCallback(
|
|
56
|
-
() =>
|
|
57
|
-
updateAccount({
|
|
58
|
-
id: meId,
|
|
59
|
-
autoReply: {
|
|
60
|
-
hasValue: true,
|
|
61
|
-
value: null,
|
|
62
|
-
},
|
|
63
|
-
}).unwrap(),
|
|
64
|
-
[updateAccount, meId],
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return [onSubmit, isLoading, onClear] as const;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const AutoReplyPanel = customize('AutoReplyPanel', () => {
|
|
71
|
-
const localizer = useLocalizer();
|
|
72
|
-
const { toggleAutoReply } = useChatGroupContext();
|
|
73
|
-
const value = useValue();
|
|
74
|
-
const [onSubmit, submitting, onClear] = useAutoReplyActions();
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<div className="wxchtf-auto-reply-panel">
|
|
78
|
-
<Button
|
|
79
|
-
onClick={toggleAutoReply}
|
|
80
|
-
className="wxchtf-auto-reply-panel-close"
|
|
81
|
-
type="link"
|
|
82
|
-
icon={<Icon type="close" />}
|
|
83
|
-
/>
|
|
84
|
-
<div className="wxchtf-auto-reply-panel-header">
|
|
85
|
-
<h3>{localizer.autoReply.title()}</h3>
|
|
86
|
-
<Button type="link" onClick={onClear} disabled={submitting} className="wxchtf-auto-reply-panel-clear">
|
|
87
|
-
{localizer.autoReply.clearBtn()}
|
|
88
|
-
</Button>
|
|
89
|
-
</div>
|
|
90
|
-
|
|
91
|
-
<AutoReplyForm value={value} busy={submitting ?? false} onSubmit={onSubmit} />
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
});
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import { customize } from '../../customize';
|
|
5
|
+
import { useLocalizer } from '../../localizer';
|
|
6
|
+
import { useChatGroupContext } from '../ChatGroupContext';
|
|
7
|
+
import { Icon } from '../../common/Icon';
|
|
8
|
+
import { AutoReply } from '../../../core';
|
|
9
|
+
import { chatifyApi } from '../../../core';
|
|
10
|
+
import { AUTO_REPLY_FORM_INITIAL_VALUE, AutoReplyForm, AutoReplyFormValue } from './AutoReplyForm';
|
|
11
|
+
|
|
12
|
+
function mapToFormValue(autoReply?: AutoReply | null): AutoReplyFormValue {
|
|
13
|
+
if (!autoReply) {
|
|
14
|
+
return AUTO_REPLY_FORM_INITIAL_VALUE;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
period: [dayjs(autoReply.period.start), dayjs(autoReply.period.end)],
|
|
19
|
+
text: autoReply.text,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function useValue() {
|
|
24
|
+
const { data: me } = chatifyApi.useGeCurrentUserAccountQuery();
|
|
25
|
+
|
|
26
|
+
const value = useMemo<AutoReplyFormValue>(() => {
|
|
27
|
+
return mapToFormValue(me?.autoReply);
|
|
28
|
+
}, [me]);
|
|
29
|
+
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function useAutoReplyActions() {
|
|
34
|
+
const meId = chatifyApi.settings.me();
|
|
35
|
+
const [updateAccount, { isLoading }] = chatifyApi.useUpdateAccountMutation();
|
|
36
|
+
|
|
37
|
+
const onSubmit = useCallback(
|
|
38
|
+
(value: AutoReplyFormValue) =>
|
|
39
|
+
updateAccount({
|
|
40
|
+
id: meId,
|
|
41
|
+
autoReply: {
|
|
42
|
+
hasValue: true,
|
|
43
|
+
value: {
|
|
44
|
+
text: value.text,
|
|
45
|
+
period: {
|
|
46
|
+
start: value.period[0].toISOString(),
|
|
47
|
+
end: value.period[1].toISOString(),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}).unwrap(),
|
|
52
|
+
[updateAccount, meId],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const onClear = useCallback(
|
|
56
|
+
() =>
|
|
57
|
+
updateAccount({
|
|
58
|
+
id: meId,
|
|
59
|
+
autoReply: {
|
|
60
|
+
hasValue: true,
|
|
61
|
+
value: null,
|
|
62
|
+
},
|
|
63
|
+
}).unwrap(),
|
|
64
|
+
[updateAccount, meId],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return [onSubmit, isLoading, onClear] as const;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const AutoReplyPanel = customize('AutoReplyPanel', () => {
|
|
71
|
+
const localizer = useLocalizer();
|
|
72
|
+
const { toggleAutoReply } = useChatGroupContext();
|
|
73
|
+
const value = useValue();
|
|
74
|
+
const [onSubmit, submitting, onClear] = useAutoReplyActions();
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className="wxchtf-auto-reply-panel">
|
|
78
|
+
<Button
|
|
79
|
+
onClick={toggleAutoReply}
|
|
80
|
+
className="wxchtf-auto-reply-panel-close"
|
|
81
|
+
type="link"
|
|
82
|
+
icon={<Icon type="close" />}
|
|
83
|
+
/>
|
|
84
|
+
<div className="wxchtf-auto-reply-panel-header">
|
|
85
|
+
<h3>{localizer.autoReply.title()}</h3>
|
|
86
|
+
<Button type="link" onClick={onClear} disabled={submitting} className="wxchtf-auto-reply-panel-clear">
|
|
87
|
+
{localizer.autoReply.clearBtn()}
|
|
88
|
+
</Button>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<AutoReplyForm value={value} busy={submitting ?? false} onSubmit={onSubmit} />
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { DatePicker, Form } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { useLocalizer } from '../../localizer';
|
|
4
|
-
|
|
5
|
-
export interface AutoReplyPeriodInputProps {
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const AutoReplyPeriodInput = customize('AutoReplyPeriodInput', (props: AutoReplyPeriodInputProps) => {
|
|
10
|
-
const { name } = props;
|
|
11
|
-
const localizer = useLocalizer();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Form.Item
|
|
15
|
-
label={localizer.autoReply.period.label()}
|
|
16
|
-
name={name}
|
|
17
|
-
rules={[{ required: true, message: localizer.autoReply.period.required() }]}
|
|
18
|
-
>
|
|
19
|
-
<DatePicker.RangePicker format={localizer.autoReply.period.format()} />
|
|
20
|
-
</Form.Item>
|
|
21
|
-
);
|
|
22
|
-
});
|
|
1
|
+
import { DatePicker, Form } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { useLocalizer } from '../../localizer';
|
|
4
|
+
|
|
5
|
+
export interface AutoReplyPeriodInputProps {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const AutoReplyPeriodInput = customize('AutoReplyPeriodInput', (props: AutoReplyPeriodInputProps) => {
|
|
10
|
+
const { name } = props;
|
|
11
|
+
const localizer = useLocalizer();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Form.Item
|
|
15
|
+
label={localizer.autoReply.period.label()}
|
|
16
|
+
name={name}
|
|
17
|
+
rules={[{ required: true, message: localizer.autoReply.period.required() }]}
|
|
18
|
+
>
|
|
19
|
+
<DatePicker.RangePicker format={localizer.autoReply.period.format()} />
|
|
20
|
+
</Form.Item>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Form, Input } from 'antd';
|
|
2
|
-
import { customize } from '../../customize';
|
|
3
|
-
import { useLocalizer } from '../../localizer';
|
|
4
|
-
|
|
5
|
-
export interface AutoReplyTextInputProps {
|
|
6
|
-
name: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const AutoReplyTextInput = customize('AutoReplyTextInput', (props: AutoReplyTextInputProps) => {
|
|
10
|
-
const { name } = props;
|
|
11
|
-
const localizer = useLocalizer();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<Form.Item
|
|
15
|
-
label={localizer.autoReply.text.label()}
|
|
16
|
-
name={name}
|
|
17
|
-
rules={[{ required: true, message: localizer.autoReply.text.required() }]}
|
|
18
|
-
>
|
|
19
|
-
<Input.TextArea rows={4} />
|
|
20
|
-
</Form.Item>
|
|
21
|
-
);
|
|
22
|
-
});
|
|
1
|
+
import { Form, Input } from 'antd';
|
|
2
|
+
import { customize } from '../../customize';
|
|
3
|
+
import { useLocalizer } from '../../localizer';
|
|
4
|
+
|
|
5
|
+
export interface AutoReplyTextInputProps {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const AutoReplyTextInput = customize('AutoReplyTextInput', (props: AutoReplyTextInputProps) => {
|
|
10
|
+
const { name } = props;
|
|
11
|
+
const localizer = useLocalizer();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Form.Item
|
|
15
|
+
label={localizer.autoReply.text.label()}
|
|
16
|
+
name={name}
|
|
17
|
+
rules={[{ required: true, message: localizer.autoReply.text.required() }]}
|
|
18
|
+
>
|
|
19
|
+
<Input.TextArea rows={4} />
|
|
20
|
+
</Form.Item>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { AutoReplyButton } from './AutoReplyButton';
|
|
2
|
-
import { AutoReplyForm } from './AutoReplyForm';
|
|
3
|
-
import { AutoReplyPanel } from './AutoReplyPanel';
|
|
4
|
-
import { AutoReplyPeriodInput } from './AutoReplyPeriodInput';
|
|
5
|
-
import { AutoReplyTextInput } from './AutoReplyTextInput';
|
|
6
|
-
|
|
7
|
-
export * from './AutoReplyButton';
|
|
8
|
-
export * from './AutoReplyForm';
|
|
9
|
-
export * from './AutoReplyPanel';
|
|
10
|
-
export * from './AutoReplyPeriodInput';
|
|
11
|
-
export * from './AutoReplyTextInput';
|
|
12
|
-
|
|
13
|
-
export interface AutoReplyCustomizeValue {
|
|
14
|
-
AutoReplyButton?: typeof AutoReplyButton.Component | null;
|
|
15
|
-
AutoReplyForm?: typeof AutoReplyForm.Component | null;
|
|
16
|
-
AutoReplyPanel?: typeof AutoReplyPanel.Component | null;
|
|
17
|
-
AutoReplyPeriodInput?: typeof AutoReplyPeriodInput.Component | null;
|
|
18
|
-
AutoReplyTextInput?: typeof AutoReplyTextInput.Component | null;
|
|
19
|
-
}
|
|
1
|
+
import { AutoReplyButton } from './AutoReplyButton';
|
|
2
|
+
import { AutoReplyForm } from './AutoReplyForm';
|
|
3
|
+
import { AutoReplyPanel } from './AutoReplyPanel';
|
|
4
|
+
import { AutoReplyPeriodInput } from './AutoReplyPeriodInput';
|
|
5
|
+
import { AutoReplyTextInput } from './AutoReplyTextInput';
|
|
6
|
+
|
|
7
|
+
export * from './AutoReplyButton';
|
|
8
|
+
export * from './AutoReplyForm';
|
|
9
|
+
export * from './AutoReplyPanel';
|
|
10
|
+
export * from './AutoReplyPeriodInput';
|
|
11
|
+
export * from './AutoReplyTextInput';
|
|
12
|
+
|
|
13
|
+
export interface AutoReplyCustomizeValue {
|
|
14
|
+
AutoReplyButton?: typeof AutoReplyButton.Component | null;
|
|
15
|
+
AutoReplyForm?: typeof AutoReplyForm.Component | null;
|
|
16
|
+
AutoReplyPanel?: typeof AutoReplyPanel.Component | null;
|
|
17
|
+
AutoReplyPeriodInput?: typeof AutoReplyPeriodInput.Component | null;
|
|
18
|
+
AutoReplyTextInput?: typeof AutoReplyTextInput.Component | null;
|
|
19
|
+
}
|