Skip to content

Commit 2495244

Browse files
committed
Sync call log only to one deal
1 parent ea8cd0f commit 2495244

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pipedrive-embeddable-ringcentral-phone-spa",
3-
"version": "1.3.9",
3+
"version": "1.3.10",
44
"description": "Add RingCentral Embeddable Voice widgets to Pipedrive",
55
"keywords": [
66
"RingCentral",

src/features/call-log-sync-to-deal.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ async function syncToDeal (form, deal) {
5959
...form,
6060
deal_id: deal.id
6161
}
62+
delete data.person_id
6263
// data.participants = []
6364
// data.person_id = ''
6465
let res = await fetch.post(url, data)
@@ -78,3 +79,10 @@ export async function syncToDeals (form) {
7879
}
7980
return deals.length
8081
}
82+
83+
export async function getDealId (form) {
84+
let deals = await searchByPersonId(form.person_id)
85+
return deals
86+
.filter(d => d.person_id.toString() === form.person_id.toString())
87+
.map(d => d.id)[0]
88+
}

src/features/call-log-sync.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
match
2121
} from 'ringcentral-embeddable-extension-common/src/common/db'
2222
import { getUserId } from './activities'
23-
import { notifySyncSuccess, syncToDeals } from './call-log-sync-to-deal'
23+
import { notifySyncSuccess, getDealId } from './call-log-sync-to-deal'
2424

2525
let {
2626
showCallLogSyncForm,
@@ -206,14 +206,15 @@ async function doSyncOne (contact, body, formData) {
206206
notification_language_id: 1,
207207
assigned_to_user_id: userId
208208
}
209-
let rr = await syncToDeals(bd)
210-
if (!rr) {
211-
let res = await fetch.post(url, bd)
212-
let success = res && res.data
213-
if (success) {
214-
notifySyncSuccess({ id, logType })
215-
} else {
216-
notify('call log sync to third party failed', 'warn')
217-
}
209+
let dealId = await getDealId(bd)
210+
if (dealId) {
211+
bd.deal_id = dealId
212+
}
213+
let res = await fetch.post(url, bd)
214+
let success = res && res.data
215+
if (success) {
216+
notifySyncSuccess({ id, logType })
217+
} else {
218+
notify('call log sync to third party failed', 'warn')
218219
}
219220
}

src/features/deals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export async function searchByPersonId (personId) {
151151
// }
152152

153153
function getDeals (token, start, userId = '') {
154-
let url = `${host}/v1/deals?limit=500&person_id=${userId}&start=${start}&get_summary=0&totals_convert_currency=default_currency&session_token=${token}&strict_mode=true&status=open`
154+
let url = `${host}/v1/deals?limit=500&person_id=${userId}&start=${start}&get_summary=0&totals_convert_currency=default_currency&session_token=${token}&strict_mode=true&status=open&sort=update_time%20ASC`
155155
return fetch.get(url)
156156
}
157157

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Ringcentral Embeddable Widgets for Pipedrive",
3-
"version": "1.3.9",
3+
"version": "1.3.10",
44
"description": "Add RingCentral Embeddable Voice widgets to Pipedrive",
55
"permissions": [
66
"http://*/",

0 commit comments

Comments
 (0)