@controleonline/ui-common 1.2.108 → 1.2.109

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.
@@ -4,19 +4,18 @@ import * as types from "@controleonline/ui-default/src/store/default/mutation_ty
4
4
  export const createWhatsappConnection = ({ commit, getters }, params = {}) => {
5
5
  commit(types.SET_ISLOADING, true);
6
6
 
7
- let options = {
7
+ const options = {
8
8
  method: "POST",
9
9
  body: params,
10
10
  };
11
11
 
12
12
  return api
13
- .fetch("/whatsapp/create-session" , options)
14
- .then((data) => {
13
+ .fetch("/whatsapp/create-session", options)
14
+ .then(data => {
15
15
  commit(types.SET_ITEM, data);
16
-
17
16
  return data;
18
17
  })
19
- .catch((e) => {
18
+ .catch(e => {
20
19
  commit(types.SET_ERROR, e.message);
21
20
  throw e;
22
21
  })
@@ -26,34 +25,37 @@ export const createWhatsappConnection = ({ commit, getters }, params = {}) => {
26
25
  };
27
26
 
28
27
  /**
29
- * Persist an official (Meta Cloud API) WhatsApp connection.
30
- * Uses connections.channel = whatsapp_official and channelConfig for credentials.
28
+ * Persist official Meta Cloud API WhatsApp connection.
29
+ * channel=whatsapp_official + channelConfig JSON (write-only on API).
31
30
  */
32
- export const saveOfficialWhatsappConnection = ({ commit, getters }, params = {}) => {
31
+ export const saveOfficialWhatsappConnection = ({ commit }, params = {}) => {
33
32
  commit(types.SET_ISLOADING, true);
34
33
 
35
34
  const body = {
36
- name: params.name || `WhatsApp Oficial ${params.phoneNumberId || ''}`.trim(),
37
- channel: 'whatsapp_official',
38
- type: params.type || null,
35
+ name: params.name || `WA Oficial ${params.phoneNumberId || ""}`.trim().slice(0, 50),
36
+ channel: "whatsapp_official",
37
+ type: params.type || "relationship",
39
38
  people: params.people,
40
39
  channelConfig: JSON.stringify({
41
40
  access_token: params.accessToken,
42
41
  phone_number_id: params.phoneNumberId,
43
- api_version: params.apiVersion || 'v22.0',
42
+ api_version: params.apiVersion || "v22.0",
44
43
  }),
45
44
  };
46
45
 
46
+ if (params.status) {
47
+ body.status = params.status;
48
+ }
47
49
  if (params.phone) {
48
50
  body.phone = params.phone;
49
51
  }
50
52
 
51
53
  const options = {
52
- method: params.id ? 'PUT' : 'POST',
54
+ method: params.id ? "PUT" : "POST",
53
55
  body,
54
56
  };
55
57
 
56
- const endpoint = params.id ? `/connections/${params.id}` : '/connections';
58
+ const endpoint = params.id ? `/connections/${params.id}` : "/connections";
57
59
 
58
60
  return api
59
61
  .fetch(endpoint, options)
@@ -1,101 +1,105 @@
1
- import * as actions from "@controleonline/ui-default/src/store/default/actions";
2
- import * as getters from "@controleonline/ui-default/src/store/default/getters";
3
- import mutations from "@controleonline/ui-default/src/store/default/mutations";
4
- import * as customActions from "./customActions";
5
-
6
- export default {
7
- namespaced: true,
8
- state: {
9
- item: {},
10
- items: [],
11
- resourceEndpoint: "connections",
12
- isLoading: false,
13
- reload: false,
14
- error: "",
15
- totalItems: 0,
16
- summary: {},
17
- messages: [],
18
- message: {},
19
- filters: {},
20
- columns: [
21
- {
22
- editable: false,
23
- isIdentity: true,
24
- sortable: true,
25
- name: "id",
26
- align: "left",
27
- label: "id",
28
- sum: false,
29
- format: function (value) {
30
- return "#" + value;
31
- },
32
- },
33
- {
34
- externalFilter: false,
35
- sortable: true,
36
- name: "name",
37
- align: "left",
38
- label: "name",
39
- format: function (value) {
40
- return value;
41
- },
42
- },
43
- {
44
- externalFilter: false,
45
- sortable: true,
46
- editable: false,
47
- name: "phone",
48
- align: "left",
49
- label: "phone",
50
- format: function (value, row, column) {
51
- const phone = String(value.phone);
52
- const lastFour = phone.slice(-4);
53
- const firstPart = phone.slice(0, -4);
54
- return `(${value?.ddd}) ${firstPart}-${lastFour}`;
55
- },
56
- },
57
-
1
+ import * as actions from "@controleonline/ui-default/src/store/default/actions";
2
+ import * as getters from "@controleonline/ui-default/src/store/default/getters";
3
+ import mutations from "@controleonline/ui-default/src/store/default/mutations";
4
+ import * as customActions from "./customActions";
5
+
6
+ export default {
7
+ namespaced: true,
8
+ state: {
9
+ item: {},
10
+ items: [],
11
+ resourceEndpoint: "connections",
12
+ isLoading: false,
13
+ reload: false,
14
+ error: "",
15
+ totalItems: 0,
16
+ summary: {},
17
+ messages: [],
18
+ message: {},
19
+ filters: {},
20
+ columns: [
21
+ {
22
+ editable: false,
23
+ isIdentity: true,
24
+ sortable: true,
25
+ name: "id",
26
+ align: "left",
27
+ label: "id",
28
+ sum: false,
29
+ format: function (value) {
30
+ return "#" + value;
31
+ },
32
+ },
33
+ {
34
+ externalFilter: false,
35
+ sortable: true,
36
+ name: "name",
37
+ align: "left",
38
+ label: "name",
39
+ format: function (value) {
40
+ return value;
41
+ },
42
+ },
43
+ {
44
+ externalFilter: false,
45
+ sortable: true,
46
+ editable: false,
47
+ name: "phone",
48
+ align: "left",
49
+ label: "phone",
50
+ format: function (value, row, column) {
51
+ const phone = String(value.phone);
52
+ const lastFour = phone.slice(-4);
53
+ const firstPart = phone.slice(0, -4);
54
+ return `(${value?.ddd}) ${firstPart}-${lastFour}`;
55
+ },
56
+ },
57
+
58
58
  {
59
59
  externalFilter: false,
60
60
  sortable: true,
61
61
  name: "type",
62
62
  align: "left",
63
63
  label: "type",
64
- list: [
65
- {
66
- value: "crm",
67
- label: "CRM",
68
- },
69
- {
70
- value: "support",
71
- label: "Suporte",
72
- },
73
- {
74
- value: null,
75
- label: "Nenhum",
76
- },
77
- ],
78
- format: function (value) {
79
- return value;
80
- },
81
- },
82
-
64
+ list: [
65
+ {
66
+ value: "crm",
67
+ label: "CRM",
68
+ },
69
+ {
70
+ value: "support",
71
+ label: "Suporte",
72
+ },
73
+ {
74
+ value: null,
75
+ label: "Nenhum",
76
+ },
77
+ ],
78
+ format: function (value) {
79
+ return value;
80
+ },
81
+ },
82
+
83
83
  {
84
84
  sortable: true,
85
85
  editable: false,
86
86
  name: "channel",
87
87
  align: "left",
88
88
  label: "channel",
89
- list: [
90
- {
91
- value: "whatsapp",
92
- label: "Whatsapp",
93
- },
94
- ],
95
- format: function (value) {
96
- return value;
97
- },
98
- },
89
+ list: [
90
+ {
91
+ value: "whatsapp",
92
+ label: "WhatsApp",
93
+ },
94
+ {
95
+ value: "whatsapp_official",
96
+ label: "WhatsApp Oficial",
97
+ },
98
+ ],
99
+ format: function (value) {
100
+ return value;
101
+ },
102
+ },
99
103
  {
100
104
  editable: false,
101
105
  externalFilter: false,
@@ -103,22 +107,22 @@ export default {
103
107
  name: "status",
104
108
  align: "left",
105
109
  label: "status",
106
- list: "status/getItems",
107
- searchParam: "status",
108
- format: function (value) {
109
- return value?.status;
110
- },
111
- saveFormat: function (value) {
112
- return value ? "/statuses/" + (value.value || value) : null;
113
- },
114
- },
115
- {
116
- name: "connection",
117
- },
118
- ],
119
- print: [],
120
- },
121
- actions: { ...actions, ...customActions },
122
- getters,
123
- mutations,
124
- };
110
+ list: "status/getItems",
111
+ searchParam: "status",
112
+ format: function (value) {
113
+ return value?.status;
114
+ },
115
+ saveFormat: function (value) {
116
+ return value ? "/statuses/" + (value.value || value) : null;
117
+ },
118
+ },
119
+ {
120
+ name: "connection",
121
+ },
122
+ ],
123
+ print: [],
124
+ },
125
+ actions: { ...actions, ...customActions },
126
+ getters,
127
+ mutations,
128
+ };