@scopieflows/app-copper 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +7 -0
  2. package/package.json +28 -0
  3. package/src/i18n/de.json +285 -0
  4. package/src/i18n/es.json +285 -0
  5. package/src/i18n/fr.json +285 -0
  6. package/src/i18n/ja.json +285 -0
  7. package/src/i18n/nl.json +285 -0
  8. package/src/i18n/pt.json +285 -0
  9. package/src/i18n/translation.json +285 -0
  10. package/src/i18n/zh.json +285 -0
  11. package/src/index.d.ts +4 -0
  12. package/src/index.js +94 -0
  13. package/src/index.js.map +1 -0
  14. package/src/lib/actions/convert-lead.d.ts +23 -0
  15. package/src/lib/actions/convert-lead.js +52 -0
  16. package/src/lib/actions/convert-lead.js.map +1 -0
  17. package/src/lib/actions/create-activity.d.ts +15 -0
  18. package/src/lib/actions/create-activity.js +108 -0
  19. package/src/lib/actions/create-activity.js.map +1 -0
  20. package/src/lib/actions/create-company.d.ts +21 -0
  21. package/src/lib/actions/create-company.js +103 -0
  22. package/src/lib/actions/create-company.js.map +1 -0
  23. package/src/lib/actions/create-lead.d.ts +14 -0
  24. package/src/lib/actions/create-lead.js +101 -0
  25. package/src/lib/actions/create-lead.js.map +1 -0
  26. package/src/lib/actions/create-opportunity.d.ts +24 -0
  27. package/src/lib/actions/create-opportunity.js +69 -0
  28. package/src/lib/actions/create-opportunity.js.map +1 -0
  29. package/src/lib/actions/create-person.d.ts +13 -0
  30. package/src/lib/actions/create-person.js +122 -0
  31. package/src/lib/actions/create-person.js.map +1 -0
  32. package/src/lib/actions/create-project.d.ts +7 -0
  33. package/src/lib/actions/create-project.js +35 -0
  34. package/src/lib/actions/create-project.js.map +1 -0
  35. package/src/lib/actions/create-task.d.ts +27 -0
  36. package/src/lib/actions/create-task.js +142 -0
  37. package/src/lib/actions/create-task.js.map +1 -0
  38. package/src/lib/actions/search-for-a-company.d.ts +40 -0
  39. package/src/lib/actions/search-for-a-company.js +258 -0
  40. package/src/lib/actions/search-for-a-company.js.map +1 -0
  41. package/src/lib/actions/search-for-a-lead.d.ts +52 -0
  42. package/src/lib/actions/search-for-a-lead.js +274 -0
  43. package/src/lib/actions/search-for-a-lead.js.map +1 -0
  44. package/src/lib/actions/search-for-a-person.d.ts +54 -0
  45. package/src/lib/actions/search-for-a-person.js +235 -0
  46. package/src/lib/actions/search-for-a-person.js.map +1 -0
  47. package/src/lib/actions/search-for-a-project.d.ts +24 -0
  48. package/src/lib/actions/search-for-a-project.js +165 -0
  49. package/src/lib/actions/search-for-a-project.js.map +1 -0
  50. package/src/lib/actions/search-for-an-activity.d.ts +22 -0
  51. package/src/lib/actions/search-for-an-activity.js +130 -0
  52. package/src/lib/actions/search-for-an-activity.js.map +1 -0
  53. package/src/lib/actions/search-for-an-opportunity.d.ts +74 -0
  54. package/src/lib/actions/search-for-an-opportunity.js +334 -0
  55. package/src/lib/actions/search-for-an-opportunity.js.map +1 -0
  56. package/src/lib/actions/update-company.d.ts +23 -0
  57. package/src/lib/actions/update-company.js +135 -0
  58. package/src/lib/actions/update-company.js.map +1 -0
  59. package/src/lib/actions/update-lead.d.ts +13 -0
  60. package/src/lib/actions/update-lead.js +136 -0
  61. package/src/lib/actions/update-lead.js.map +1 -0
  62. package/src/lib/actions/update-opportunity.d.ts +34 -0
  63. package/src/lib/actions/update-opportunity.js +89 -0
  64. package/src/lib/actions/update-opportunity.js.map +1 -0
  65. package/src/lib/actions/update-person.d.ts +13 -0
  66. package/src/lib/actions/update-person.js +155 -0
  67. package/src/lib/actions/update-person.js.map +1 -0
  68. package/src/lib/actions/update-project.d.ts +16 -0
  69. package/src/lib/actions/update-project.js +56 -0
  70. package/src/lib/actions/update-project.js.map +1 -0
  71. package/src/lib/common/constants.d.ts +35 -0
  72. package/src/lib/common/constants.js +54 -0
  73. package/src/lib/common/constants.js.map +1 -0
  74. package/src/lib/common/props.d.ts +168 -0
  75. package/src/lib/common/props.js +679 -0
  76. package/src/lib/common/props.js.map +1 -0
  77. package/src/lib/common/requests.d.ts +33 -0
  78. package/src/lib/common/requests.js +320 -0
  79. package/src/lib/common/requests.js.map +1 -0
  80. package/src/lib/triggers/new-activity.d.ts +14 -0
  81. package/src/lib/triggers/new-activity.js +74 -0
  82. package/src/lib/triggers/new-activity.js.map +1 -0
  83. package/src/lib/triggers/new-lead.d.ts +14 -0
  84. package/src/lib/triggers/new-lead.js +45 -0
  85. package/src/lib/triggers/new-lead.js.map +1 -0
  86. package/src/lib/triggers/new-person.d.ts +14 -0
  87. package/src/lib/triggers/new-person.js +45 -0
  88. package/src/lib/triggers/new-person.js.map +1 -0
  89. package/src/lib/triggers/new-task.d.ts +14 -0
  90. package/src/lib/triggers/new-task.js +45 -0
  91. package/src/lib/triggers/new-task.js.map +1 -0
  92. package/src/lib/triggers/updated-lead-status.d.ts +14 -0
  93. package/src/lib/triggers/updated-lead-status.js +66 -0
  94. package/src/lib/triggers/updated-lead-status.js.map +1 -0
  95. package/src/lib/triggers/updated-lead.d.ts +14 -0
  96. package/src/lib/triggers/updated-lead.js +45 -0
  97. package/src/lib/triggers/updated-lead.js.map +1 -0
  98. package/src/lib/triggers/updated-opportunity-stage.d.ts +14 -0
  99. package/src/lib/triggers/updated-opportunity-stage.js +73 -0
  100. package/src/lib/triggers/updated-opportunity-stage.js.map +1 -0
  101. package/src/lib/triggers/updated-opportunity-status.d.ts +14 -0
  102. package/src/lib/triggers/updated-opportunity-status.js +66 -0
  103. package/src/lib/triggers/updated-opportunity-status.js.map +1 -0
  104. package/src/lib/triggers/updated-opportunity.d.ts +14 -0
  105. package/src/lib/triggers/updated-opportunity.js +45 -0
  106. package/src/lib/triggers/updated-opportunity.js.map +1 -0
  107. package/src/lib/triggers/updated-project.d.ts +14 -0
  108. package/src/lib/triggers/updated-project.js +45 -0
  109. package/src/lib/triggers/updated-project.js.map +1 -0
  110. package/src/lib/triggers/updated-task.d.ts +14 -0
  111. package/src/lib/triggers/updated-task.js +45 -0
  112. package/src/lib/triggers/updated-task.js.map +1 -0
@@ -0,0 +1,679 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MultiLossReasonsDropdown = exports.MultiCustomerSourceDropdown = exports.MultiLeadStatusDropdown = exports.MultiContactTypesDropdown = exports.MultiActivityTypesDropdown = exports.ActivityTypesDropdown = exports.projectsDropdown = exports.multiPipelinesDropdown = exports.pipelinesDropdown = exports.multiOpportunityDropdown = exports.opportunityDropdown = exports.multiUsersDropdown = exports.usersDropdown = exports.multiPrimaryContactsDropdown = exports.primaryContactsDropdown = exports.multiCompanyDropdown = exports.companyDropdown = exports.leadDropdown = exports.peopleDropdown = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@scopieflows/pieces-framework");
6
+ const requests_1 = require("./requests");
7
+ const constants_1 = require("./constants");
8
+ const peopleDropdown = (refreshers) => pieces_framework_1.Property.Dropdown({
9
+ displayName: 'Person',
10
+ description: 'select a person',
11
+ required: true,
12
+ refreshers,
13
+ auth: constants_1.CopperAuth,
14
+ options(_a) {
15
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
16
+ if (!auth) {
17
+ return {
18
+ disabled: true,
19
+ placeholder: 'Connect your Copper account first',
20
+ options: [],
21
+ };
22
+ }
23
+ try {
24
+ const people = yield requests_1.CopperApiService.fetchPeople(auth);
25
+ return {
26
+ options: people.map((person) => ({
27
+ label: person.name,
28
+ value: JSON.stringify(person),
29
+ })),
30
+ };
31
+ }
32
+ catch (e) {
33
+ console.error('Failed to fetch campaigns', e);
34
+ return {
35
+ options: [],
36
+ placeholder: 'Unable to load campaigns',
37
+ };
38
+ }
39
+ });
40
+ },
41
+ });
42
+ exports.peopleDropdown = peopleDropdown;
43
+ const leadDropdown = (refreshers) => pieces_framework_1.Property.Dropdown({
44
+ auth: constants_1.CopperAuth,
45
+ displayName: 'Lead',
46
+ description: 'select a Lead',
47
+ required: true,
48
+ refreshers,
49
+ options(_a) {
50
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
51
+ if (!auth) {
52
+ return {
53
+ disabled: true,
54
+ placeholder: 'Connect your Copper account first',
55
+ options: [],
56
+ };
57
+ }
58
+ try {
59
+ const leads = yield requests_1.CopperApiService.fetchLeads(auth);
60
+ return {
61
+ options: leads.map((lead) => ({
62
+ label: lead.name,
63
+ value: JSON.stringify(lead),
64
+ })),
65
+ };
66
+ }
67
+ catch (e) {
68
+ console.error('Failed to fetch leads', e);
69
+ return {
70
+ options: [],
71
+ placeholder: 'Unable to load leads',
72
+ };
73
+ }
74
+ });
75
+ },
76
+ });
77
+ exports.leadDropdown = leadDropdown;
78
+ const companyDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
79
+ auth: constants_1.CopperAuth,
80
+ displayName: 'Company',
81
+ description: 'select a Company',
82
+ required,
83
+ refreshers,
84
+ options(_a) {
85
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
86
+ if (!auth) {
87
+ return {
88
+ disabled: true,
89
+ placeholder: 'Connect your Copper account first',
90
+ options: [],
91
+ };
92
+ }
93
+ try {
94
+ const companies = yield requests_1.CopperApiService.fetchCompanies(auth);
95
+ return {
96
+ options: companies.map((company) => ({
97
+ label: company.name,
98
+ value: JSON.stringify(company),
99
+ })),
100
+ };
101
+ }
102
+ catch (e) {
103
+ console.error('Failed to fetch companies', e);
104
+ return {
105
+ options: [],
106
+ placeholder: 'Unable to load companies',
107
+ };
108
+ }
109
+ });
110
+ },
111
+ });
112
+ exports.companyDropdown = companyDropdown;
113
+ const multiCompanyDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.MultiSelectDropdown({
114
+ auth: constants_1.CopperAuth,
115
+ displayName: 'Company',
116
+ description: 'select Companies',
117
+ required,
118
+ refreshers,
119
+ options(_a) {
120
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
121
+ if (!auth) {
122
+ return {
123
+ disabled: true,
124
+ placeholder: 'Connect your Copper account first',
125
+ options: [],
126
+ };
127
+ }
128
+ try {
129
+ const companies = yield requests_1.CopperApiService.fetchCompanies(auth);
130
+ return {
131
+ options: companies.map((company) => ({
132
+ label: company.name,
133
+ value: company.id,
134
+ })),
135
+ };
136
+ }
137
+ catch (e) {
138
+ console.error('Failed to fetch companies', e);
139
+ return {
140
+ options: [],
141
+ placeholder: 'Unable to load companies',
142
+ };
143
+ }
144
+ });
145
+ },
146
+ });
147
+ exports.multiCompanyDropdown = multiCompanyDropdown;
148
+ const primaryContactsDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
149
+ auth: constants_1.CopperAuth,
150
+ displayName: 'Primary Contact',
151
+ description: 'select a primary contact',
152
+ required,
153
+ refreshers,
154
+ options(_a) {
155
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
156
+ if (!auth) {
157
+ return {
158
+ disabled: true,
159
+ placeholder: 'Connect your Copper account first',
160
+ options: [],
161
+ };
162
+ }
163
+ try {
164
+ const primaryContacts = yield requests_1.CopperApiService.fetchPeople(auth);
165
+ return {
166
+ options: primaryContacts.map((contact) => ({
167
+ label: contact.name,
168
+ value: contact.id,
169
+ })),
170
+ };
171
+ }
172
+ catch (e) {
173
+ console.error('Failed to fetch opportunities', e);
174
+ return {
175
+ options: [],
176
+ placeholder: 'Unable to load opportunities',
177
+ };
178
+ }
179
+ });
180
+ },
181
+ });
182
+ exports.primaryContactsDropdown = primaryContactsDropdown;
183
+ const multiPrimaryContactsDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.MultiSelectDropdown({
184
+ auth: constants_1.CopperAuth,
185
+ displayName: 'Primary Contacts',
186
+ description: 'select primary contacts',
187
+ required,
188
+ refreshers,
189
+ options(_a) {
190
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
191
+ if (!auth) {
192
+ return {
193
+ disabled: true,
194
+ placeholder: 'Connect your Copper account first',
195
+ options: [],
196
+ };
197
+ }
198
+ try {
199
+ const primaryContacts = yield requests_1.CopperApiService.fetchPeople(auth);
200
+ return {
201
+ options: primaryContacts.map((contact) => ({
202
+ label: contact.name,
203
+ value: contact.id,
204
+ })),
205
+ };
206
+ }
207
+ catch (e) {
208
+ console.error('Failed to fetch opportunities', e);
209
+ return {
210
+ options: [],
211
+ placeholder: 'Unable to load opportunities',
212
+ };
213
+ }
214
+ });
215
+ },
216
+ });
217
+ exports.multiPrimaryContactsDropdown = multiPrimaryContactsDropdown;
218
+ const usersDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
219
+ auth: constants_1.CopperAuth,
220
+ displayName: 'Assignee',
221
+ description: 'select a user to assign to',
222
+ required,
223
+ refreshers,
224
+ options(_a) {
225
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
226
+ if (!auth) {
227
+ return {
228
+ disabled: true,
229
+ placeholder: 'Connect your Copper account first',
230
+ options: [],
231
+ };
232
+ }
233
+ try {
234
+ const users = yield requests_1.CopperApiService.fetchUsers(auth);
235
+ return {
236
+ options: users.map((user) => ({
237
+ label: user.name,
238
+ value: user.id,
239
+ })),
240
+ };
241
+ }
242
+ catch (e) {
243
+ console.error('Failed to fetch opportunities', e);
244
+ return {
245
+ options: [],
246
+ placeholder: 'Unable to load opportunities',
247
+ };
248
+ }
249
+ });
250
+ },
251
+ });
252
+ exports.usersDropdown = usersDropdown;
253
+ const multiUsersDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.MultiSelectDropdown({
254
+ auth: constants_1.CopperAuth,
255
+ displayName: 'Assignee',
256
+ description: 'select assignees',
257
+ required,
258
+ refreshers,
259
+ options(_a) {
260
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
261
+ if (!auth) {
262
+ return {
263
+ disabled: true,
264
+ placeholder: 'Connect your Copper account first',
265
+ options: [],
266
+ };
267
+ }
268
+ try {
269
+ const users = yield requests_1.CopperApiService.fetchUsers(auth);
270
+ return {
271
+ options: users.map((user) => ({
272
+ label: user.name,
273
+ value: user.id,
274
+ })),
275
+ };
276
+ }
277
+ catch (e) {
278
+ console.error('Failed to fetch opportunities', e);
279
+ return {
280
+ options: [],
281
+ placeholder: 'Unable to load opportunities',
282
+ };
283
+ }
284
+ });
285
+ },
286
+ });
287
+ exports.multiUsersDropdown = multiUsersDropdown;
288
+ const opportunityDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
289
+ auth: constants_1.CopperAuth,
290
+ displayName: 'Opportunity',
291
+ description: 'select an Opportunity',
292
+ required,
293
+ refreshers,
294
+ options(_a) {
295
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
296
+ if (!auth) {
297
+ return {
298
+ disabled: true,
299
+ placeholder: 'Connect your Copper account first',
300
+ options: [],
301
+ };
302
+ }
303
+ try {
304
+ const opportunities = yield requests_1.CopperApiService.fetchOpportunities(auth);
305
+ return {
306
+ options: opportunities.map((opportunity) => ({
307
+ label: opportunity.name,
308
+ value: JSON.stringify(opportunity),
309
+ })),
310
+ };
311
+ }
312
+ catch (e) {
313
+ console.error('Failed to fetch opportunities', e);
314
+ return {
315
+ options: [],
316
+ placeholder: 'Unable to load opportunities',
317
+ };
318
+ }
319
+ });
320
+ },
321
+ });
322
+ exports.opportunityDropdown = opportunityDropdown;
323
+ const multiOpportunityDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.MultiSelectDropdown({
324
+ auth: constants_1.CopperAuth,
325
+ displayName: 'Opportunity',
326
+ description: 'select Opportunities',
327
+ required,
328
+ refreshers,
329
+ options(_a) {
330
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
331
+ if (!auth) {
332
+ return {
333
+ disabled: true,
334
+ placeholder: 'Connect your Copper account first',
335
+ options: [],
336
+ };
337
+ }
338
+ try {
339
+ const opportunities = yield requests_1.CopperApiService.fetchOpportunities(auth);
340
+ return {
341
+ options: opportunities.map((opportunity) => ({
342
+ label: opportunity.name,
343
+ value: opportunity.id,
344
+ })),
345
+ };
346
+ }
347
+ catch (e) {
348
+ console.error('Failed to fetch opportunities', e);
349
+ return {
350
+ options: [],
351
+ placeholder: 'Unable to load opportunities',
352
+ };
353
+ }
354
+ });
355
+ },
356
+ });
357
+ exports.multiOpportunityDropdown = multiOpportunityDropdown;
358
+ const pipelinesDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
359
+ auth: constants_1.CopperAuth,
360
+ displayName: 'Pipeline',
361
+ description: 'select a Pipeline',
362
+ required,
363
+ refreshers,
364
+ options(_a) {
365
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
366
+ if (!auth) {
367
+ return {
368
+ disabled: true,
369
+ placeholder: 'Connect your Copper account first',
370
+ options: [],
371
+ };
372
+ }
373
+ try {
374
+ const pipelines = yield requests_1.CopperApiService.fetchPipelines(auth);
375
+ return {
376
+ options: pipelines.map((pipeline) => ({
377
+ label: pipeline.name,
378
+ value: JSON.stringify(pipeline),
379
+ })),
380
+ };
381
+ }
382
+ catch (e) {
383
+ console.error('Failed to fetch pipelines', e);
384
+ return {
385
+ options: [],
386
+ placeholder: 'Unable to load pipelines',
387
+ };
388
+ }
389
+ });
390
+ },
391
+ });
392
+ exports.pipelinesDropdown = pipelinesDropdown;
393
+ const multiPipelinesDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.MultiSelectDropdown({
394
+ auth: constants_1.CopperAuth,
395
+ displayName: 'Pipeline',
396
+ description: 'select a Pipeline',
397
+ required,
398
+ refreshers,
399
+ options(_a) {
400
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
401
+ if (!auth) {
402
+ return {
403
+ disabled: true,
404
+ placeholder: 'Connect your Copper account first',
405
+ options: [],
406
+ };
407
+ }
408
+ try {
409
+ const pipelines = yield requests_1.CopperApiService.fetchPipelines(auth);
410
+ return {
411
+ options: pipelines.map((pipeline) => ({
412
+ label: pipeline.name,
413
+ value: JSON.stringify(pipeline),
414
+ })),
415
+ };
416
+ }
417
+ catch (e) {
418
+ console.error('Failed to fetch pipelines', e);
419
+ return {
420
+ options: [],
421
+ placeholder: 'Unable to load pipelines',
422
+ };
423
+ }
424
+ });
425
+ },
426
+ });
427
+ exports.multiPipelinesDropdown = multiPipelinesDropdown;
428
+ const projectsDropdown = ({ refreshers, required = false, }) => pieces_framework_1.Property.Dropdown({
429
+ auth: constants_1.CopperAuth,
430
+ displayName: 'Project',
431
+ description: 'select a Project',
432
+ required,
433
+ refreshers,
434
+ options(_a) {
435
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
436
+ if (!auth) {
437
+ return {
438
+ disabled: true,
439
+ placeholder: 'Connect your Copper account first',
440
+ options: [],
441
+ };
442
+ }
443
+ try {
444
+ const projects = yield requests_1.CopperApiService.fetchProjects(auth);
445
+ return {
446
+ options: projects.map((project) => ({
447
+ label: project.name,
448
+ value: JSON.stringify(project),
449
+ })),
450
+ };
451
+ }
452
+ catch (e) {
453
+ console.error('Failed to fetch projects', e);
454
+ return {
455
+ options: [],
456
+ placeholder: 'Unable to load projects',
457
+ };
458
+ }
459
+ });
460
+ },
461
+ });
462
+ exports.projectsDropdown = projectsDropdown;
463
+ const ActivityTypesDropdown = (entity) => pieces_framework_1.Property.Dropdown({
464
+ auth: constants_1.CopperAuth,
465
+ displayName: 'Activity Type',
466
+ description: 'Select activity Type',
467
+ required: true,
468
+ refreshers: ['auth'],
469
+ options(_a) {
470
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
471
+ if (!auth) {
472
+ return {
473
+ disabled: true,
474
+ placeholder: 'Connect your Copper account first',
475
+ options: [],
476
+ };
477
+ }
478
+ try {
479
+ const response = yield requests_1.CopperApiService.fetchActivityTypes(auth);
480
+ const items = entity && response[entity]
481
+ ? response[entity]
482
+ : [...response.user, ...response.system];
483
+ return {
484
+ options: items.map((item) => ({
485
+ label: item.name,
486
+ value: JSON.stringify(item),
487
+ })),
488
+ };
489
+ }
490
+ catch (e) {
491
+ console.error('Failed to fetch activity types', e);
492
+ return {
493
+ options: [],
494
+ placeholder: 'Unable to load activity types',
495
+ };
496
+ }
497
+ });
498
+ },
499
+ });
500
+ exports.ActivityTypesDropdown = ActivityTypesDropdown;
501
+ const MultiActivityTypesDropdown = ({ entity, required = false }) => pieces_framework_1.Property.MultiSelectDropdown({
502
+ auth: constants_1.CopperAuth,
503
+ displayName: 'Activity Type',
504
+ description: 'Select activity Type',
505
+ required,
506
+ refreshers: ['auth'],
507
+ options(_a) {
508
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
509
+ if (!auth) {
510
+ return {
511
+ disabled: true,
512
+ placeholder: 'Connect your Copper account first',
513
+ options: [],
514
+ };
515
+ }
516
+ try {
517
+ const response = yield requests_1.CopperApiService.fetchActivityTypes(auth);
518
+ const items = entity && response[entity]
519
+ ? response[entity]
520
+ : [...response.user, ...response.system];
521
+ return {
522
+ options: items.map((item) => ({
523
+ label: item.name,
524
+ value: JSON.stringify(item),
525
+ })),
526
+ };
527
+ }
528
+ catch (e) {
529
+ console.error('Failed to fetch activity types', e);
530
+ return {
531
+ options: [],
532
+ placeholder: 'Unable to load activity types',
533
+ };
534
+ }
535
+ });
536
+ },
537
+ });
538
+ exports.MultiActivityTypesDropdown = MultiActivityTypesDropdown;
539
+ const MultiContactTypesDropdown = ({ required = false }) => pieces_framework_1.Property.MultiSelectDropdown({
540
+ auth: constants_1.CopperAuth,
541
+ displayName: 'Contact Type',
542
+ description: 'Select contact Type',
543
+ required,
544
+ refreshers: ['auth'],
545
+ options(_a) {
546
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
547
+ if (!auth) {
548
+ return {
549
+ disabled: true,
550
+ placeholder: 'Connect your Copper account first',
551
+ options: [],
552
+ };
553
+ }
554
+ try {
555
+ const response = yield requests_1.CopperApiService.fetchContactTypes(auth);
556
+ return {
557
+ options: response.map((item) => ({
558
+ label: item.name,
559
+ value: item.id,
560
+ })),
561
+ };
562
+ }
563
+ catch (e) {
564
+ console.error('Failed to fetch contact types', e);
565
+ return {
566
+ options: [],
567
+ placeholder: 'Unable to load contact types',
568
+ };
569
+ }
570
+ });
571
+ },
572
+ });
573
+ exports.MultiContactTypesDropdown = MultiContactTypesDropdown;
574
+ const MultiLeadStatusDropdown = ({ required = false }) => pieces_framework_1.Property.MultiSelectDropdown({
575
+ auth: constants_1.CopperAuth,
576
+ displayName: 'Lead Status',
577
+ description: 'Select lead status',
578
+ required,
579
+ refreshers: ['auth'],
580
+ options(_a) {
581
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
582
+ if (!auth) {
583
+ return {
584
+ disabled: true,
585
+ placeholder: 'Connect your Copper account first',
586
+ options: [],
587
+ };
588
+ }
589
+ try {
590
+ const response = yield requests_1.CopperApiService.fetchLeadStatuses(auth);
591
+ return {
592
+ options: response.map((item) => ({
593
+ label: item.name,
594
+ value: item.id,
595
+ })),
596
+ };
597
+ }
598
+ catch (e) {
599
+ console.error('Failed to fetch lead statuses', e);
600
+ return {
601
+ options: [],
602
+ placeholder: 'Unable to load lead statuses',
603
+ };
604
+ }
605
+ });
606
+ },
607
+ });
608
+ exports.MultiLeadStatusDropdown = MultiLeadStatusDropdown;
609
+ const MultiCustomerSourceDropdown = ({ required = false }) => pieces_framework_1.Property.MultiSelectDropdown({
610
+ auth: constants_1.CopperAuth,
611
+ displayName: 'Customer Source',
612
+ description: 'Select customer source.',
613
+ required,
614
+ refreshers: ['auth'],
615
+ options(_a) {
616
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
617
+ if (!auth) {
618
+ return {
619
+ disabled: true,
620
+ placeholder: 'Connect your Copper account first',
621
+ options: [],
622
+ };
623
+ }
624
+ try {
625
+ const response = yield requests_1.CopperApiService.fetchCustomerSources(auth);
626
+ return {
627
+ options: response.map((item) => ({
628
+ label: item.name,
629
+ value: item.id,
630
+ })),
631
+ };
632
+ }
633
+ catch (e) {
634
+ console.error('Failed to fetch customer sources', e);
635
+ return {
636
+ options: [],
637
+ placeholder: 'Unable to load customer sources',
638
+ };
639
+ }
640
+ });
641
+ },
642
+ });
643
+ exports.MultiCustomerSourceDropdown = MultiCustomerSourceDropdown;
644
+ const MultiLossReasonsDropdown = ({ required = false }) => pieces_framework_1.Property.MultiSelectDropdown({
645
+ auth: constants_1.CopperAuth,
646
+ displayName: 'Loss Reason',
647
+ description: 'Select loss reason.',
648
+ required,
649
+ refreshers: ['auth'],
650
+ options(_a) {
651
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
652
+ if (!auth) {
653
+ return {
654
+ disabled: true,
655
+ placeholder: 'Connect your Copper account first',
656
+ options: [],
657
+ };
658
+ }
659
+ try {
660
+ const response = yield requests_1.CopperApiService.fetchLossReasons(auth);
661
+ return {
662
+ options: response.map((item) => ({
663
+ label: item.name,
664
+ value: item.id,
665
+ })),
666
+ };
667
+ }
668
+ catch (e) {
669
+ console.error('Failed to fetch loss reasons', e);
670
+ return {
671
+ options: [],
672
+ placeholder: 'Unable to load loss reasons',
673
+ };
674
+ }
675
+ });
676
+ },
677
+ });
678
+ exports.MultiLossReasonsDropdown = MultiLossReasonsDropdown;
679
+ //# sourceMappingURL=props.js.map