|
|
|
|
@ -4,6 +4,7 @@ import { isEmpty, isNotEmpty, pick } from '@/utils/commons';
|
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
|
import { phoneNumberToWAID } from '@/channel/whatsappUtils';
|
|
|
|
|
import { useConversationNewItem } from '@/hooks/useConversation';
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore';
|
|
|
|
|
|
|
|
|
|
export const ConversationItemForm = ({ initialValues, onFormInstanceReady }) => {
|
|
|
|
|
const [currentConversation] = useConversationStore((state) => [state.currentConversation]);
|
|
|
|
|
@ -84,6 +85,7 @@ export const ConversationItemForm = ({ initialValues, onFormInstanceReady }) =>
|
|
|
|
|
export const ConversationItemFormModal = ({ open, onCreate, onCancel, initialValues: _initialValues, }) => {
|
|
|
|
|
const [formInstance, setFormInstance] = useState();
|
|
|
|
|
const [newItemLoading, setNewItemLoading] = useState(false);
|
|
|
|
|
const userId = useAuthStore((state) => state.loginUser.userId);
|
|
|
|
|
|
|
|
|
|
const { newConversation } = useConversationNewItem();
|
|
|
|
|
|
|
|
|
|
@ -94,6 +96,7 @@ export const ConversationItemFormModal = ({ open, onCreate, onCancel, initialVal
|
|
|
|
|
phone_number: _initialValues?.whatsapp_phone_number || _initialValues?.phone_number || '',
|
|
|
|
|
wa_id: _initialValues?.whatsapp_phone_number || _initialValues?.wa_id || '',
|
|
|
|
|
name: _initialValues?.whatsapp_name || _initialValues?.name || '',
|
|
|
|
|
remark: _initialValues?.conversation_memo || '',
|
|
|
|
|
is_new: _initialValues?.is_new ?? true,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -120,8 +123,9 @@ export const ConversationItemFormModal = ({ open, onCreate, onCancel, initialVal
|
|
|
|
|
try {
|
|
|
|
|
const values = await formInstance?.validateFields();
|
|
|
|
|
// formInstance?.resetFields();
|
|
|
|
|
|
|
|
|
|
setNewItemLoading(true);
|
|
|
|
|
if (initialValues.is_current_order !== true) newConversation(values.wa_id, values.name);
|
|
|
|
|
if (initialValues.is_current_order !== true) newConversation({...values, conversationid: _initialValues?.sn || '', opi_sn: userId});
|
|
|
|
|
if (typeof onCreate === 'function') {
|
|
|
|
|
onCreate(values);
|
|
|
|
|
}
|
|
|
|
|
|