From e0bdecada4e87c103b783d717f73e2159fb60268 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 31 Aug 2023 13:12:37 +0530 Subject: [PATCH] fix: show calls in activities tab --- frontend/src/components/Activities.vue | 91 +++++++++++++++++++++++++- frontend/src/pages/CallLog.vue | 4 +- frontend/src/pages/Deal.vue | 18 ++++- frontend/src/pages/Lead.vue | 18 ++++- 4 files changed, 121 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Activities.vue b/frontend/src/components/Activities.vue index db2119787..35ae48146 100644 --- a/frontend/src/components/Activities.vue +++ b/frontend/src/components/Activities.vue @@ -91,9 +91,9 @@
- {{ timeAgo(call.modified) }} + {{ timeAgo(call.creation) }}
@@ -208,6 +208,89 @@
+
+
+
+ {{ activity.type == 'Incoming' ? 'Inbound' : 'Outbound' }} call +
+
+ + {{ timeAgo(activity.creation) }} + +
+
+
+
+ +
Duration
+
+ {{ activity.duration }} +
+
+
+ +
+ {{ activity.show_recording ? 'Hide recording' : 'Listen to call' }} +
+
+
+
+ +
+
+
+ +
+
+ {{ activity.caller.label }} +
+
+ {{ activity.from }} +
+
+ + +
+
+ {{ activity.receiver.label }} +
+
+ {{ activity.to }} +
+
+
+
+
- {{ timeAgo(callLog.data.modified) }} + {{ timeAgo(callLog.data.creation) }}
diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index a7744412a..ab22818a7 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -380,7 +380,7 @@ const tabs = computed(() => { { label: 'Activity', icon: ActivityIcon, - content: deal.data.activities, + content: all_activities(), activityTitle: 'Activity log', }, { @@ -411,6 +411,17 @@ const tabs = computed(() => { ] }) +function all_activities() { + if (!lead.data) return [] + if (!calls.data) return lead.data.activities + console.log(lead.data.activities[0].creation) + console.log(calls.data[0].creation) + return [ + ...lead.data.activities, + ...calls.data, + ].sort((a, b) => new Date(b.creation) - new Date(a.creation)) +} + const tabRef = ref([]) const indicator = ref(null) @@ -581,15 +592,16 @@ const calls = createListResource({ 'status', 'type', 'recording_url', - 'modified', + 'creation', 'note', ], filters: { lead: props.dealId }, - orderBy: 'modified desc', + orderBy: 'creation desc', pageLength: 999, auto: true, transform: (docs) => { docs.forEach((doc) => { + doc.activity_type = doc.type === 'Incoming' ? 'incoming_call' : 'outgoing_call' doc.duration = secondsToDuration(doc.duration) if (doc.type === 'Incoming') { doc.caller = { diff --git a/frontend/src/pages/Lead.vue b/frontend/src/pages/Lead.vue index f3ac3d655..d17b27640 100644 --- a/frontend/src/pages/Lead.vue +++ b/frontend/src/pages/Lead.vue @@ -372,7 +372,7 @@ const tabs = computed(() => { { label: 'Activity', icon: ActivityIcon, - content: lead.data.activities, + content: all_activities(), activityTitle: 'Activity log', }, { @@ -403,6 +403,17 @@ const tabs = computed(() => { ] }) +function all_activities() { + if (!lead.data) return [] + if (!calls.data) return lead.data.activities + console.log(lead.data.activities[0].creation) + console.log(calls.data[0].creation) + return [ + ...lead.data.activities, + ...calls.data, + ].sort((a, b) => new Date(b.creation) - new Date(a.creation)) +} + const tabRef = ref([]) const indicator = ref(null) @@ -614,15 +625,16 @@ const calls = createListResource({ 'status', 'type', 'recording_url', - 'modified', + 'creation', 'note', ], filters: { lead: props.leadId }, - orderBy: 'modified desc', + orderBy: 'creation desc', pageLength: 999, auto: true, transform: (docs) => { docs.forEach((doc) => { + doc.activity_type = doc.type === 'Incoming' ? 'incoming_call' : 'outgoing_call' doc.duration = secondsToDuration(doc.duration) if (doc.type === 'Incoming') { doc.caller = {