|
2 | 2 | * sync call log to deal
|
3 | 3 | */
|
4 | 4 |
|
5 |
| -import fetch from 'ringcentral-embeddable-extension-common/src/common/fetch' |
| 5 | +// import fetch from 'ringcentral-embeddable-extension-common/src/common/fetch' |
6 | 6 | import {
|
7 | 7 | host, notify
|
8 | 8 | } from 'ringcentral-embeddable-extension-common/src/common/helpers'
|
9 |
| -import { getSessionToken } from './common' |
| 9 | +// import { getSessionToken } from './common' |
10 | 10 | import extLinkSvg from 'ringcentral-embeddable-extension-common/src/common/link-external.svg'
|
11 | 11 | import { thirdPartyConfigs } from 'ringcentral-embeddable-extension-common/src/common/app-config'
|
12 | 12 | import { searchByPersonId } from './deals'
|
@@ -44,45 +44,44 @@ export function notifySyncSuccess ({
|
44 | 44 | notify(msg, type, 9000)
|
45 | 45 | }
|
46 | 46 |
|
47 |
| -export async function getDeals () { |
48 |
| - let token = getSessionToken() |
49 |
| - let url = `${host}/api/v1/pipelines/1/deals?limit=500&start=0&get_summary=0&totals_convert_currency=default_currency&session_token=${token}&strict_mode=true&status=open` |
50 |
| - let res = await fetch.get(url) |
51 |
| - let success = res && res.data |
52 |
| - return success || [] |
53 |
| -} |
| 47 | +// async function getDeals () { |
| 48 | +// let token = getSessionToken() |
| 49 | +// let url = `${host}/api/v1/pipelines/1/deals?limit=500&start=0&get_summary=0&totals_convert_currency=default_currency&session_token=${token}&strict_mode=true&status=open` |
| 50 | +// let res = await fetch.get(url) |
| 51 | +// let success = res && res.data |
| 52 | +// return success || [] |
| 53 | +// } |
54 | 54 |
|
55 |
| -async function syncToDeal (form, deal) { |
56 |
| - let token = getSessionToken() |
57 |
| - let url = `${host}/api/v1/activities?session_token=${token}&strict_mode=true` |
58 |
| - let data = { |
59 |
| - ...form, |
60 |
| - deal_id: deal.id |
61 |
| - } |
62 |
| - delete data.person_id |
63 |
| - // data.participants = [] |
64 |
| - // data.person_id = '' |
65 |
| - let res = await fetch.post(url, data) |
66 |
| - let success = res && res.data |
67 |
| - if (success) { |
68 |
| - notifySyncSuccess({ id: form.person_id, logType: form.subject }) |
69 |
| - } else { |
70 |
| - notify('call log sync to deals failed', 'warn') |
71 |
| - console.log('call log sync to deals failed') |
72 |
| - } |
73 |
| -} |
| 55 | +// async function syncToDeal (form, deal) { |
| 56 | +// let token = getSessionToken() |
| 57 | +// let url = `${host}/api/v1/activities?session_token=${token}&strict_mode=true` |
| 58 | +// let data = { |
| 59 | +// ...form, |
| 60 | +// deal_id: deal.id |
| 61 | +// } |
| 62 | +// delete data.person_id |
| 63 | +// // data.participants = [] |
| 64 | +// // data.person_id = '' |
| 65 | +// let res = await fetch.post(url, data) |
| 66 | +// let success = res && res.data |
| 67 | +// if (success) { |
| 68 | +// notifySyncSuccess({ id: form.person_id, logType: form.subject }) |
| 69 | +// } else { |
| 70 | +// notify('call log sync to deals failed', 'warn') |
| 71 | +// console.log('call log sync to deals failed') |
| 72 | +// } |
| 73 | +// } |
74 | 74 |
|
75 |
| -export async function syncToDeals (form) { |
76 |
| - let deals = await searchByPersonId(form.person_id) |
77 |
| - for (let deal of deals) { |
78 |
| - await syncToDeal(form, deal) |
79 |
| - } |
80 |
| - return deals.length |
81 |
| -} |
| 75 | +// async function syncToDeals (form) { |
| 76 | +// let deals = await searchByPersonId(form.person_id) |
| 77 | +// for (let deal of deals) { |
| 78 | +// await syncToDeal(form, deal) |
| 79 | +// } |
| 80 | +// return deals.length |
| 81 | +// } |
82 | 82 |
|
83 |
| -export async function getDealId (form) { |
84 |
| - let deals = await searchByPersonId(form.person_id) |
| 83 | +export async function getDealId (contact) { |
| 84 | + let deals = await searchByPersonId(contact) |
85 | 85 | return deals
|
86 |
| - .filter(d => d && d.person_id && d.person_id.toString() === form.person_id.toString()) |
87 | 86 | .map(d => d.id)[0]
|
88 | 87 | }
|
0 commit comments