@controleonline/ui-common 1.2.87 → 1.2.89

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 (77) hide show
  1. package/.github/workflows/integration-source-gate.yml +68 -0
  2. package/.github/workflows/manager-worker.yml +7 -156
  3. package/.github/workflows/publish-npm.yml +73 -27
  4. package/.github/workflows/pull-request-checks.yml +7 -5
  5. package/docs/technical/Device-Detail-Alias-UI-Sync.md +141 -0
  6. package/package.json +13 -8
  7. package/src/api/localDB.js +86 -131
  8. package/src/react/components/BottomNavigationBar.js +178 -174
  9. package/src/react/components/BottomNavigationBar.styles.js +139 -118
  10. package/src/react/components/DefaultProvider.native.js +427 -421
  11. package/src/react/components/DefaultProvider.web.js +131 -125
  12. package/src/react/components/RemoteCheckoutService.js +3 -3
  13. package/src/react/components/RuntimeFooterMarqueeText.js +88 -36
  14. package/src/react/components/RuntimeInfoFooter.js +76 -43
  15. package/src/react/components/RuntimeInfoFooter.styles.js +22 -14
  16. package/src/react/config/deviceConfigBootstrap.js +71 -233
  17. package/src/react/config/deviceConfigValues.js +238 -0
  18. package/src/react/pages/Devices/detail/DeviceChargePermissionSection.js +32 -0
  19. package/src/react/pages/Devices/detail/DeviceDetailAlertsCommandsSection.js +4 -22
  20. package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +6 -2
  21. package/src/react/pages/Devices/detail/DeviceDetailOrdersPrintSection.js +4 -0
  22. package/src/react/pages/Devices/detail/DeviceDetailPdvConfigSection.js +7 -0
  23. package/src/react/pages/Devices/detail/DeviceDetailScreen.js +24 -335
  24. package/src/react/pages/Devices/detail/createDeviceDetailContext.js +20 -0
  25. package/src/react/pages/Devices/detail/deviceDetailHelpers.js +2 -11
  26. package/src/react/pages/Devices/detail/useDeviceDetailActions.js +11 -36
  27. package/src/react/pages/Devices/detail/useDeviceDetailLoaders.js +129 -37
  28. package/src/react/pages/Devices/detail/useDeviceDetailSaves.js +11 -38
  29. package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +9 -28
  30. package/src/react/pages/IntegrationConfigFields.js +1 -0
  31. package/src/react/pages/IntegrationConfigPage.js +101 -45
  32. package/src/react/pages/IntegrationConfigPage.utils.js +21 -13
  33. package/src/react/pages/fetchPeopleConfigs.js +21 -0
  34. package/src/react/pages/integrationsCatalog.js +15 -110
  35. package/src/react/services/Cielo/Cielo.js +9 -9
  36. package/src/react/services/Getnet/Getnet.web.js +25 -0
  37. package/src/react/utils/companyAuthority.js +36 -0
  38. package/src/react/utils/confirmAction.js +12 -0
  39. package/src/react/utils/fileUrl.js +14 -5
  40. package/src/react/utils/paymentDevices.js +375 -270
  41. package/src/react/utils/printerDevices.js +2 -2
  42. package/src/react/utils/runtimeFooter.js +178 -224
  43. package/src/react/utils/runtimeFooterText.js +160 -0
  44. package/src/react/utils/runtimeLanguage.js +5 -5
  45. package/src/react/utils/runtimeZoom.js +29 -5
  46. package/src/react/utils/shopFranchises.js +167 -12
  47. package/src/react/utils/storeColumns.js +235 -217
  48. package/src/react/utils/systemErrorMessage.js +2 -1
  49. package/src/store/integration/index.js +43 -0
  50. package/src/tests/browser/manager/device-detail-apply-config-defined.spec.js +31 -0
  51. package/src/tests/browser/manager/device-detail-composition.spec.js +295 -0
  52. package/src/tests/browser/manager/device-detail-copy-config.spec.js +11 -1
  53. package/src/tests/browser/manager/device-detail-pdv-current-company.spec.js +273 -0
  54. package/src/tests/browser/manager/runtime-footer-rotation.spec.js +397 -0
  55. package/src/tests/react/components/DefaultProviderAuthority.test.js +28 -0
  56. package/src/tests/react/components/RuntimeFooterMarqueeText.build.test.js +29 -0
  57. package/src/tests/react/config/deviceConfigBootstrap.test.js +24 -1
  58. package/src/tests/react/pages/DeviceChargePermissionSection.test.js +42 -0
  59. package/src/tests/react/pages/applyCurrentDeviceConfig.test.js +85 -0
  60. package/src/tests/react/pages/deviceDetailComposition.test.js +65 -0
  61. package/src/tests/react/pages/deviceDetailHookDependencies.test.mjs +31 -0
  62. package/src/tests/react/pages/deviceDetailLoaderDependencies.test.mjs +28 -0
  63. package/src/tests/react/pages/receitaFederalIntegrationContract.test.mjs +27 -6
  64. package/src/tests/react/services/Cielo.test.js +2 -2
  65. package/src/tests/react/utils/companyAuthority.test.js +53 -0
  66. package/src/tests/react/utils/formatter.test.mjs +6 -0
  67. package/src/tests/react/utils/paymentDevices.test.js +72 -0
  68. package/src/tests/react/utils/runtimeFooter.test.js +35 -0
  69. package/src/tests/react/utils/runtimeFooterText.test.js +88 -0
  70. package/src/tests/react/utils/runtimeLanguage.test.js +4 -4
  71. package/src/tests/react/utils/runtimeZoom.test.js +20 -0
  72. package/src/tests/react/utils/shopFranchises.test.js +32 -13
  73. package/src/tests/react/utils/translate.test.mjs +6 -6
  74. package/src/utils/formatter.js +7 -3
  75. package/src/utils/translate.js +16 -16
  76. package/src/utils/translatePending.js +6 -6
  77. package/src/utils/translateStorage.js +2 -2
@@ -1,237 +1,48 @@
1
+ import {appendScreenMetrics, hasScreenMetricsChanges} from '@controleonline/ui-common/src/react/utils/screenMetrics.js';
2
+ import {normalizeBooleanConfig, SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY} from '@controleonline/ui-common/src/react/utils/shopConfig.js';
1
3
  import {
2
- appendScreenMetrics,
3
- hasScreenMetricsChanges,
4
- } from '@controleonline/ui-common/src/react/utils/screenMetrics';
5
- import {
6
- normalizeBooleanConfig,
7
- SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
8
- } from '@controleonline/ui-common/src/react/utils/shopConfig';
9
-
10
- export const CIELO_DEVICES = ['quantum', 'ingenico', 'positivo'];
11
- export const SUPPORTED_POS_GATEWAYS = ['cielo', 'infinite-pay'];
12
- export const DEVICE_ALERT_SOUND_ENABLED_KEY = 'notification-sound-enabled';
13
- export const DEVICE_ALERT_SOUND_URL_KEY = 'notification-sound-url';
14
- export const DEVICE_ORDER_VISIBILITY_KEY = 'pos-order-visibility';
15
- export const DEVICE_ORDER_VISIBILITY_DEVICE = 'device';
16
- export const DEVICE_ORDER_VISIBILITY_COMPANY = 'company';
17
- export const POS_DELIVERY_ENABLED_CONFIG_KEY = 'pos-delivery-enabled';
18
- export const DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY =
19
- 'device-runtime-debug-info-enabled';
20
- export const DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY =
21
- 'display-auto-print-product';
22
- export const DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY =
23
- 'display-allow-printer-change';
24
- export const DISPLAY_SIZE_CONFIG_KEY = 'display-size';
25
- export const DISPLAY_SIDE_BREAK_CONFIG_KEY = 'display-side-break';
26
- export const DISPLAY_SIZE_MIN = 1;
27
- export const DISPLAY_SIZE_MAX = 10;
28
- export const DISPLAY_SIZE_DEFAULT = 5;
29
- export const POS_OPERATION_MODE_CONFIG_KEY = 'pos-operation-mode';
30
- /** Independent of operation mode: whether this device may run local charge/payment. */
31
- export const POS_LOCAL_CHARGE_ENABLED_CONFIG_KEY = 'pos-local-charge-enabled';
32
- export const POS_PRODUCT_SHOWCASE_CONFIG_KEY = 'pos-product-showcase-id';
33
- export const DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY =
34
- 'android-kiosk-enabled';
35
- export const DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY =
36
- 'android-launcher-enabled';
37
- export const POS_AUTO_PRINT_ENABLED_CONFIG_KEY = 'pos-auto-print-enabled';
38
- export const POS_CASH_MANAGEMENT_MODE_CONFIG_KEY =
39
- 'pos-cash-management-mode';
40
- export const POS_CHECK_ORDER_TYPE_CONFIG_KEY = 'check-order-type';
41
- export const POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY =
42
- 'check-order-management-mode';
43
- export const POS_OPERATION_MODE_COUNTER = 'counter';
44
- export const POS_OPERATION_MODE_WAITER = 'waiter';
45
- export const POS_OPERATION_MODE_TOTEM = 'totem';
46
- export const POS_OPERATION_MODE_SINGLE_ITEM = 'single-item';
47
- export const POS_OPERATION_MODE_CASHIER = 'cashier';
48
- export const POS_CHECK_ORDER_TYPE_NONE = 'none';
49
- export const POS_CHECK_ORDER_TYPE_TAB = 'tab';
50
- export const POS_CHECK_ORDER_TYPE_TABLE = 'table';
51
- export const POS_CHECK_ORDER_TYPE_STAMP = 'stamp';
52
- export const POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE = 'manage';
53
- export const POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY = 'existing-only';
54
- export const POS_OPERATION_MODE_DEFAULT = POS_OPERATION_MODE_CASHIER;
55
- export const POS_PRINT_MODE_ORDER = 'order';
56
- export const POS_PRINT_MODE_FORM = 'form';
57
- export const POS_PRINT_MODE_DEFAULT = POS_PRINT_MODE_ORDER;
58
- export const POS_CASH_MANAGEMENT_MODE_CASH_REGISTER = 'cash-register';
59
- export const POS_CASH_MANAGEMENT_MODE_DAILY = 'daily';
60
- export const POS_CASH_MANAGEMENT_MODE_DEFAULT =
61
- POS_CASH_MANAGEMENT_MODE_CASH_REGISTER;
62
- export const POS_OPERATION_MODE_OPTIONS = [
63
- {
64
- value: POS_OPERATION_MODE_COUNTER,
65
- translationKey: 'counterService',
66
- descriptionKey: 'counterServiceDescription',
67
- },
68
- {
69
- value: POS_OPERATION_MODE_WAITER,
70
- translationKey: 'waiterService',
71
- descriptionKey: 'waiterServiceDescription',
72
- },
73
- {
74
- value: POS_OPERATION_MODE_TOTEM,
75
- translationKey: 'selfServiceKiosk',
76
- descriptionKey: 'selfServiceKioskDescription',
77
- },
78
- {
79
- value: POS_OPERATION_MODE_SINGLE_ITEM,
80
- translationKey: 'singleItemSale',
81
- descriptionKey: 'singleItemSaleDescription',
82
- },
83
- {
84
- value: POS_OPERATION_MODE_CASHIER,
85
- translationKey: 'cashierPOS',
86
- descriptionKey: 'cashierPOSDescription',
87
- },
88
- ];
89
-
90
- export const DEFAULT_DEVICE_CONFIGS = {
91
- 'pos-type': 'full',
92
- 'print-mode': 'order',
93
- 'check-type': 'manual',
94
- 'product-input-type': 'manual',
95
- 'selection-type': 'single',
96
- sound: '0',
97
- vibration: '0',
98
- [DEVICE_ORDER_VISIBILITY_KEY]: DEVICE_ORDER_VISIBILITY_DEVICE,
99
- [POS_DELIVERY_ENABLED_CONFIG_KEY]: '1',
100
- [DEVICE_ALERT_SOUND_ENABLED_KEY]: '0',
101
- [DEVICE_ALERT_SOUND_URL_KEY]: '',
102
- [DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY]: '0',
103
- [DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '0',
104
- [DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY]: '0',
105
- [DISPLAY_SIZE_CONFIG_KEY]: String(DISPLAY_SIZE_DEFAULT),
106
- [DISPLAY_SIDE_BREAK_CONFIG_KEY]: '0',
107
- [POS_CHECK_ORDER_TYPE_CONFIG_KEY]: POS_CHECK_ORDER_TYPE_NONE,
108
- [POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY]:
109
- POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
110
- [POS_OPERATION_MODE_CONFIG_KEY]: POS_OPERATION_MODE_DEFAULT,
111
- [POS_PRODUCT_SHOWCASE_CONFIG_KEY]: '',
112
- [POS_AUTO_PRINT_ENABLED_CONFIG_KEY]: '0',
113
- [POS_CASH_MANAGEMENT_MODE_CONFIG_KEY]: POS_CASH_MANAGEMENT_MODE_DEFAULT,
114
- };
115
-
116
- export const isTruthyValue = value =>
117
- value === true || value === '1' || value === 1 || value === 'true';
118
-
119
- export const isMissingConfigValue = value =>
120
- value === undefined || value === null || value === '';
121
-
122
- export const parseConfigsObject = configs => {
123
- if (!configs) return {};
124
-
125
- if (typeof configs === 'string') {
126
- try {
127
- const parsed = JSON.parse(configs);
128
- return parsed && typeof parsed === 'object' ? parsed : {};
129
- } catch {
130
- return {};
131
- }
132
- }
133
-
134
- return typeof configs === 'object' ? {...configs} : {};
135
- };
136
-
137
- export const normalizeDisplaySize = value => {
138
- const normalizedValue = String(value ?? '').trim();
139
-
140
- if (normalizedValue === '') {
141
- return DISPLAY_SIZE_DEFAULT;
142
- }
143
-
144
- const numericValue = Number(normalizedValue);
145
-
146
- if (!Number.isFinite(numericValue)) {
147
- return DISPLAY_SIZE_DEFAULT;
148
- }
149
-
150
- return Math.min(
151
- DISPLAY_SIZE_MAX,
152
- Math.max(DISPLAY_SIZE_MIN, Math.round(numericValue)),
153
- );
154
- };
155
-
156
- export const resolveDisplaySize = configs =>
157
- normalizeDisplaySize(
158
- parseConfigsObject(configs)?.[DISPLAY_SIZE_CONFIG_KEY],
159
- );
160
-
161
- export const isDisplaySideBreakEnabled = configs =>
162
- isTruthyValue(
163
- parseConfigsObject(configs)?.[DISPLAY_SIDE_BREAK_CONFIG_KEY],
164
- );
165
-
166
- export const normalizePosOperationMode = value => {
167
- const normalizedValue = String(value || '')
168
- .trim()
169
- .toLowerCase()
170
- .normalize('NFD')
171
- .replace(/[\u0300-\u036f]/g, '')
172
- .replace(/[\s_]/g, '-');
173
-
174
- if (
175
- [
176
- POS_OPERATION_MODE_COUNTER,
177
- 'balcao',
178
- 'counter-service',
179
- 'front-counter',
180
- ].includes(normalizedValue)
181
- ) {
182
- return POS_OPERATION_MODE_COUNTER;
183
- }
184
-
185
- if (
186
- [
187
- POS_OPERATION_MODE_WAITER,
188
- 'garcon',
189
- 'garcom',
190
- 'table-service',
191
- ].includes(normalizedValue)
192
- ) {
193
- return POS_OPERATION_MODE_WAITER;
194
- }
195
-
196
- if (
197
- [
198
- POS_OPERATION_MODE_TOTEM,
199
- ].includes(normalizedValue)
200
- ) {
201
- return POS_OPERATION_MODE_TOTEM;
202
- }
203
-
204
- if (
205
- [
206
- POS_OPERATION_MODE_SINGLE_ITEM,
207
- 'single-sale',
208
- 'single-item-sale',
209
- 'sale-unit',
210
- 'sale-single',
211
- 'venda-unitaria',
212
- 'venda-unica',
213
- 'item-unico',
214
- 'unit-sale',
215
- 'unitary-sale',
216
- ].includes(normalizedValue)
217
- ) {
218
- return POS_OPERATION_MODE_SINGLE_ITEM;
219
- }
220
-
221
- if (
222
- [
223
- POS_OPERATION_MODE_CASHIER,
224
- 'pdv',
225
- 'pos',
226
- 'checkout',
227
- 'cashier-pos',
228
- ].includes(normalizedValue)
229
- ) {
230
- return POS_OPERATION_MODE_CASHIER;
231
- }
232
-
233
- return '';
234
- };
4
+ CIELO_DEVICES,
5
+ SUPPORTED_POS_GATEWAYS,
6
+ DEVICE_ORDER_VISIBILITY_KEY,
7
+ DEVICE_ORDER_VISIBILITY_DEVICE,
8
+ DEVICE_ORDER_VISIBILITY_COMPANY,
9
+ POS_DELIVERY_ENABLED_CONFIG_KEY,
10
+ DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY,
11
+ DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY,
12
+ POS_OPERATION_MODE_CONFIG_KEY,
13
+ POS_LOCAL_CHARGE_ENABLED_CONFIG_KEY,
14
+ ORDER_CHARGE_ENABLED_CONFIG_KEY,
15
+ isOrderChargeEnabled,
16
+ DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY,
17
+ DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY,
18
+ POS_AUTO_PRINT_ENABLED_CONFIG_KEY,
19
+ POS_CASH_MANAGEMENT_MODE_CONFIG_KEY,
20
+ POS_CHECK_ORDER_TYPE_CONFIG_KEY,
21
+ POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY,
22
+ POS_OPERATION_MODE_COUNTER,
23
+ POS_OPERATION_MODE_WAITER,
24
+ POS_OPERATION_MODE_TOTEM,
25
+ POS_OPERATION_MODE_SINGLE_ITEM,
26
+ POS_CHECK_ORDER_TYPE_NONE,
27
+ POS_CHECK_ORDER_TYPE_TAB,
28
+ POS_CHECK_ORDER_TYPE_TABLE,
29
+ POS_CHECK_ORDER_TYPE_TABLE_TAB,
30
+ POS_CHECK_ORDER_TYPE_STAMP,
31
+ POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
32
+ POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
33
+ POS_PRINT_MODE_FORM,
34
+ POS_PRINT_MODE_DEFAULT,
35
+ POS_CASH_MANAGEMENT_MODE_CASH_REGISTER,
36
+ POS_CASH_MANAGEMENT_MODE_DAILY,
37
+ POS_CASH_MANAGEMENT_MODE_DEFAULT,
38
+ POS_OPERATION_MODE_OPTIONS,
39
+ DEFAULT_DEVICE_CONFIGS,
40
+ isTruthyValue,
41
+ isMissingConfigValue,
42
+ parseConfigsObject,
43
+ normalizePosOperationMode,
44
+ } from './deviceConfigValues';
45
+ export * from './deviceConfigValues';
235
46
 
236
47
  export const resolvePosOperationMode = configs =>
237
48
  normalizePosOperationMode(
@@ -264,6 +75,10 @@ export const normalizePosCheckOrderType = value => {
264
75
  return POS_CHECK_ORDER_TYPE_TABLE;
265
76
  }
266
77
 
78
+ if (normalizedValue === POS_CHECK_ORDER_TYPE_TABLE_TAB) {
79
+ return POS_CHECK_ORDER_TYPE_TABLE_TAB;
80
+ }
81
+
267
82
  if (
268
83
  [
269
84
  POS_CHECK_ORDER_TYPE_STAMP,
@@ -306,6 +121,21 @@ export const resolvePosCheckOrderTypeForShop = (
306
121
  return resolvedType;
307
122
  };
308
123
 
124
+ // A device mode is not an Order.orderType. The current entry starts at the
125
+ // table; the waiter navigation can then resolve a concrete tab under that table.
126
+ export const resolvePosCheckOrderEntryTypeForShop = (deviceConfigs, shopConfigs) => {
127
+ const type = resolvePosCheckOrderTypeForShop(deviceConfigs, shopConfigs);
128
+ return type === POS_CHECK_ORDER_TYPE_TABLE_TAB ? POS_CHECK_ORDER_TYPE_TABLE : type;
129
+ };
130
+
131
+ export const resolvePosCheckOrderTypesForShop = (deviceConfigs, shopConfigs) => {
132
+ const type = resolvePosCheckOrderTypeForShop(deviceConfigs, shopConfigs);
133
+ if (type === POS_CHECK_ORDER_TYPE_TABLE_TAB) {
134
+ return [POS_CHECK_ORDER_TYPE_TABLE, POS_CHECK_ORDER_TYPE_TAB];
135
+ }
136
+ return type === POS_CHECK_ORDER_TYPE_NONE ? [] : [type];
137
+ };
138
+
309
139
  export const normalizePosCheckOrderManagementMode = value => {
310
140
  const normalizedValue = String(value || '')
311
141
  .trim()
@@ -513,6 +343,14 @@ export const isPosLocalChargeEnabled = configs => {
513
343
  );
514
344
  };
515
345
 
346
+ // Entry-point visibility only. The consultation and invoice API enforce capability.
347
+ export const isPosChargeEntryEnabled = configs => {
348
+ const parsed = parseConfigsObject(configs);
349
+ return Object.prototype.hasOwnProperty.call(parsed, ORDER_CHARGE_ENABLED_CONFIG_KEY)
350
+ ? isOrderChargeEnabled(parsed)
351
+ : isPosLocalChargeEnabled(parsed);
352
+ };
353
+
516
354
  export const getPosOperationModeOption = mode => {
517
355
 
518
356
  const normalizedMode = normalizePosOperationMode(mode);
@@ -0,0 +1,238 @@
1
+ import {
2
+ normalizeBooleanConfig,
3
+ SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
4
+ } from '@controleonline/ui-common/src/react/utils/shopConfig.js';
5
+
6
+ export const CIELO_DEVICES = ['quantum', 'ingenico', 'positivo'];
7
+ export const SUPPORTED_POS_GATEWAYS = ['cielo', 'infinite-pay'];
8
+ export const DEVICE_ALERT_SOUND_ENABLED_KEY = 'notification-sound-enabled';
9
+ export const DEVICE_ALERT_SOUND_URL_KEY = 'notification-sound-url';
10
+ export const DEVICE_ORDER_VISIBILITY_KEY = 'pos-order-visibility';
11
+ export const DEVICE_ORDER_VISIBILITY_DEVICE = 'device';
12
+ export const DEVICE_ORDER_VISIBILITY_COMPANY = 'company';
13
+ export const POS_DELIVERY_ENABLED_CONFIG_KEY = 'pos-delivery-enabled';
14
+ export const DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY =
15
+ 'device-runtime-debug-info-enabled';
16
+ export const DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY =
17
+ 'display-auto-print-product';
18
+ export const DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY =
19
+ 'display-allow-printer-change';
20
+ export const DISPLAY_SIZE_CONFIG_KEY = 'display-size';
21
+ export const DISPLAY_SIDE_BREAK_CONFIG_KEY = 'display-side-break';
22
+ export const DISPLAY_SIZE_MIN = 1;
23
+ export const DISPLAY_SIZE_MAX = 10;
24
+ export const DISPLAY_SIZE_DEFAULT = 5;
25
+ export const POS_OPERATION_MODE_CONFIG_KEY = 'pos-operation-mode';
26
+ /** Independent of operation mode: whether this device may run local charge/payment. */
27
+ export const POS_LOCAL_CHARGE_ENABLED_CONFIG_KEY = 'pos-local-charge-enabled';
28
+ // Canonical financial permission already enforced by the API.
29
+ export const ORDER_CHARGE_ENABLED_CONFIG_KEY = 'order-charge-enabled';
30
+ export const isOrderChargeEnabled = configs => {
31
+ const value = parseConfigsObject(configs)?.[ORDER_CHARGE_ENABLED_CONFIG_KEY];
32
+ return value === true || value === 1 ||
33
+ ['1', 'true', 'yes', 'on'].includes(String(value ?? '').trim().toLowerCase());
34
+ };
35
+ export const POS_PRODUCT_SHOWCASE_CONFIG_KEY = 'pos-product-showcase-id';
36
+ export const DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY =
37
+ 'android-kiosk-enabled';
38
+ export const DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY =
39
+ 'android-launcher-enabled';
40
+ export const POS_AUTO_PRINT_ENABLED_CONFIG_KEY = 'pos-auto-print-enabled';
41
+ export const POS_CASH_MANAGEMENT_MODE_CONFIG_KEY =
42
+ 'pos-cash-management-mode';
43
+ export const POS_CHECK_ORDER_TYPE_CONFIG_KEY = 'check-order-type';
44
+ export const POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY =
45
+ 'check-order-management-mode';
46
+ export const POS_OPERATION_MODE_COUNTER = 'counter';
47
+ export const POS_OPERATION_MODE_WAITER = 'waiter';
48
+ export const POS_OPERATION_MODE_TOTEM = 'totem';
49
+ export const POS_OPERATION_MODE_SINGLE_ITEM = 'single-item';
50
+ export const POS_OPERATION_MODE_CASHIER = 'cashier';
51
+ export const POS_CHECK_ORDER_TYPE_NONE = 'none';
52
+ export const POS_CHECK_ORDER_TYPE_TAB = 'tab';
53
+ export const POS_CHECK_ORDER_TYPE_TABLE = 'table';
54
+ export const POS_CHECK_ORDER_TYPE_TABLE_TAB = 'table-tab';
55
+ export const POS_CHECK_ORDER_TYPE_STAMP = 'stamp';
56
+ export const POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE = 'manage';
57
+ export const POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY = 'existing-only';
58
+ export const POS_OPERATION_MODE_DEFAULT = POS_OPERATION_MODE_COUNTER;
59
+ export const POS_PRINT_MODE_ORDER = 'order';
60
+ export const POS_PRINT_MODE_FORM = 'form';
61
+ export const POS_PRINT_MODE_DEFAULT = POS_PRINT_MODE_ORDER;
62
+ export const POS_CASH_MANAGEMENT_MODE_CASH_REGISTER = 'cash-register';
63
+ export const POS_CASH_MANAGEMENT_MODE_DAILY = 'daily';
64
+ export const POS_CASH_MANAGEMENT_MODE_DEFAULT =
65
+ POS_CASH_MANAGEMENT_MODE_CASH_REGISTER;
66
+ export const POS_OPERATION_MODE_OPTIONS = [
67
+ {
68
+ value: POS_OPERATION_MODE_COUNTER,
69
+ translationKey: 'counterService',
70
+ descriptionKey: 'counterServiceDescription',
71
+ },
72
+ {
73
+ value: POS_OPERATION_MODE_WAITER,
74
+ translationKey: 'waiterService',
75
+ descriptionKey: 'waiterServiceDescription',
76
+ },
77
+ {
78
+ value: POS_OPERATION_MODE_TOTEM,
79
+ translationKey: 'selfServiceKiosk',
80
+ descriptionKey: 'selfServiceKioskDescription',
81
+ },
82
+ {
83
+ value: POS_OPERATION_MODE_SINGLE_ITEM,
84
+ translationKey: 'singleItemSale',
85
+ descriptionKey: 'singleItemSaleDescription',
86
+ },
87
+ {
88
+ value: POS_OPERATION_MODE_CASHIER,
89
+ translationKey: 'cashierPOS',
90
+ descriptionKey: 'cashierPOSDescription',
91
+ },
92
+ ];
93
+
94
+ export const DEFAULT_DEVICE_CONFIGS = {
95
+ 'pos-type': 'full',
96
+ 'print-mode': 'order',
97
+ 'check-type': 'manual',
98
+ 'product-input-type': 'manual',
99
+ 'selection-type': 'single',
100
+ sound: '0',
101
+ vibration: '0',
102
+ [DEVICE_ORDER_VISIBILITY_KEY]: DEVICE_ORDER_VISIBILITY_DEVICE,
103
+ [POS_DELIVERY_ENABLED_CONFIG_KEY]: '1',
104
+ [DEVICE_ALERT_SOUND_ENABLED_KEY]: '0',
105
+ [DEVICE_ALERT_SOUND_URL_KEY]: '',
106
+ [DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY]: '0',
107
+ [DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '0',
108
+ [DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY]: '0',
109
+ [DISPLAY_SIZE_CONFIG_KEY]: String(DISPLAY_SIZE_DEFAULT),
110
+ [DISPLAY_SIDE_BREAK_CONFIG_KEY]: '0',
111
+ [POS_CHECK_ORDER_TYPE_CONFIG_KEY]: POS_CHECK_ORDER_TYPE_NONE,
112
+ [POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY]:
113
+ POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
114
+ [POS_OPERATION_MODE_CONFIG_KEY]: POS_OPERATION_MODE_DEFAULT,
115
+ [POS_PRODUCT_SHOWCASE_CONFIG_KEY]: '',
116
+ [POS_AUTO_PRINT_ENABLED_CONFIG_KEY]: '0',
117
+ [POS_CASH_MANAGEMENT_MODE_CONFIG_KEY]: POS_CASH_MANAGEMENT_MODE_DEFAULT,
118
+ };
119
+
120
+ export const isTruthyValue = value =>
121
+ value === true || value === '1' || value === 1 || value === 'true';
122
+
123
+ export const isMissingConfigValue = value =>
124
+ value === undefined || value === null || value === '';
125
+
126
+ export const parseConfigsObject = configs => {
127
+ if (!configs) return {};
128
+
129
+ if (typeof configs === 'string') {
130
+ try {
131
+ const parsed = JSON.parse(configs);
132
+ return parsed && typeof parsed === 'object' ? parsed : {};
133
+ } catch {
134
+ return {};
135
+ }
136
+ }
137
+
138
+ return typeof configs === 'object' ? {...configs} : {};
139
+ };
140
+
141
+ export const normalizeDisplaySize = value => {
142
+ const normalizedValue = String(value ?? '').trim();
143
+
144
+ if (normalizedValue === '') {
145
+ return DISPLAY_SIZE_DEFAULT;
146
+ }
147
+
148
+ const numericValue = Number(normalizedValue);
149
+
150
+ if (!Number.isFinite(numericValue)) {
151
+ return DISPLAY_SIZE_DEFAULT;
152
+ }
153
+
154
+ return Math.min(
155
+ DISPLAY_SIZE_MAX,
156
+ Math.max(DISPLAY_SIZE_MIN, Math.round(numericValue)),
157
+ );
158
+ };
159
+
160
+ export const resolveDisplaySize = configs =>
161
+ normalizeDisplaySize(
162
+ parseConfigsObject(configs)?.[DISPLAY_SIZE_CONFIG_KEY],
163
+ );
164
+
165
+ export const isDisplaySideBreakEnabled = configs =>
166
+ isTruthyValue(
167
+ parseConfigsObject(configs)?.[DISPLAY_SIDE_BREAK_CONFIG_KEY],
168
+ );
169
+
170
+ export const normalizePosOperationMode = value => {
171
+ const normalizedValue = String(value || '')
172
+ .trim()
173
+ .toLowerCase()
174
+ .normalize('NFD')
175
+ .replace(/[\u0300-\u036f]/g, '')
176
+ .replace(/[\s_]/g, '-');
177
+
178
+ if (
179
+ [
180
+ POS_OPERATION_MODE_COUNTER,
181
+ 'balcao',
182
+ 'counter-service',
183
+ 'front-counter',
184
+ ].includes(normalizedValue)
185
+ ) {
186
+ return POS_OPERATION_MODE_COUNTER;
187
+ }
188
+
189
+ if (
190
+ [
191
+ POS_OPERATION_MODE_WAITER,
192
+ 'garcon',
193
+ 'garcom',
194
+ 'table-service',
195
+ ].includes(normalizedValue)
196
+ ) {
197
+ return POS_OPERATION_MODE_WAITER;
198
+ }
199
+
200
+ if (
201
+ [
202
+ POS_OPERATION_MODE_TOTEM,
203
+ ].includes(normalizedValue)
204
+ ) {
205
+ return POS_OPERATION_MODE_TOTEM;
206
+ }
207
+
208
+ if (
209
+ [
210
+ POS_OPERATION_MODE_SINGLE_ITEM,
211
+ 'single-sale',
212
+ 'single-item-sale',
213
+ 'sale-unit',
214
+ 'sale-single',
215
+ 'venda-unitaria',
216
+ 'venda-unica',
217
+ 'item-unico',
218
+ 'unit-sale',
219
+ 'unitary-sale',
220
+ ].includes(normalizedValue)
221
+ ) {
222
+ return POS_OPERATION_MODE_SINGLE_ITEM;
223
+ }
224
+
225
+ if (
226
+ [
227
+ POS_OPERATION_MODE_CASHIER,
228
+ 'pdv',
229
+ 'pos',
230
+ 'checkout',
231
+ 'cashier-pos',
232
+ ].includes(normalizedValue)
233
+ ) {
234
+ return POS_OPERATION_MODE_CASHIER;
235
+ }
236
+
237
+ return '';
238
+ };
@@ -0,0 +1,32 @@
1
+ import React, {useRef, useState} from 'react';
2
+ import {Text, View} from 'react-native';
3
+ import {ORDER_CHARGE_ENABLED_CONFIG_KEY, isOrderChargeEnabled} from '../../../config/deviceConfigBootstrap';
4
+ import styles from '../../DeviceDetailPage.styles';
5
+
6
+ export default function DeviceChargePermissionSection({configs, actionsRef, currentCompany,
7
+ deviceString, deviceType, refreshCurrentConfig, showSystemError, renderSwitchRow, brandColors}) {
8
+ const [saving, setSaving] = useState(false);
9
+ const pending = useRef(false);
10
+ async function save(value) {
11
+ if (pending.current || !currentCompany?.id || !deviceString) return;
12
+ pending.current = true;
13
+ setSaving(true);
14
+ try {
15
+ await actionsRef.current.deviceConfigActions.addDeviceConfigs({device: deviceString,
16
+ people: `/people/${currentCompany.id}`, type: deviceType,
17
+ configs: JSON.stringify({[ORDER_CHARGE_ENABLED_CONFIG_KEY]: value})});
18
+ await refreshCurrentConfig();
19
+ } catch (error) {
20
+ showSystemError(error, 'Não foi possível salvar a permissão de cobrança.');
21
+ } finally {pending.current = false; setSaving(false);}
22
+ }
23
+ const enabled = isOrderChargeEnabled(configs);
24
+ return <View style={styles.configCard}>
25
+ {renderSwitchRow({label: 'Permitir cobrança neste device', value: enabled,
26
+ valueLabel: enabled ? 'Permitida' : 'Desabilitada',
27
+ disabled: saving || !deviceString || !currentCompany?.id, onValueChange: save})}
28
+ <Text style={[styles.deviceString, {color: brandColors.textSecondary}]}>
29
+ A cobrança usa os meios de pagamento e o destino configurados. O sistema valida a autorização para receber aqui ou encaminhar a outro device.
30
+ </Text>
31
+ </View>;
32
+ }
@@ -1,29 +1,8 @@
1
1
  import React from 'react';
2
- import { Text, View, Switch, TextInput, TouchableOpacity, Platform } from 'react-native';
2
+ import { Text, View, TextInput, TouchableOpacity } from 'react-native';
3
3
  import { Picker } from '@react-native-picker/picker';
4
4
  import Icon from 'react-native-vector-icons/Feather';
5
5
  import styles from '../../DeviceDetailPage.styles';
6
- import {
7
- POS_OPERATION_MODE_OPTIONS,
8
- POS_OPERATION_MODE_COUNTER,
9
- POS_PRINT_MODE_ORDER,
10
- POS_PRINT_MODE_FORM,
11
- POS_CHECK_ORDER_TYPE_NONE,
12
- POS_CHECK_ORDER_TYPE_TAB,
13
- POS_CHECK_ORDER_TYPE_TABLE,
14
- POS_CHECK_ORDER_TYPE_STAMP,
15
- POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
16
- POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
17
- POS_CASH_MANAGEMENT_MODE_CASH_REGISTER,
18
- POS_CASH_MANAGEMENT_MODE_DAILY,
19
- POS_OPERATION_MODE_CONFIG_KEY,
20
- DEVICE_ORDER_VISIBILITY_COMPANY,
21
- DEVICE_ORDER_VISIBILITY_DEVICE,
22
- resolvePosOperationMode,
23
- } from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
24
- import { normalizeEntityId } from '@controleonline/ui-common/src/react/utils/paymentDevices';
25
- import { getProductShowcaseLabel } from './deviceDetailHelpers';
26
- import { tt } from './deviceDetailConstants';
27
6
 
28
7
  /**
29
8
  * Extracted from DeviceDetailScreen for modularization (≤500 lines).
@@ -32,6 +11,8 @@ import { tt } from './deviceDetailConstants';
32
11
  export default function DeviceDetailAlertsCommandsSection(ctx) {
33
12
  const {
34
13
  themeColors, brandColors, palette,
14
+ shouldShowDeviceBehavior, shouldShowRemotePayment, shouldShowRemoteCommands,
15
+ deviceRuntimeDebugInfoEnabled, setDeviceRuntimeDebugInfoEnabled,
35
16
  renderHelpButton, renderOptionButtons, renderSwitchRow, renderProduct,
36
17
  posOperationMode, setPosOperationMode, savePosOperationMode, savingPosOperationMode,
37
18
  productShowcaseId, setProductShowcaseId, saveProductShowcaseConfig,
@@ -66,6 +47,7 @@ export default function DeviceDetailAlertsCommandsSection(ctx) {
66
47
 
67
48
  return (
68
49
  <>
50
+ {shouldShowDeviceBehavior && (
69
51
  <View style={styles.section}>
70
52
  <Text style={styles.sectionTitle}>
71
53
  <Icon name="volume-2" size={13} /> {' '}Aviso Sonoro
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
- import { Text, View, FlatList, TextInput } from 'react-native';
2
+ import { Text, View, FlatList, TextInput, TouchableOpacity } from 'react-native';
3
3
  import Icon from 'react-native-vector-icons/Feather';
4
4
  import Formatter from '@controleonline/ui-common/src/utils/formatter';
5
5
  import styles from '../../DeviceDetailPage.styles';
6
6
  import { hex } from './deviceDetailConstants';
7
+ import { paymentIcon } from './deviceDetailHelpers';
8
+ import { withOpacity } from '@controleonline/../../src/styles/branding';
9
+ import { inlineStyle_1301_61 } from '../../DeviceDetailPage.styles';
7
10
 
8
11
  /**
9
12
  * PDV movement tab sections.
@@ -12,7 +15,8 @@ import { hex } from './deviceDetailConstants';
12
15
  export default function DeviceDetailMovementSections(ctx) {
13
16
  const {
14
17
  showPdvMovementTab, inflowData, productTotal, wallets, filteredProducts, search, setSearch,
15
- renderProduct, loadingMovementData,
18
+ renderProduct, loadingMovementData, inflowTotal, products, isOpen,
19
+ actionLoading, handleToggle, loadingConfigData, brandColors,
16
20
  } = ctx;
17
21
 
18
22
  return (