|
|
|
@ -22,7 +22,7 @@ export const fetchTemplates = async () => {
|
|
|
|
|
* @param {object} params { opisn }
|
|
|
|
|
*/
|
|
|
|
|
export const fetchConversationsList = async (params) => {
|
|
|
|
|
const { errcode, result: data } = await fetchJSON(`${API_HOST}/v2/getconversations`, params);
|
|
|
|
|
const { errcode, result: data } = await fetchJSON(`${API_HOST}/getconversations`, params);
|
|
|
|
|
if (errcode !== 0) return [];
|
|
|
|
|
const list = (data || []).map((ele) => ({ ...ele, customer_name: `${ele.whatsapp_name || ''}`.trim(), whatsapp_name: `${ele.whatsapp_name || ''}`.trim() }));
|
|
|
|
|
return list;
|
|
|
|
@ -74,7 +74,7 @@ export const postNewOrEditConversationItem = async (body) => {
|
|
|
|
|
Object.keys(body).forEach(function (key) {
|
|
|
|
|
formData.append(key, body[key]);
|
|
|
|
|
});
|
|
|
|
|
const { errcode, result } = await postForm(`${API_HOST}/v2/new_conversation`, formData);
|
|
|
|
|
const { errcode, result } = await postForm(`${API_HOST}/new_conversation`, formData);
|
|
|
|
|
if (errcode !== 0) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
@ -113,7 +113,7 @@ export const fetchConversationItemUnread = async (body) => {
|
|
|
|
|
* @param {object} body { conversationid, top_state }
|
|
|
|
|
*/
|
|
|
|
|
export const fetchConversationItemTop = async (body) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/set_top_conversation`, body);
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/set_top_conversation`, body);
|
|
|
|
|
return errcode !== 0 ? {} : result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -213,7 +213,7 @@ export const postAssignConversation = async (params) => {
|
|
|
|
|
* @param {object} params { opisn, }
|
|
|
|
|
*/
|
|
|
|
|
export const fetchTags = async (params) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/get_opi_tags`, params);
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/get_opi_tags`, params);
|
|
|
|
|
return errcode !== 0 ? [] : result.map(ele => ({ label: ele.tag_label, key: ele.tag_key, value: ele.tag_key, }));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -225,7 +225,7 @@ export const postConversationTags = async (body) => {
|
|
|
|
|
Object.keys(body).forEach(function (key) {
|
|
|
|
|
formData.append(key, body[key]);
|
|
|
|
|
});
|
|
|
|
|
const { errcode, result } = await postForm(`${API_HOST}/v2/set_conversation_tags_add`, formData);
|
|
|
|
|
const { errcode, result } = await postForm(`${API_HOST}/set_conversation_tags_add`, formData);
|
|
|
|
|
return errcode !== 0 ? {} : result[0];
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
@ -233,7 +233,7 @@ export const postConversationTags = async (body) => {
|
|
|
|
|
* @param {object} params { opisn, conversationid, tag_id }
|
|
|
|
|
*/
|
|
|
|
|
export const deleteConversationTags = async (params) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/v2/set_conversation_tags_del`, params);
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${API_HOST}/set_conversation_tags_del`, params);
|
|
|
|
|
return errcode !== 0 ? {} : result;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|