@controleonline/ui-common 1.2.71 → 1.2.75

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 (150) hide show
  1. package/.github/actions/workers/manager/action.yml +147 -0
  2. package/.github/actions/workers/qa/action.yml +44 -0
  3. package/.github/actions/workers/security/action.yml +44 -0
  4. package/.github/actions/workers/technical-documenter/action.yml +51 -0
  5. package/.github/workflows/manager-worker.yml +168 -0
  6. package/.github/workflows/publish-npm.yml +45 -0
  7. package/.gitmodules +3 -0
  8. package/AGENTS.md +6 -0
  9. package/README.md +14 -0
  10. package/package.json +3 -2
  11. package/src/api/fetch.js +1 -1
  12. package/src/api/index.js +92 -22
  13. package/src/react/components/AddImportModal.js +94 -110
  14. package/src/react/components/BottomNavigationBar.config.js +211 -231
  15. package/src/react/components/CategoryForm.js +52 -35
  16. package/src/react/components/DefaultProvider.native.js +131 -95
  17. package/src/react/components/DefaultProvider.web.js +148 -74
  18. package/src/react/components/NetworkPrinterPreviewModal.js +249 -0
  19. package/src/react/components/NetworkPrinterPreviewModal.styles.js +159 -0
  20. package/src/react/components/RuntimeInfoFooter.js +100 -36
  21. package/src/react/components/RuntimeInfoFooter.styles.js +3 -0
  22. package/src/react/components/UnifiedPaymentBar.js +7 -4
  23. package/src/react/components/UserAvatar.js +160 -0
  24. package/src/react/components/integrations/IntegrationHero/index.js +48 -0
  25. package/src/react/components/integrations/IntegrationHero/styles.js +57 -0
  26. package/src/react/components/integrations/IntegrationTabs/index.js +89 -0
  27. package/src/react/components/integrations/IntegrationTabs/styles.js +44 -0
  28. package/src/react/config/deviceConfigBootstrap.js +5 -3
  29. package/src/react/pages/Connections.js +229 -0
  30. package/src/react/pages/Connections.styles.js +222 -0
  31. package/src/react/pages/DeviceDetailPage.js +2814 -0
  32. package/src/react/pages/DeviceDetailPage.styles.js +308 -0
  33. package/src/react/pages/Devices/currentDevice.js +194 -0
  34. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +257 -0
  35. package/src/react/pages/Devices/deviceTypes/all.js +23 -0
  36. package/src/react/pages/Devices/deviceTypes/device.js +25 -0
  37. package/src/react/pages/Devices/deviceTypes/deviceListHelpers.js +178 -0
  38. package/src/react/pages/Devices/deviceTypes/display.js +26 -0
  39. package/src/react/pages/Devices/deviceTypes/index.js +145 -0
  40. package/src/react/pages/Devices/deviceTypes/ipCamera.js +35 -0
  41. package/src/react/pages/Devices/deviceTypes/pdv.js +88 -0
  42. package/src/react/pages/Devices/deviceTypes/printer.js +37 -0
  43. package/src/react/pages/Devices/deviceTypes/shared.js +453 -0
  44. package/src/react/pages/Devices/deviceTypes/useDeviceNetworkConnectivity.js +145 -0
  45. package/src/react/pages/Devices.js +183 -0
  46. package/src/react/pages/Devices.styles.js +353 -0
  47. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -0
  48. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -0
  49. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -0
  50. package/src/react/pages/Food99IntegrationPage/components/Food99ProductCard.js +1 -0
  51. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +181 -0
  52. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -0
  53. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -0
  54. package/src/react/pages/Food99IntegrationPage/index.js +1530 -0
  55. package/src/react/pages/Food99IntegrationPage/styles.js +792 -0
  56. package/src/react/pages/Food99IntegrationPage/utils.js +155 -0
  57. package/src/react/pages/Food99IntegrationPage.js +1 -0
  58. package/src/react/pages/Food99IntegrationPage.styles.js +1 -0
  59. package/src/react/pages/GenericLogPage.js +42 -167
  60. package/src/react/pages/IFoodIntegrationPage/components/IFoodCatalogTab.js +8 -0
  61. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +420 -0
  62. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -0
  63. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +103 -0
  64. package/src/react/pages/IFoodIntegrationPage/components/IFoodProductCard.js +1 -0
  65. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -0
  66. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -0
  67. package/src/react/pages/IFoodIntegrationPage/styles.js +764 -0
  68. package/src/react/pages/IFoodIntegrationPage/utils.js +91 -0
  69. package/src/react/pages/IFoodIntegrationPage.js +1 -0
  70. package/src/react/pages/IFoodIntegrationPage.styles.js +1 -0
  71. package/src/react/pages/Imports.js +214 -166
  72. package/src/react/pages/IntegrationConfigPage.js +744 -0
  73. package/src/react/pages/IntegrationConfigPage.styles.js +269 -0
  74. package/src/react/pages/Integrations.js +299 -0
  75. package/src/react/pages/Integrations.styles.js +130 -0
  76. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -0
  77. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -0
  78. package/src/react/pages/MarketplaceIntegrationPage/components/RemoteMarketplaceMenuTab.js +335 -0
  79. package/src/react/pages/MarketplaceIntegrationPage/index.js +60 -0
  80. package/src/react/pages/MarketplaceIntegrationPage/utils.js +137 -0
  81. package/src/react/pages/MercadoLivreIntegrationPage.js +538 -0
  82. package/src/react/pages/PrinterDeviceDetailPage.js +1916 -0
  83. package/src/react/pages/PrinterDeviceDetailPage.styles.js +223 -0
  84. package/src/react/pages/PrinterDeviceFormPage.js +521 -0
  85. package/src/react/pages/PrinterDeviceFormPage.styles.js +159 -0
  86. package/src/react/pages/WhatsAppConnectionPage.js +459 -0
  87. package/src/react/pages/WhatsAppConnectionPage.styles.js +284 -0
  88. package/src/react/pages/integrationsCatalog.js +399 -0
  89. package/src/react/services/Cielo/Cielo.js +193 -193
  90. package/src/react/utils/categoryContexts.js +46 -0
  91. package/src/react/utils/entityDisplay.js +222 -217
  92. package/src/react/utils/fileUrl.js +39 -20
  93. package/src/react/utils/integrationPage.js +16 -0
  94. package/src/react/utils/runtimeFooter.js +40 -22
  95. package/src/react/utils/runtimeLanguage.js +50 -9
  96. package/src/react/utils/runtimeMenu.js +191 -131
  97. package/src/react/utils/runtimeZoom.js +43 -0
  98. package/src/react/utils/shopConfig.js +27 -15
  99. package/src/react/utils/shopFranchises.js +126 -1
  100. package/src/react/utils/storeColumns.js +23 -4
  101. package/src/react/utils/userAvatar.js +104 -0
  102. package/src/store/categories/index.js +48 -20
  103. package/src/store/device_config/index.js +62 -21
  104. package/src/store/entity_log/index.js +22 -1
  105. package/src/store/imports/customActions.js +51 -0
  106. package/src/store/imports/index.js +89 -88
  107. package/src/store/status/index.js +11 -11
  108. package/src/store/themes/index.js +22 -0
  109. package/src/store/timezones/index.js +3 -1
  110. package/src/tests/browser/manager/connections.spec.js +143 -0
  111. package/src/tests/browser/manager/devices-current.spec.js +343 -0
  112. package/src/tests/browser/manager/mercado-livre-integration.spec.js +268 -0
  113. package/src/tests/react/api/deviceHeaders.test.js +114 -0
  114. package/src/tests/react/components/AddImportModal.test.js +166 -0
  115. package/src/tests/react/components/BottomNavigationBar.config.test.js +20 -0
  116. package/src/tests/react/components/UserAvatar.test.js +52 -0
  117. package/src/tests/react/pages/DevicePickerStyles.test.js +47 -0
  118. package/src/tests/react/pages/Devices/deviceListHelpers.test.js +39 -0
  119. package/src/tests/react/pages/DevicesCurrentDevice.test.js +198 -0
  120. package/src/tests/react/pages/connectionsHelpers.test.js +34 -0
  121. package/src/tests/react/pages/mercadoLivreIntegrationPageContract.test.mjs +16 -0
  122. package/src/tests/react/services/Cielo.test.js +190 -190
  123. package/src/tests/react/store/categoriesOrdering.test.js +26 -0
  124. package/src/tests/react/utils/appDomain.test.js +62 -0
  125. package/src/tests/react/utils/entityDisplay.test.js +2 -2
  126. package/src/tests/react/utils/fileUrl.test.js +3 -3
  127. package/src/tests/react/utils/formatter.test.mjs +33 -0
  128. package/src/tests/react/utils/runtimeFooter.test.js +29 -4
  129. package/src/tests/react/utils/runtimeLanguage.test.js +79 -9
  130. package/src/tests/react/utils/runtimeMenu.test.js +198 -134
  131. package/src/tests/react/utils/runtimeZoom.test.js +38 -0
  132. package/src/tests/react/utils/shopConfig.test.js +10 -9
  133. package/src/tests/react/utils/shopFranchises.test.js +43 -0
  134. package/src/tests/react/utils/translate.discovery.test.mjs +170 -0
  135. package/src/tests/react/utils/translate.test.helpers.mjs +152 -0
  136. package/src/tests/react/utils/translate.test.mjs +141 -349
  137. package/src/tests/react/utils/userAvatar.test.js +63 -0
  138. package/src/utils/appDomain.js +15 -4
  139. package/src/utils/formatter.js +104 -16
  140. package/src/utils/integrationConfigs.js +80 -80
  141. package/src/utils/translate.js +222 -438
  142. package/src/utils/translateDiscovery.js +96 -0
  143. package/src/utils/translateNormalize.js +33 -0
  144. package/src/utils/translatePending.js +92 -0
  145. package/src/utils/translateStorage.js +142 -0
  146. package/.github/agents/developer.agent.md +0 -30
  147. package/.github/agents/devops.agent.md +0 -30
  148. package/.github/agents/qa.agent.md +0 -30
  149. package/.github/agents/security.agent.md +0 -30
  150. package/.github/workflows/npmjs.yml +0 -35
@@ -3,7 +3,7 @@ import {
3
3
  extractCollectionItems,
4
4
  toEntityIri,
5
5
  } from '@controleonline/ui-common/src/react/utils/commercialDocumentOrders';
6
- import {normalizeShopEntityId} from '@controleonline/ui-common/src/react/utils/shopConfig';
6
+ import {normalizeShopEntityId} from '@controleonline/ui-common/src/react/utils/shopConfig';
7
7
 
8
8
  export const SHOP_FRANCHISE_LINK_TYPE = 'franchisee';
9
9
  export const SHOP_FRANCHISE_PAGE_SIZE = 50;
@@ -25,6 +25,131 @@ const sortByLabel = (left, right) =>
25
25
  .localeCompare(String(right || ''), 'pt-BR', {
26
26
  sensitivity: 'base',
27
27
  });
28
+
29
+ const normalizeCategoryCandidate = value => {
30
+ const normalizedId = normalizeShopEntityId(value);
31
+
32
+ if (normalizedId) {
33
+ return normalizedId;
34
+ }
35
+
36
+ if (typeof value === 'string' || typeof value === 'number') {
37
+ return String(value || '').trim();
38
+ }
39
+
40
+ return '';
41
+ };
42
+
43
+ export const extractAddressCategoryIds = address => {
44
+ const candidates = [
45
+ address?.categories,
46
+ address?.category,
47
+ address?.addressCategories,
48
+ address?.address_categories,
49
+ address?.categoryAddresses,
50
+ address?.category_addresses,
51
+ ];
52
+ const result = new Set();
53
+
54
+ const collect = value => {
55
+ if (value === null || value === undefined || value === '') {
56
+ return;
57
+ }
58
+
59
+ if (Array.isArray(value)) {
60
+ value.forEach(collect);
61
+ return;
62
+ }
63
+
64
+ if (typeof value === 'object') {
65
+ [
66
+ value.category,
67
+ value.category_id,
68
+ value.categoryId,
69
+ value.id,
70
+ value['@id'],
71
+ ].forEach(collect);
72
+ return;
73
+ }
74
+
75
+ String(value)
76
+ .split(/\r?\n|,/)
77
+ .map(normalizeCategoryCandidate)
78
+ .filter(Boolean)
79
+ .forEach(id => result.add(id));
80
+ };
81
+
82
+ candidates.forEach(collect);
83
+
84
+ return Array.from(result);
85
+ };
86
+
87
+ export const addressMatchesFranchiseCategoryIds = (
88
+ address,
89
+ categoryIds = [],
90
+ ) => {
91
+ const selectedCategoryIds = new Set(
92
+ (Array.isArray(categoryIds) ? categoryIds : [])
93
+ .map(normalizeCategoryCandidate)
94
+ .filter(Boolean),
95
+ );
96
+
97
+ if (selectedCategoryIds.size === 0) {
98
+ return true;
99
+ }
100
+
101
+ return extractAddressCategoryIds(address).some(categoryId =>
102
+ selectedCategoryIds.has(categoryId),
103
+ );
104
+ };
105
+
106
+ export const filterShopFranchiseDirectory = ({
107
+ directory = [],
108
+ visibleCompanyIds = [],
109
+ addressCategoryIds = [],
110
+ legacyVisibleAddressIds = [],
111
+ } = {}) => {
112
+ const visibleCompanyIdSet = new Set(
113
+ (Array.isArray(visibleCompanyIds) ? visibleCompanyIds : [])
114
+ .map(normalizeShopEntityId)
115
+ .filter(Boolean),
116
+ );
117
+ const legacyVisibleAddressIdSet = new Set(
118
+ (Array.isArray(legacyVisibleAddressIds) ? legacyVisibleAddressIds : [])
119
+ .map(normalizeShopEntityId)
120
+ .filter(Boolean),
121
+ );
122
+
123
+ if (visibleCompanyIdSet.size === 0) {
124
+ return [];
125
+ }
126
+
127
+ return (Array.isArray(directory) ? directory : [])
128
+ .map(company => {
129
+ const companyId = normalizeShopEntityId(company);
130
+
131
+ if (!visibleCompanyIdSet.has(companyId)) {
132
+ return null;
133
+ }
134
+
135
+ const shopAddresses = (company?.shopAddresses || []).filter(address => {
136
+ if (!addressMatchesFranchiseCategoryIds(address, addressCategoryIds)) {
137
+ return false;
138
+ }
139
+
140
+ return (
141
+ legacyVisibleAddressIdSet.size === 0 ||
142
+ legacyVisibleAddressIdSet.has(normalizeShopEntityId(address))
143
+ );
144
+ });
145
+
146
+ return {
147
+ ...company,
148
+ shopAddresses,
149
+ };
150
+ })
151
+ .filter(Boolean);
152
+ };
28
153
 
29
154
  export const resolveFranchiseCompanyLabel = company =>
30
155
  String(company?.alias || company?.name || '').trim() ||
@@ -116,10 +116,29 @@ const normalizeFormattedValue = value => {
116
116
  if (value === null || value === undefined) {
117
117
  return value;
118
118
  }
119
-
120
- if (typeof value === 'object' && !Array.isArray(value)) {
121
- return value?.label ?? value?.value ?? value?.name ?? value;
122
- }
119
+
120
+ if (Array.isArray(value)) {
121
+ return value
122
+ .map(item => normalizeFormattedValue(item))
123
+ .filter(item => normalizeText(item))
124
+ .join(', ');
125
+ }
126
+
127
+ if (typeof value === 'object' && !Array.isArray(value)) {
128
+ return (
129
+ value?.label ??
130
+ value?.value ??
131
+ value?.name ??
132
+ value?.alias ??
133
+ value?.icon ??
134
+ value?.fileName ??
135
+ value?.filename ??
136
+ value?.originalName ??
137
+ value?.id ??
138
+ value?.['@id'] ??
139
+ ''
140
+ );
141
+ }
123
142
 
124
143
  return value;
125
144
  };
@@ -0,0 +1,104 @@
1
+ import md5 from 'md5';
2
+
3
+ const normalizeText = value => String(value || '').replace(/\s+/g, ' ').trim();
4
+
5
+ const extractNumericId = value => {
6
+ const normalized = normalizeText(value);
7
+ if (!normalized) {
8
+ return '';
9
+ }
10
+
11
+ if (/^\d+$/.test(normalized)) {
12
+ return normalized;
13
+ }
14
+
15
+ const match = normalized.match(/\/(\d+)(?:\/)?$/);
16
+ return match ? match[1] : '';
17
+ };
18
+
19
+ export const getAvatarDisplayName = user =>
20
+ normalizeText(
21
+ user?.name ||
22
+ user?.people?.name ||
23
+ user?.person?.name ||
24
+ user?.realname ||
25
+ user?.username,
26
+ );
27
+
28
+ export const resolveUserAvatarUrl = (user, resolvePersistedAvatar) => {
29
+ return (
30
+ typeof resolvePersistedAvatar === 'function'
31
+ ? normalizeText(resolvePersistedAvatar(user?.avatar))
32
+ : ''
33
+ );
34
+ };
35
+
36
+ export const resolveUserPeopleIri = (user, session = {}) => {
37
+ const candidates = [
38
+ session?.people,
39
+ session?.person,
40
+ session?.peopleId,
41
+ session?.people_id,
42
+ user?.people?.['@id'],
43
+ user?.people?.id,
44
+ user?.people,
45
+ user?.person?.['@id'],
46
+ user?.person?.id,
47
+ user?.person,
48
+ user?.peopleId,
49
+ user?.people_id,
50
+ user?.person_id,
51
+ user?.['@id'],
52
+ user?.id,
53
+ ];
54
+
55
+ for (const candidate of candidates) {
56
+ const normalized = normalizeText(candidate);
57
+ if (!normalized) {
58
+ continue;
59
+ }
60
+
61
+ if (normalized.includes('/people/')) {
62
+ return normalized;
63
+ }
64
+
65
+ const id = extractNumericId(normalized);
66
+ if (id) {
67
+ return `/people/${id}`;
68
+ }
69
+ }
70
+
71
+ return '';
72
+ };
73
+
74
+ export const getUserInitials = ({name, email} = {}) => {
75
+ const words = normalizeText(name).split(' ').filter(Boolean);
76
+
77
+ if (words.length >= 2) {
78
+ return `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase();
79
+ }
80
+
81
+ if (words.length === 1) {
82
+ return words[0][0].toUpperCase();
83
+ }
84
+
85
+ const normalizedEmail = normalizeText(email);
86
+ return normalizedEmail ? normalizedEmail[0].toUpperCase() : '?';
87
+ };
88
+
89
+ export const getGravatarUrl = (email, size = 200) => {
90
+ const normalizedEmail = normalizeText(email).toLowerCase();
91
+ if (!normalizedEmail) {
92
+ return '';
93
+ }
94
+
95
+ return `https://www.gravatar.com/avatar/${md5(normalizedEmail)}?s=${size}&d=404`;
96
+ };
97
+
98
+ export default {
99
+ getAvatarDisplayName,
100
+ getGravatarUrl,
101
+ getUserInitials,
102
+ resolveUserAvatarUrl,
103
+ resolveUserPeopleIri,
104
+ };
@@ -8,11 +8,20 @@ export default {
8
8
  item: {},
9
9
  items: [],
10
10
  filters: {},
11
- resourceEndpoint: "categories",
12
- isLoading: false,
13
- error: "",
14
-
15
- totalItems: 0,messages:[], message:{},
11
+ resourceEndpoint: "categories",
12
+ isLoading: false,
13
+ error: "",
14
+ configs: {
15
+ import: {
16
+ enabled: true,
17
+ importType: "product",
18
+ labelKey: ["categories", "button", "importCsv"],
19
+ titleKey: ["categories", "title", "productImport"],
20
+ searchPlaceholderKey: ["categories", "input", "importSearch"],
21
+ },
22
+ },
23
+
24
+ totalItems: 0,messages:[], message:{},
16
25
 
17
26
  summary: {},
18
27
  filters: {},
@@ -29,17 +38,34 @@ export default {
29
38
  return "#" + value;
30
39
  },
31
40
  },
32
- {
33
- externalFilter: false,
34
- sortable: true,
35
- name: "name",
41
+ {
42
+ externalFilter: false,
43
+ sortable: true,
44
+ name: "name",
36
45
  align: "left",
37
46
  label: "name",
38
47
  sum: false,
39
48
  format: function (value) {
40
49
  return value;
41
- },
42
- },
50
+ },
51
+ },
52
+ {
53
+ sortable: true,
54
+ editable: true,
55
+ inputType: "number",
56
+ name: "sortOrder",
57
+ align: "right",
58
+ label: "sortOrder",
59
+ defaultSort: "ASC",
60
+ format: function (value) {
61
+ return value ?? "";
62
+ },
63
+ saveFormat: function (value) {
64
+ return value === "" || value === null || value === undefined
65
+ ? null
66
+ : Number(value);
67
+ },
68
+ },
43
69
  {
44
70
  sortable: true,
45
71
  name: "color",
@@ -60,15 +86,17 @@ export default {
60
86
  return value;
61
87
  },
62
88
  },
63
- {
64
- sortable: true,
65
- name: "categoryFiles",
66
- align: "left",
67
- label: "categoryFiles",
68
- format: function (value) {
69
- return value;
70
- },
71
- },
89
+ {
90
+ sortable: true,
91
+ name: "categoryFiles",
92
+ align: "left",
93
+ label: "categoryFiles",
94
+ inputType: "files",
95
+ fileType: "image",
96
+ format: function (value) {
97
+ return value;
98
+ },
99
+ },
72
100
  {
73
101
  externalFilter: false,
74
102
  sortable: true,
@@ -1,28 +1,69 @@
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: 'device_configs',
12
- isLoading: false,
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: 'device_configs',
12
+ isLoading: false,
13
13
  isSaving: false,
14
14
  error: '',
15
- totalItems: 0,messages:[], message:{},
15
+ totalItems: 0,
16
+ messages: [],
17
+ message: {},
16
18
  summary: {},
17
19
  loadedKey: '',
18
20
  loadedAt: 0,
19
21
  filters: {},
20
- columns: [],
22
+ columns: [
23
+ {
24
+ editable: false,
25
+ isIdentity: true,
26
+ sortable: true,
27
+ name: 'id',
28
+ align: 'left',
29
+ label: 'id',
30
+ format(value) {
31
+ return value != null ? `#${value}` : '';
32
+ },
33
+ },
34
+ {
35
+ sortable: true,
36
+ name: 'alias',
37
+ align: 'left',
38
+ label: 'device',
39
+ format(value) {
40
+ return value || '';
41
+ },
42
+ },
43
+ {
44
+ sortable: true,
45
+ name: 'typeLabel',
46
+ align: 'left',
47
+ label: 'type',
48
+ format(value) {
49
+ return value || '';
50
+ },
51
+ },
52
+ {
53
+ sortable: true,
54
+ name: 'type',
55
+ align: 'left',
56
+ label: 'configType',
57
+ format(value) {
58
+ return value || '';
59
+ },
60
+ },
61
+ ],
21
62
  },
22
- actions: {
23
- ...customActions,
24
- ...actions,
25
- },
26
- getters,
27
- mutations,
28
- };
63
+ actions: {
64
+ ...customActions,
65
+ ...actions,
66
+ },
67
+ getters,
68
+ mutations,
69
+ };
@@ -17,7 +17,28 @@ export default {
17
17
  messages: [],
18
18
  message: {},
19
19
  filters: {},
20
- columns: [],
20
+ columns: [
21
+ {
22
+ externalFilter: true,
23
+ inputType: 'date-range',
24
+ label: 'period',
25
+ name: 'createdAt',
26
+ table: false,
27
+ },
28
+ {
29
+ externalFilter: true,
30
+ label: 'Tipo de log',
31
+ list: true,
32
+ name: 'type',
33
+ table: false,
34
+ },
35
+ {
36
+ externalFilter: true,
37
+ label: 'Classe / origem',
38
+ name: 'class',
39
+ table: false,
40
+ },
41
+ ],
21
42
  },
22
43
  actions: {...actions, ...customActions},
23
44
  getters,
@@ -0,0 +1,51 @@
1
+ import {Platform} from 'react-native';
2
+ import {api} from '@controleonline/ui-common/src/api';
3
+
4
+ const extractId = value => {
5
+ if (value === null || value === undefined || value === '') {
6
+ return '';
7
+ }
8
+
9
+ if (typeof value === 'number') {
10
+ return String(value);
11
+ }
12
+
13
+ const raw = typeof value === 'string' ? value : value?.id || value?.['@id'];
14
+ const match = String(raw || '').match(/(\d+)$/);
15
+ return match ? match[1] : '';
16
+ };
17
+
18
+ export const uploadImportFile = (_context, payload = {}) => {
19
+ const normalizedPayload = payload && typeof payload === 'object' ? payload : {};
20
+ const file = normalizedPayload.file;
21
+ const importType = String(normalizedPayload.importType || '').trim();
22
+ const peopleId = extractId(normalizedPayload.peopleId || normalizedPayload.people);
23
+
24
+ if (!file) {
25
+ throw new Error('Arquivo de importacao nao informado.');
26
+ }
27
+
28
+ if (!importType) {
29
+ throw new Error('Tipo de importacao nao informado.');
30
+ }
31
+
32
+ if (!peopleId) {
33
+ throw new Error('Empresa nao identificada para a importacao.');
34
+ }
35
+
36
+ const formData = new FormData();
37
+ formData.append('importType', importType);
38
+ formData.append('people', peopleId);
39
+
40
+ if (Platform.OS === 'web') {
41
+ formData.append('file', file);
42
+ } else {
43
+ formData.append('file', {
44
+ uri: file.uri,
45
+ name: file.name || 'import.csv',
46
+ type: file.mimeType || 'text/csv',
47
+ });
48
+ }
49
+
50
+ return api.upload('/imports/upload', formData);
51
+ };