@controleonline/ui-common 1.2.111 → 1.2.113

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 (54) hide show
  1. package/.release/rc-manifest.json +6 -6
  2. package/package.json +1 -1
  3. package/src/react/components/CategoryForm.js +539 -539
  4. package/src/react/components/DefaultProvider.native.js +2 -2
  5. package/src/react/components/DefaultProvider.web.js +2 -2
  6. package/src/react/components/integrations/IntegrationHero/index.js +1 -1
  7. package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
  8. package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
  9. package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
  10. package/src/react/pages/AiProviderConfigPage.js +304 -0
  11. package/src/react/pages/Connections.js +96 -18
  12. package/src/react/pages/Connections.styles.js +72 -72
  13. package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
  14. package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
  15. package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
  16. package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
  17. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
  18. package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
  19. package/src/react/pages/Devices.js +2 -2
  20. package/src/react/pages/Devices.styles.js +353 -353
  21. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
  22. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
  23. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
  24. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
  25. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
  26. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
  27. package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
  28. package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
  29. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
  30. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
  31. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
  32. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
  33. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
  34. package/src/react/pages/Imports.js +1 -1
  35. package/src/react/pages/Imports.styles.js +223 -223
  36. package/src/react/pages/IntegrationConfigPage.js +2 -2
  37. package/src/react/pages/Integrations.js +15 -2
  38. package/src/react/pages/Integrations.styles.js +130 -130
  39. package/src/react/pages/LinkedInIntegrationPage.js +2 -2
  40. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
  41. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
  42. package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
  43. package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
  44. package/src/react/pages/PrinterDeviceFormPage.js +2 -2
  45. package/src/react/pages/WhatsAppConnectionPage.js +364 -280
  46. package/src/react/pages/WhatsAppConnectionPage.styles.js +279 -315
  47. package/src/react/pages/WhatsAppProviderForm.js +1 -1
  48. package/src/react/pages/integrationsCatalog.js +32 -0
  49. package/src/react/pages/whatsAppConnectionHelpers.js +10 -38
  50. package/src/react/router/publicRoutes.js +0 -3
  51. package/src/react/utils/fileUrl.js +1 -1
  52. package/src/store/connections/customActions.js +14 -16
  53. package/src/store/connections/index.js +105 -109
  54. package/src/react/router/__tests__/publicRoutes.test.js +0 -12
@@ -19,29 +19,6 @@ export const formatPhoneLabel = phone => {
19
19
  return ddd ? `(${ddd}) ${firstPart}-${lastFour}` : `${firstPart}-${lastFour}`;
20
20
  };
21
21
 
22
- const resolveStatusIri = status => {
23
- if (!status) return null;
24
- if (typeof status === 'string') {
25
- if (status.startsWith('/') || status.startsWith('http')) return status;
26
- return null;
27
- }
28
- if (typeof status === 'object') {
29
- const iri = status['@id'] || status.id;
30
- if (iri == null) return null;
31
- const asString = String(iri);
32
- if (asString.startsWith('/') || asString.startsWith('http')) return asString;
33
- return `/statuses/${asString}`;
34
- }
35
- return null;
36
- };
37
-
38
- const resolveNumericId = item => {
39
- const raw = item?.id ?? item?.['@id'];
40
- if (raw == null) return null;
41
- const digits = String(raw).replace(/\D/g, '');
42
- return digits ? Number(digits) : null;
43
- };
44
-
45
22
  export const normalizeConnection = item => {
46
23
  const channel =
47
24
  item?.channel === CHANNEL_WHATSAPP_OFFICIAL
@@ -49,18 +26,15 @@ export const normalizeConnection = item => {
49
26
  : CHANNEL_WHATSAPP;
50
27
  return {
51
28
  id: item?.id || item?.['@id'] || `connection-${Math.random()}`,
52
- numericId: resolveNumericId(item),
53
29
  name: item?.name || 'Sem nome',
54
- status:
55
- (typeof item?.status === 'object'
56
- ? item?.status?.status || item?.status?.name
57
- : item?.status) || 'Pendente',
58
- statusIri: resolveStatusIri(item?.status),
30
+ status: item?.status?.status || item?.status || 'Pendente',
59
31
  type: item?.type || 'Nenhum',
60
32
  channel,
61
- provider: channel,
33
+ /** alias used by list UI */
34
+ provider: channel === CHANNEL_WHATSAPP_OFFICIAL ? CHANNEL_WHATSAPP_OFFICIAL : CHANNEL_WHATSAPP,
62
35
  phone: item?.phone || {},
63
36
  phoneLabel: formatPhoneLabel(item?.phone),
37
+ channelConfig: item?.channelConfig || item?.channel_config || null,
64
38
  };
65
39
  };
66
40
 
@@ -74,18 +48,10 @@ export const toArray = response => {
74
48
  export const formatApiError = error => {
75
49
  if (!error) return 'Nao foi possivel concluir a operacao.';
76
50
  if (typeof error === 'string') return error;
77
- const violations = error?.violations || error?.data?.violations;
78
- if (Array.isArray(violations) && violations.length) {
79
- return violations
80
- .map(v => v?.message || v?.propertyPath)
81
- .filter(Boolean)
82
- .join(' · ');
83
- }
84
51
  return (
85
52
  error?.message ||
86
53
  error?.description ||
87
54
  error?.errmsg ||
88
- error?.hydra?.description ||
89
55
  'Nao foi possivel concluir a operacao.'
90
56
  );
91
57
  };
@@ -103,3 +69,9 @@ export const buildOfficialChannelConfig = ({
103
69
  if (version) config.api_version = version;
104
70
  return config;
105
71
  };
72
+
73
+ export const maskToken = token => {
74
+ const value = String(token || '');
75
+ if (value.length <= 8) return value ? '••••••••' : '';
76
+ return `${value.slice(0, 4)}…${value.slice(-4)}`;
77
+ };
@@ -5,9 +5,6 @@ export const PUBLIC_ROUTES = new Set([
5
5
  'CreateAccount',
6
6
  'ConfirmAccountPage',
7
7
  'ResetPasswordPage',
8
- 'OauthDiscordCallbackPage',
9
- 'McpOAuthConsentPage',
10
- 'PaylistPage',
11
8
  'ShopIndex',
12
9
  'ShopFranchiseLocatorPage',
13
10
  'ShopSearchPage',
@@ -1,6 +1,6 @@
1
1
  import {env as APP_ENV} from '@env';
2
2
  import {filterApiHeaders, isTrustedApiUrl} from '../../utils/trustedApiUrl';
3
- import {buildAssetUrl} from '@controleonline/ui-layout/src/styles/branding';
3
+ import {buildAssetUrl} from '@controleonline/../../src/styles/branding';
4
4
  import {
5
5
  resolveAppDomain,
6
6
  resolveCompanyDomain,
@@ -4,18 +4,19 @@ 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
- const options = {
7
+ let 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
+
16
17
  return data;
17
18
  })
18
- .catch(e => {
19
+ .catch((e) => {
19
20
  commit(types.SET_ERROR, e.message);
20
21
  throw e;
21
22
  })
@@ -25,37 +26,34 @@ export const createWhatsappConnection = ({ commit, getters }, params = {}) => {
25
26
  };
26
27
 
27
28
  /**
28
- * Persist official Meta Cloud API WhatsApp connection.
29
- * channel=whatsapp_official + channelConfig JSON (write-only on API).
29
+ * Persist an official (Meta Cloud API) WhatsApp connection.
30
+ * Uses connections.channel = whatsapp_official and channelConfig for credentials.
30
31
  */
31
- export const saveOfficialWhatsappConnection = ({ commit }, params = {}) => {
32
+ export const saveOfficialWhatsappConnection = ({ commit, getters }, params = {}) => {
32
33
  commit(types.SET_ISLOADING, true);
33
34
 
34
35
  const body = {
35
- name: params.name || `WA Oficial ${params.phoneNumberId || ""}`.trim().slice(0, 50),
36
- channel: "whatsapp_official",
37
- type: params.type || "relationship",
36
+ name: params.name || `WhatsApp Oficial ${params.phoneNumberId || ''}`.trim(),
37
+ channel: 'whatsapp_official',
38
+ type: params.type || null,
38
39
  people: params.people,
39
40
  channelConfig: JSON.stringify({
40
41
  access_token: params.accessToken,
41
42
  phone_number_id: params.phoneNumberId,
42
- api_version: params.apiVersion || "v22.0",
43
+ api_version: params.apiVersion || 'v22.0',
43
44
  }),
44
45
  };
45
46
 
46
- if (params.status) {
47
- body.status = params.status;
48
- }
49
47
  if (params.phone) {
50
48
  body.phone = params.phone;
51
49
  }
52
50
 
53
51
  const options = {
54
- method: params.id ? "PUT" : "POST",
52
+ method: params.id ? 'PUT' : 'POST',
55
53
  body,
56
54
  };
57
55
 
58
- const endpoint = params.id ? `/connections/${params.id}` : "/connections";
56
+ const endpoint = params.id ? `/connections/${params.id}` : '/connections';
59
57
 
60
58
  return api
61
59
  .fetch(endpoint, options)
@@ -1,105 +1,101 @@
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
- value: "whatsapp_official",
96
- label: "WhatsApp Oficial",
97
- },
98
- ],
99
- format: function (value) {
100
- return value;
101
- },
102
- },
89
+ list: [
90
+ {
91
+ value: "whatsapp",
92
+ label: "Whatsapp",
93
+ },
94
+ ],
95
+ format: function (value) {
96
+ return value;
97
+ },
98
+ },
103
99
  {
104
100
  editable: false,
105
101
  externalFilter: false,
@@ -107,22 +103,22 @@ export default {
107
103
  name: "status",
108
104
  align: "left",
109
105
  label: "status",
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
- };
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
+ };
@@ -1,12 +0,0 @@
1
- import {isPublicRoute, PUBLIC_ROUTES} from '../publicRoutes'
2
-
3
- describe('publicRoutes', () => {
4
- it('treats MCP OAuth consent as public (ManagerLayout gate)', () => {
5
- expect(PUBLIC_ROUTES.has('McpOAuthConsentPage')).toBe(true)
6
- expect(isPublicRoute('McpOAuthConsentPage')).toBe(true)
7
- })
8
-
9
- it('keeps SignIn public', () => {
10
- expect(isPublicRoute('SignInPage')).toBe(true)
11
- })
12
- })