@controleonline/ui-common 1.2.80 → 1.2.81

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 (90) hide show
  1. package/AGENTS.md +8 -0
  2. package/package.json +9 -3
  3. package/src/api/fetch.js +7 -7
  4. package/src/react/components/AddImportModal.js +6 -2
  5. package/src/react/components/BackgroundRuntimeBridge.js +201 -215
  6. package/src/react/components/ConfirmModal.js +44 -9
  7. package/src/react/components/ConfirmModal.styles.js +55 -41
  8. package/src/react/components/CopyDeviceConfigModal.js +193 -0
  9. package/src/react/components/CopyDeviceConfigModal.styles.js +123 -0
  10. package/src/react/components/DefaultProvider.native.js +22 -0
  11. package/src/react/components/DefaultProvider.web.js +25 -1
  12. package/src/react/components/EntityLogBranch.js +482 -0
  13. package/src/react/components/EntityLogCards.js +369 -0
  14. package/src/react/components/EntityLogContent.js +113 -794
  15. package/src/react/components/LinkedOrderProductsTab.js +3 -3
  16. package/src/react/components/PrintService.js +130 -409
  17. package/src/react/components/RemoteCheckoutService.js +2 -2
  18. package/src/react/components/RuntimeBottomNavigationBar.js +141 -146
  19. package/src/react/components/RuntimeFooterMarqueeText.js +137 -0
  20. package/src/react/components/RuntimeInfoFooter.js +12 -15
  21. package/src/react/components/SystemErrorToast.js +49 -29
  22. package/src/react/components/SystemErrorToast.styles.js +43 -38
  23. package/src/react/components/UserAvatar.js +120 -28
  24. package/src/react/config/deviceConfigBootstrap.js +330 -304
  25. package/src/react/hooks/usePrintSpoolEffects.js +161 -0
  26. package/src/react/pages/DeviceDetailPage.js +6 -2882
  27. package/src/react/pages/Devices/detail/DeviceDetailAlertsCommandsSection.js +233 -0
  28. package/src/react/pages/Devices/detail/DeviceDetailHeader.js +138 -0
  29. package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +167 -0
  30. package/src/react/pages/Devices/detail/DeviceDetailOrdersPrintSection.js +216 -0
  31. package/src/react/pages/Devices/detail/DeviceDetailPaymentSection.js +40 -0
  32. package/src/react/pages/Devices/detail/DeviceDetailPdvConfigSection.js +390 -0
  33. package/src/react/pages/Devices/detail/DeviceDetailRenderers.js +135 -0
  34. package/src/react/pages/Devices/detail/DeviceDetailScreen.js +493 -0
  35. package/src/react/pages/Devices/detail/OptionButtonChip.js +65 -0
  36. package/src/react/pages/Devices/detail/deviceDetailConstants.js +36 -0
  37. package/src/react/pages/Devices/detail/deviceDetailHelpers.js +70 -0
  38. package/src/react/pages/Devices/detail/useDeviceDetailActions.js +483 -0
  39. package/src/react/pages/Devices/detail/useDeviceDetailCopyConfig.js +87 -0
  40. package/src/react/pages/Devices/detail/useDeviceDetailLoaders.js +327 -0
  41. package/src/react/pages/Devices/detail/useDeviceDetailSaves.js +429 -0
  42. package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +484 -0
  43. package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +71 -0
  44. package/src/react/pages/Devices/deviceTypes/index.js +2 -0
  45. package/src/react/pages/Devices/deviceTypes/pdv.js +11 -0
  46. package/src/react/pages/Imports.js +3 -2
  47. package/src/react/pages/IntegrationConfigFields.js +126 -0
  48. package/src/react/pages/IntegrationConfigPage.js +122 -591
  49. package/src/react/pages/IntegrationConfigPage.utils.js +95 -0
  50. package/src/react/print/usePrintButtonController.js +9 -1
  51. package/src/react/services/Getnet/Checkout.js +81 -0
  52. package/src/react/services/Getnet/Getnet.js +77 -0
  53. package/src/react/services/paymentGatewayExecution.js +20 -0
  54. package/src/react/utils/bottomNavigationToolbar.js +161 -0
  55. package/src/react/utils/commercialDocumentOrders.js +18 -6
  56. package/src/react/utils/copyDeviceConfigs.js +198 -0
  57. package/src/react/utils/fileUrl.js +43 -0
  58. package/src/react/utils/importStatus.js +19 -10
  59. package/src/react/utils/logSettings.js +7 -7
  60. package/src/react/utils/maintenanceSettings.js +16 -0
  61. package/src/react/utils/paymentDevices.js +6 -0
  62. package/src/react/utils/printManagedPrinter.js +45 -0
  63. package/src/react/utils/printRouting.js +63 -0
  64. package/src/react/utils/printSpoolUtils.js +119 -0
  65. package/src/react/utils/printerDevices.js +368 -368
  66. package/src/react/utils/runtimeFooter.js +10 -19
  67. package/src/react/utils/shopFranchises.js +186 -65
  68. package/src/react/utils/systemErrorMessage.js +71 -67
  69. package/src/store/device_config/customActions.js +119 -30
  70. package/src/tests/browser/manager/bottom-navigation-role-toolbar.spec.js +353 -0
  71. package/src/tests/browser/manager/device-detail-alias-save.spec.js +345 -0
  72. package/src/tests/browser/manager/device-detail-copy-config.spec.js +365 -0
  73. package/src/tests/browser/manager/runtime-footer-marquee.spec.js +262 -0
  74. package/src/tests/browser/manager/theme-confirm-toast.spec.js +236 -0
  75. package/src/tests/react/components/RuntimeFooterMarqueeText.test.js +171 -0
  76. package/src/tests/react/components/UserAvatar.test.js +6 -2
  77. package/src/tests/react/components/themeAwareModals.test.mjs +60 -0
  78. package/src/tests/react/config/deviceConfigBootstrap.test.js +104 -66
  79. package/src/tests/react/pages/deviceDetailDelete.test.js +78 -0
  80. package/src/tests/react/pages/receitaFederalIntegrationContract.test.mjs +48 -0
  81. package/src/tests/react/utils/bottomNavigationToolbar.test.js +222 -0
  82. package/src/tests/react/utils/copyDeviceConfigs.test.mjs +127 -0
  83. package/src/tests/react/utils/fileUrl.test.js +38 -0
  84. package/src/tests/react/utils/importStatus.test.js +26 -9
  85. package/src/tests/react/utils/passwordPolicy.test.js +27 -0
  86. package/src/tests/react/utils/printRouting.test.mjs +86 -0
  87. package/src/tests/react/utils/printSpoolUtils.test.mjs +52 -0
  88. package/src/tests/react/utils/runtimeFooter.test.js +7 -0
  89. package/src/tests/react/utils/shopFranchises.test.js +121 -115
  90. package/src/tests/react/utils/systemErrorMessage.test.js +32 -59
@@ -0,0 +1,484 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useNavigation, useRoute } from '@react-navigation/native';
3
+ import { useStore } from '@store';
4
+ import { useMessage } from '@controleonline/ui-common/src/react/components/MessageService';
5
+ import { resolveThemePalette } from '@controleonline/../../src/styles/branding';
6
+ import { colors } from '@controleonline/../../src/styles/colors';
7
+ import packageJson from '@package';
8
+ import {
9
+ canDisplayChangePrinter, DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY, DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY,
10
+ DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY, DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY, DEVICE_ALERT_SOUND_ENABLED_KEY,
11
+ DEVICE_ALERT_SOUND_URL_KEY, DEVICE_ORDER_VISIBILITY_COMPANY, DEVICE_ORDER_VISIBILITY_DEVICE, DEVICE_ORDER_VISIBILITY_KEY,
12
+ DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY, isPosAutoPrintEnabled, isPosCashRegisterOpen, isTruthyValue, parseConfigsObject,
13
+ POS_AUTO_PRINT_ENABLED_CONFIG_KEY, POS_CASH_MANAGEMENT_MODE_CASH_REGISTER, POS_CASH_MANAGEMENT_MODE_CONFIG_KEY,
14
+ POS_CASH_MANAGEMENT_MODE_DAILY, POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY, POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
15
+ POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE, POS_CHECK_ORDER_TYPE_CONFIG_KEY, POS_CHECK_ORDER_TYPE_NONE, POS_CHECK_ORDER_TYPE_TAB,
16
+ POS_CHECK_ORDER_TYPE_TABLE, POS_CHECK_ORDER_TYPE_STAMP, POS_DELIVERY_ENABLED_CONFIG_KEY, POS_OPERATION_MODE_COUNTER,
17
+ POS_OPERATION_MODE_CONFIG_KEY, POS_OPERATION_MODE_OPTIONS, POS_PRODUCT_SHOWCASE_CONFIG_KEY, POS_PRINT_MODE_FORM,
18
+ POS_PRINT_MODE_ORDER, getPosOperationModeOption, isAndroidKioskEnabled, isAndroidLauncherEnabled, isPosDeliveryEnabled,
19
+ resolvePosCheckOrderManagementMode, resolvePosCheckOrderType, resolvePosCheckOrderTypeForShop, resolveDeviceOrderVisibility,
20
+ resolvePosCashManagementMode, resolvePosOperationMode, resolvePosPrintMode,
21
+ } from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
22
+ import {
23
+ filterDeviceConfigsByCompany, getCompanyPaymentDeviceOptions, getPaymentGatewayFromConfigs, getPaymentGatewayLabel,
24
+ isPaymentCapableDeviceConfig, isPdvPrinterEnabled, normalizeDeviceId, normalizeEntityId, PAYMENT_TYPE_IDS_CONFIG_KEY,
25
+ PAYMENT_GATEWAY_CIELO, PDV_PRINTER_ENABLED_CONFIG_KEY, ORDER_PAYMENT_DEVICE_CONFIG_KEY, POS_GATEWAY_CONFIG_KEY,
26
+ } from '@controleonline/ui-common/src/react/utils/paymentDevices';
27
+ import { normalizeBooleanConfig, SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY } from '@controleonline/ui-common/src/react/utils/shopConfig';
28
+ import { getPrinterOptionValue, getDeviceTypeLabel, getPrinterLabel, getPrinterOptions } from '@controleonline/ui-common/src/react/utils/printerDevices';
29
+ import { hex, DISPLAY_DEVICE_TYPE, PDV_DEVICE_TYPE, DISPLAY_DEVICE_LINK_CONFIG_KEY, DISPLAY_DEVICE_PRINTER_CONFIG_KEY,
30
+ PDV_TAB_OPERATION, PDV_TAB_ORDERS, PDV_TAB_DEVICE, PDV_TAB_PAYMENT_TYPES, PDV_TAB_MOVEMENT, PDV_DETAIL_TABS, tt,
31
+ } from './deviceDetailConstants';
32
+ import { paymentIcon, formatApiError, getDisplayLabel, getProductShowcaseLabel, getIsOpen, confirm } from './deviceDetailHelpers';
33
+ import { api } from '@controleonline/ui-common/src/api';
34
+ import { buildDeviceAliasStoreUpdates } from '@controleonline/ui-common/src/react/utils/deviceAliasSync';
35
+ import { createDeviceDetailRenderers } from './DeviceDetailRenderers';
36
+ import { Alert, Platform } from 'react-native';
37
+
38
+
39
+ export default function useDeviceDetailStateA() {
40
+ const route = useRoute();
41
+ const navigation = useNavigation();
42
+ const {
43
+ deviceId: routeDeviceId,
44
+ } = route.params || {};
45
+ const deviceId = useMemo(
46
+ () => normalizeEntityId(routeDeviceId),
47
+ [routeDeviceId],
48
+ );
49
+
50
+ const invoiceStore = useStore('invoice');
51
+ const deviceConfigStore = useStore('device_config');
52
+ const deviceStore = useStore('device');
53
+ const displayStore = useStore('displays');
54
+ const peopleStore = useStore('people');
55
+ const printerStore = useStore('printer');
56
+ const themeStore = useStore('theme');
57
+ const websocketStore = useStore('websocket');
58
+ const messageApi = useMessage() || {};
59
+
60
+ const { currentCompany } = peopleStore.getters;
61
+ const { item: runtimeDevice } = deviceStore.getters;
62
+ const { item: runtimeDeviceConfig } = deviceConfigStore.getters;
63
+ const { items: displays = [], isLoading: isLoadingDisplays } = displayStore.getters;
64
+ const { items: printers = [], isLoading: isLoadingPrinters } = printerStore.getters;
65
+ const { colors: themeColors } = themeStore.getters;
66
+ const websocketActions = websocketStore.actions;
67
+ const runtimeCompanyConfigs = useMemo(
68
+ () => parseConfigsObject(currentCompany?.configs),
69
+ [currentCompany?.configs],
70
+ );
71
+ const showSystemError = useCallback(
72
+ (error, fallback) => {
73
+ messageApi.showError?.(formatApiError(error, fallback));
74
+ },
75
+ [messageApi],
76
+ );
77
+ const loyaltyCouponsEnabled = useMemo(
78
+ () => {
79
+ const hasLoyaltyCouponsEnabledKey = Object.prototype.hasOwnProperty.call(
80
+ runtimeCompanyConfigs || {},
81
+ SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
82
+ );
83
+
84
+ return hasLoyaltyCouponsEnabledKey
85
+ ? normalizeBooleanConfig(
86
+ runtimeCompanyConfigs?.[SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY],
87
+ )
88
+ : true;
89
+ },
90
+ [runtimeCompanyConfigs],
91
+ );
92
+
93
+ const currentDevice =
94
+ deviceId &&
95
+ normalizeEntityId(runtimeDevice?.id || runtimeDevice?.['@id']) === deviceId
96
+ ? runtimeDevice
97
+ : {};
98
+ const currentDeviceConfig =
99
+ deviceId &&
100
+ normalizeEntityId(
101
+ runtimeDeviceConfig?.device?.id ||
102
+ runtimeDeviceConfig?.device?.['@id'] ||
103
+ runtimeDeviceConfig?.deviceId ||
104
+ runtimeDeviceConfig?.device?.deviceId,
105
+ ) === deviceId
106
+ ? runtimeDeviceConfig
107
+ : {};
108
+ const deviceString = String(
109
+ currentDevice?.device || currentDeviceConfig?.device?.device || '',
110
+ ).trim();
111
+ const deviceType = String(
112
+ currentDevice?.type ||
113
+ currentDevice?.deviceType ||
114
+ currentDeviceConfig?.type ||
115
+ currentDeviceConfig?.device?.type ||
116
+ '',
117
+ )
118
+ .trim()
119
+ .toUpperCase();
120
+ const normalizedInitialConfigs = useMemo(
121
+ () => parseConfigsObject(currentDeviceConfig?.configs),
122
+ [currentDeviceConfig?.configs],
123
+ );
124
+ const initialAlias = String(
125
+ currentDevice?.alias || currentDeviceConfig?.device?.alias || currentDevice?.device || '',
126
+ ).trim();
127
+ const isDisplayDevice = deviceType === DISPLAY_DEVICE_TYPE;
128
+ const isPdvDevice = deviceType === PDV_DEVICE_TYPE;
129
+
130
+ const actionsRef = useRef({});
131
+ const stampAutoDisableSignatureRef = useRef('');
132
+ actionsRef.current = {
133
+ invoiceActions: invoiceStore.actions,
134
+ deviceConfigActions: deviceConfigStore.actions,
135
+ deviceActions: deviceStore.actions,
136
+ };
137
+
138
+ const brandColors = useMemo(
139
+ () => resolveThemePalette({ ...themeColors, ...(currentCompany?.theme?.colors || {}) }, colors),
140
+ [themeColors, currentCompany?.id],
141
+ );
142
+
143
+ const [products, setProducts] = useState([]);
144
+ const [productShowcases, setProductShowcases] = useState([]);
145
+ const [companyDeviceConfigs, setCompanyDeviceConfigs] = useState([]);
146
+ const [inflowData, setInflowData] = useState(null);
147
+ const [configs, setConfigs] = useState(normalizedInitialConfigs || {});
148
+ const [loadingConfigData, setLoadingConfigData] = useState(false);
149
+ const [loadingCompanyDeviceConfigs, setLoadingCompanyDeviceConfigs] =
150
+ useState(false);
151
+ const [loadingMovementData, setLoadingMovementData] = useState(false);
152
+ const [actionLoading, setActionLoading] = useState(false);
153
+ const [activePdvTab, setActivePdvTab] = useState(PDV_TAB_OPERATION);
154
+ const [savingPaymentTarget, setSavingPaymentTarget] = useState(false);
155
+ const [savingPdvSettings, setSavingPdvSettings] = useState(false);
156
+ const [savingPaymentTypes, setSavingPaymentTypes] = useState(false);
157
+ const [savingPosOperationMode, setSavingPosOperationMode] = useState(false);
158
+ const [savingProductShowcase, setSavingProductShowcase] = useState(false);
159
+ const [savingLauncherMode, setSavingLauncherMode] = useState(false);
160
+ const [savingAlertSound, setSavingAlertSound] = useState(false);
161
+ const [savingOrderVisibility, setSavingOrderVisibility] = useState(false);
162
+ const [savingDeviceDeliverySettings, setSavingDeviceDeliverySettings] =
163
+ useState(false);
164
+ const [savingRuntimeDebugInfo, setSavingRuntimeDebugInfo] = useState(false);
165
+ const [sendingCatalogRefresh, setSendingCatalogRefresh] = useState(false);
166
+ const [loadingProductShowcases, setLoadingProductShowcases] = useState(false);
167
+ const [search, setSearch] = useState('');
168
+ const [devicePaymentTarget, setDevicePaymentTarget] = useState(
169
+ normalizeDeviceId(normalizedInitialConfigs?.[ORDER_PAYMENT_DEVICE_CONFIG_KEY]),
170
+ );
171
+ const [pdvGateway, setPdvGateway] = useState(
172
+ getPaymentGatewayFromConfigs(normalizedInitialConfigs),
173
+ );
174
+ const [pdvPrinterEnabled, setPdvPrinterEnabled] = useState(
175
+ isPdvPrinterEnabled(normalizedInitialConfigs),
176
+ );
177
+ const [posOperationMode, setPosOperationMode] = useState(
178
+ resolvePosOperationMode(normalizedInitialConfigs),
179
+ );
180
+ const [productShowcaseId, setProductShowcaseId] = useState(
181
+ normalizeEntityId(normalizedInitialConfigs?.[POS_PRODUCT_SHOWCASE_CONFIG_KEY]),
182
+ );
183
+ const [androidKioskEnabled, setAndroidKioskEnabled] = useState(
184
+ isAndroidKioskEnabled(normalizedInitialConfigs),
185
+ );
186
+ const [androidLauncherEnabled, setAndroidLauncherEnabled] = useState(
187
+ isAndroidLauncherEnabled(normalizedInitialConfigs),
188
+ );
189
+ const [counterAutoPrintEnabled, setCounterAutoPrintEnabled] = useState(
190
+ isPosAutoPrintEnabled(normalizedInitialConfigs),
191
+ );
192
+ const [counterPrintMode, setCounterPrintMode] = useState(
193
+ resolvePosPrintMode(normalizedInitialConfigs),
194
+ );
195
+ const [counterCashManagementMode, setCounterCashManagementMode] = useState(
196
+ resolvePosCashManagementMode(normalizedInitialConfigs),
197
+ );
198
+ const [checkOrderType, setCheckOrderType] = useState(
199
+ resolvePosCheckOrderTypeForShop(
200
+ normalizedInitialConfigs,
201
+ runtimeCompanyConfigs,
202
+ ),
203
+ );
204
+ const [checkOrderManagementMode, setCheckOrderManagementMode] = useState(
205
+ resolvePosCheckOrderManagementMode(normalizedInitialConfigs),
206
+ );
207
+ const [deviceOrderVisibility, setDeviceOrderVisibility] = useState(
208
+ resolveDeviceOrderVisibility(normalizedInitialConfigs),
209
+ );
210
+ const [deviceDeliveryEnabled, setDeviceDeliveryEnabled] = useState(
211
+ isPosDeliveryEnabled(normalizedInitialConfigs),
212
+ );
213
+ const [deviceAlertSoundEnabled, setDeviceAlertSoundEnabled] = useState(
214
+ isTruthyValue(normalizedInitialConfigs?.[DEVICE_ALERT_SOUND_ENABLED_KEY]),
215
+ );
216
+ const [deviceAlertSoundUrl, setDeviceAlertSoundUrl] = useState(
217
+ String(normalizedInitialConfigs?.[DEVICE_ALERT_SOUND_URL_KEY] || ''),
218
+ );
219
+ const [deviceRuntimeDebugInfoEnabled, setDeviceRuntimeDebugInfoEnabled] =
220
+ useState(
221
+ isTruthyValue(
222
+ normalizedInitialConfigs?.[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY],
223
+ ),
224
+ );
225
+ const [linkedDisplayId, setLinkedDisplayId] = useState(
226
+ normalizeEntityId(normalizedInitialConfigs?.[DISPLAY_DEVICE_LINK_CONFIG_KEY]),
227
+ );
228
+ const [displayPrinterId, setDisplayPrinterId] = useState(
229
+ normalizeDeviceId(normalizedInitialConfigs?.[DISPLAY_DEVICE_PRINTER_CONFIG_KEY]),
230
+ );
231
+ const [displayAllowPrinterChange, setDisplayAllowPrinterChange] = useState(
232
+ canDisplayChangePrinter(normalizedInitialConfigs),
233
+ );
234
+ const [displayAutoPrintProductEnabled, setDisplayAutoPrintProductEnabled] =
235
+ useState(
236
+ isTruthyValue(
237
+ normalizedInitialConfigs?.[DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY],
238
+ ),
239
+ );
240
+ const [savingDisplayPrintingConfig, setSavingDisplayPrintingConfig] = useState(false);
241
+ const [hasLoadedCurrentConfig, setHasLoadedCurrentConfig] = useState(false);
242
+ const [hasLoadedCompanyConfigs, setHasLoadedCompanyConfigs] = useState(false);
243
+ const [hasLoadedMovementData, setHasLoadedMovementData] = useState(false);
244
+ const hasLoadedCurrentConfigRef = useRef(false);
245
+ const hasLoadedCompanyConfigsRef = useRef(false);
246
+ const hasLoadedMovementDataRef = useRef(false);
247
+ const hasInitializedPdvTabRef = useRef(false);
248
+
249
+ // Edição inline do alias
250
+ const [alias, setAlias] = useState(initialAlias || '');
251
+ const [editingAlias, setEditingAlias] = useState(false);
252
+ const [aliasInput, setAliasInput] = useState(alias);
253
+ const [savingAlias, setSavingAlias] = useState(false);
254
+ const [removingDevice, setRemovingDevice] = useState(false);
255
+ const aliasInputRef = useRef(null);
256
+ const skipAliasSyncFromStoreRef = useRef(false);
257
+
258
+ useEffect(() => {
259
+ if (editingAlias) {
260
+ return;
261
+ }
262
+
263
+ if (skipAliasSyncFromStoreRef.current) {
264
+ skipAliasSyncFromStoreRef.current = false;
265
+ return;
266
+ }
267
+
268
+ setAlias(initialAlias || '');
269
+ setAliasInput(initialAlias || '');
270
+ }, [editingAlias, initialAlias]);
271
+
272
+ useEffect(() => {
273
+ hasLoadedCurrentConfigRef.current = hasLoadedCurrentConfig;
274
+ }, [hasLoadedCurrentConfig]);
275
+
276
+ useEffect(() => {
277
+ hasLoadedCompanyConfigsRef.current = hasLoadedCompanyConfigs;
278
+ }, [hasLoadedCompanyConfigs]);
279
+
280
+ useEffect(() => {
281
+ hasLoadedMovementDataRef.current = hasLoadedMovementData;
282
+ }, [hasLoadedMovementData]);
283
+
284
+ const isOpen = useMemo(() => getIsOpen(configs), [configs]);
285
+ const hasLocalPaymentGateway = useMemo(
286
+ () =>
287
+ isPaymentCapableDeviceConfig({
288
+ configs,
289
+ type: deviceType,
290
+ device: {type: deviceType},
291
+ }),
292
+ [configs, deviceType],
293
+ );
294
+ const paymentDeviceOptions = useMemo(
295
+ () =>
296
+ getCompanyPaymentDeviceOptions(
297
+ filterDeviceConfigsByCompany(companyDeviceConfigs, currentCompany?.id),
298
+ ).filter(
299
+ option => option.deviceId !== deviceString,
300
+ ),
301
+ [companyDeviceConfigs, currentCompany?.id, deviceString],
302
+ );
303
+ const displayOptions = useMemo(
304
+ () =>
305
+ (Array.isArray(displays) ? displays : [])
306
+ .filter(option => {
307
+ const companyId = normalizeEntityId(option?.company?.id || option?.company);
308
+ const currentCompanyId = normalizeEntityId(currentCompany?.id);
309
+ return !currentCompanyId || !companyId || companyId === currentCompanyId;
310
+ })
311
+ .sort((left, right) =>
312
+ String(left?.display || '').localeCompare(String(right?.display || '')),
313
+ ),
314
+ [currentCompany?.id, displays],
315
+ );
316
+ const printerOptions = useMemo(
317
+ () =>
318
+ getPrinterOptions({
319
+ printers,
320
+ deviceConfigs: companyDeviceConfigs,
321
+ companyId: currentCompany?.id,
322
+ }),
323
+ [companyDeviceConfigs, currentCompany?.id, printers],
324
+ );
325
+ const selectedPosOperationModeOption = useMemo(
326
+ () => getPosOperationModeOption(posOperationMode),
327
+ [posOperationMode],
328
+ );
329
+ const pickerMode = Platform.OS === 'android' ? 'dropdown' : undefined;
330
+ const packageVersion = packageJson?.version || packageJson?.default?.version;
331
+ const appVersion = packageVersion || runtimeDevice?.appVersion || '';
332
+ const runtimeDeviceId = useMemo(
333
+ () => normalizeDeviceId(runtimeDevice?.id || runtimeDevice?.device),
334
+ [runtimeDevice?.device, runtimeDevice?.id],
335
+ );
336
+ const runtimeDeviceType = useMemo(
337
+ () =>
338
+ String(runtimeDevice?.type || runtimeDevice?.deviceType || '')
339
+ .trim()
340
+ return {
341
+ navigation,
342
+ deviceId,
343
+ deviceConfigStore,
344
+ messageApi,
345
+ websocketActions,
346
+ runtimeCompanyConfigs,
347
+ showSystemError,
348
+ loyaltyCouponsEnabled,
349
+ currentDevice,
350
+ currentDeviceConfig,
351
+ deviceString,
352
+ deviceType,
353
+ normalizedInitialConfigs,
354
+ initialAlias,
355
+ isDisplayDevice,
356
+ isPdvDevice,
357
+ actionsRef,
358
+ stampAutoDisableSignatureRef,
359
+ brandColors,
360
+ products,
361
+ setProducts,
362
+ productShowcases,
363
+ setProductShowcases,
364
+ companyDeviceConfigs,
365
+ setCompanyDeviceConfigs,
366
+ inflowData,
367
+ setInflowData,
368
+ configs,
369
+ setConfigs,
370
+ loadingConfigData,
371
+ setLoadingConfigData,
372
+ loadingCompanyDeviceConfigs,
373
+ setLoadingCompanyDeviceConfigs,
374
+ loadingMovementData,
375
+ setLoadingMovementData,
376
+ actionLoading,
377
+ setActionLoading,
378
+ activePdvTab,
379
+ setActivePdvTab,
380
+ savingPaymentTarget,
381
+ setSavingPaymentTarget,
382
+ savingPdvSettings,
383
+ setSavingPdvSettings,
384
+ savingPaymentTypes,
385
+ setSavingPaymentTypes,
386
+ savingPosOperationMode,
387
+ setSavingPosOperationMode,
388
+ savingProductShowcase,
389
+ setSavingProductShowcase,
390
+ savingLauncherMode,
391
+ setSavingLauncherMode,
392
+ savingAlertSound,
393
+ setSavingAlertSound,
394
+ savingOrderVisibility,
395
+ setSavingOrderVisibility,
396
+ savingDeviceDeliverySettings,
397
+ setSavingDeviceDeliverySettings,
398
+ savingRuntimeDebugInfo,
399
+ setSavingRuntimeDebugInfo,
400
+ sendingCatalogRefresh,
401
+ setSendingCatalogRefresh,
402
+ loadingProductShowcases,
403
+ setLoadingProductShowcases,
404
+ search,
405
+ setSearch,
406
+ devicePaymentTarget,
407
+ setDevicePaymentTarget,
408
+ pdvGateway,
409
+ setPdvGateway,
410
+ pdvPrinterEnabled,
411
+ setPdvPrinterEnabled,
412
+ posOperationMode,
413
+ setPosOperationMode,
414
+ productShowcaseId,
415
+ setProductShowcaseId,
416
+ androidKioskEnabled,
417
+ setAndroidKioskEnabled,
418
+ androidLauncherEnabled,
419
+ setAndroidLauncherEnabled,
420
+ counterAutoPrintEnabled,
421
+ setCounterAutoPrintEnabled,
422
+ counterPrintMode,
423
+ setCounterPrintMode,
424
+ counterCashManagementMode,
425
+ setCounterCashManagementMode,
426
+ checkOrderType,
427
+ setCheckOrderType,
428
+ checkOrderManagementMode,
429
+ setCheckOrderManagementMode,
430
+ deviceOrderVisibility,
431
+ setDeviceOrderVisibility,
432
+ deviceDeliveryEnabled,
433
+ setDeviceDeliveryEnabled,
434
+ deviceAlertSoundEnabled,
435
+ setDeviceAlertSoundEnabled,
436
+ deviceAlertSoundUrl,
437
+ setDeviceAlertSoundUrl,
438
+ deviceRuntimeDebugInfoEnabled,
439
+ setDeviceRuntimeDebugInfoEnabled,
440
+ linkedDisplayId,
441
+ setLinkedDisplayId,
442
+ displayPrinterId,
443
+ setDisplayPrinterId,
444
+ displayAllowPrinterChange,
445
+ setDisplayAllowPrinterChange,
446
+ displayAutoPrintProductEnabled,
447
+ setDisplayAutoPrintProductEnabled,
448
+ savingDisplayPrintingConfig,
449
+ setSavingDisplayPrintingConfig,
450
+ hasLoadedCurrentConfig,
451
+ setHasLoadedCurrentConfig,
452
+ hasLoadedCompanyConfigs,
453
+ setHasLoadedCompanyConfigs,
454
+ hasLoadedMovementData,
455
+ setHasLoadedMovementData,
456
+ hasLoadedCurrentConfigRef,
457
+ hasLoadedCompanyConfigsRef,
458
+ hasLoadedMovementDataRef,
459
+ hasInitializedPdvTabRef,
460
+ alias,
461
+ setAlias,
462
+ editingAlias,
463
+ setEditingAlias,
464
+ aliasInput,
465
+ setAliasInput,
466
+ savingAlias,
467
+ setSavingAlias,
468
+ removingDevice,
469
+ setRemovingDevice,
470
+ aliasInputRef,
471
+ skipAliasSyncFromStoreRef,
472
+ isOpen,
473
+ hasLocalPaymentGateway,
474
+ paymentDeviceOptions,
475
+ displayOptions,
476
+ printerOptions,
477
+ selectedPosOperationModeOption,
478
+ pickerMode,
479
+ packageVersion,
480
+ appVersion,
481
+ runtimeDeviceId,
482
+ runtimeDeviceType,
483
+ };
484
+ }
@@ -0,0 +1,71 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useNavigation, useRoute } from '@react-navigation/native';
3
+ import { useStore } from '@store';
4
+ import { useMessage } from '@controleonline/ui-common/src/react/components/MessageService';
5
+ import { resolveThemePalette } from '@controleonline/../../src/styles/branding';
6
+ import { colors } from '@controleonline/../../src/styles/colors';
7
+ import packageJson from '@package';
8
+ import {
9
+ canDisplayChangePrinter, DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY, DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY,
10
+ DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY, DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY, DEVICE_ALERT_SOUND_ENABLED_KEY,
11
+ DEVICE_ALERT_SOUND_URL_KEY, DEVICE_ORDER_VISIBILITY_COMPANY, DEVICE_ORDER_VISIBILITY_DEVICE, DEVICE_ORDER_VISIBILITY_KEY,
12
+ DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY, isPosAutoPrintEnabled, isPosCashRegisterOpen, isTruthyValue, parseConfigsObject,
13
+ POS_AUTO_PRINT_ENABLED_CONFIG_KEY, POS_CASH_MANAGEMENT_MODE_CASH_REGISTER, POS_CASH_MANAGEMENT_MODE_CONFIG_KEY,
14
+ POS_CASH_MANAGEMENT_MODE_DAILY, POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY, POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
15
+ POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE, POS_CHECK_ORDER_TYPE_CONFIG_KEY, POS_CHECK_ORDER_TYPE_NONE, POS_CHECK_ORDER_TYPE_TAB,
16
+ POS_CHECK_ORDER_TYPE_TABLE, POS_CHECK_ORDER_TYPE_STAMP, POS_DELIVERY_ENABLED_CONFIG_KEY, POS_OPERATION_MODE_COUNTER,
17
+ POS_OPERATION_MODE_CONFIG_KEY, POS_OPERATION_MODE_OPTIONS, POS_PRODUCT_SHOWCASE_CONFIG_KEY, POS_PRINT_MODE_FORM,
18
+ POS_PRINT_MODE_ORDER, getPosOperationModeOption, isAndroidKioskEnabled, isAndroidLauncherEnabled, isPosDeliveryEnabled,
19
+ resolvePosCheckOrderManagementMode, resolvePosCheckOrderType, resolvePosCheckOrderTypeForShop, resolveDeviceOrderVisibility,
20
+ resolvePosCashManagementMode, resolvePosOperationMode, resolvePosPrintMode,
21
+ } from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
22
+ import {
23
+ filterDeviceConfigsByCompany, getCompanyPaymentDeviceOptions, getPaymentGatewayFromConfigs, getPaymentGatewayLabel,
24
+ isPaymentCapableDeviceConfig, isPdvPrinterEnabled, normalizeDeviceId, normalizeEntityId, PAYMENT_TYPE_IDS_CONFIG_KEY,
25
+ PAYMENT_GATEWAY_CIELO, PDV_PRINTER_ENABLED_CONFIG_KEY, ORDER_PAYMENT_DEVICE_CONFIG_KEY, POS_GATEWAY_CONFIG_KEY,
26
+ } from '@controleonline/ui-common/src/react/utils/paymentDevices';
27
+ import { normalizeBooleanConfig, SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY } from '@controleonline/ui-common/src/react/utils/shopConfig';
28
+ import { getPrinterOptionValue, getDeviceTypeLabel, getPrinterLabel, getPrinterOptions } from '@controleonline/ui-common/src/react/utils/printerDevices';
29
+ import { hex, DISPLAY_DEVICE_TYPE, PDV_DEVICE_TYPE, DISPLAY_DEVICE_LINK_CONFIG_KEY, DISPLAY_DEVICE_PRINTER_CONFIG_KEY,
30
+ PDV_TAB_OPERATION, PDV_TAB_ORDERS, PDV_TAB_DEVICE, PDV_TAB_PAYMENT_TYPES, PDV_TAB_MOVEMENT, PDV_DETAIL_TABS, tt,
31
+ } from './deviceDetailConstants';
32
+ import { paymentIcon, formatApiError, getDisplayLabel, getProductShowcaseLabel, getIsOpen, confirm } from './deviceDetailHelpers';
33
+ import { api } from '@controleonline/ui-common/src/api';
34
+ import { buildDeviceAliasStoreUpdates } from '@controleonline/ui-common/src/react/utils/deviceAliasSync';
35
+ import { createDeviceDetailRenderers } from './DeviceDetailRenderers';
36
+ import { Alert, Platform } from 'react-native';
37
+
38
+
39
+ export default function useDeviceDetailStateB(deps) {
40
+ const {
41
+ navigation, deviceId, deviceConfigStore, messageApi, websocketActions, runtimeCompanyConfigs, showSystemError, loyaltyCouponsEnabled, currentDevice, currentDeviceConfig, deviceString, deviceType,
42
+ normalizedInitialConfigs, initialAlias, isDisplayDevice, isPdvDevice, actionsRef, stampAutoDisableSignatureRef, brandColors, products, setProducts, productShowcases, setProductShowcases, companyDeviceConfigs,
43
+ setCompanyDeviceConfigs, inflowData, setInflowData, configs, setConfigs, loadingConfigData, setLoadingConfigData, loadingCompanyDeviceConfigs, setLoadingCompanyDeviceConfigs, loadingMovementData, setLoadingMovementData, actionLoading,
44
+ setActionLoading, activePdvTab, setActivePdvTab, savingPaymentTarget, setSavingPaymentTarget, savingPdvSettings, setSavingPdvSettings, savingPaymentTypes, setSavingPaymentTypes, savingPosOperationMode, setSavingPosOperationMode, savingProductShowcase,
45
+ setSavingProductShowcase, savingLauncherMode, setSavingLauncherMode, savingAlertSound, setSavingAlertSound, savingOrderVisibility, setSavingOrderVisibility, savingDeviceDeliverySettings, setSavingDeviceDeliverySettings, savingRuntimeDebugInfo, setSavingRuntimeDebugInfo, sendingCatalogRefresh,
46
+ setSendingCatalogRefresh, loadingProductShowcases, setLoadingProductShowcases, search, setSearch, devicePaymentTarget, setDevicePaymentTarget, pdvGateway, setPdvGateway, pdvPrinterEnabled, setPdvPrinterEnabled, posOperationMode,
47
+ setPosOperationMode, productShowcaseId, setProductShowcaseId, androidKioskEnabled, setAndroidKioskEnabled, androidLauncherEnabled, setAndroidLauncherEnabled, counterAutoPrintEnabled, setCounterAutoPrintEnabled, counterPrintMode, setCounterPrintMode, counterCashManagementMode,
48
+ setCounterCashManagementMode, checkOrderType, setCheckOrderType, checkOrderManagementMode, setCheckOrderManagementMode, deviceOrderVisibility, setDeviceOrderVisibility, deviceDeliveryEnabled, setDeviceDeliveryEnabled, deviceAlertSoundEnabled, setDeviceAlertSoundEnabled, deviceAlertSoundUrl,
49
+ setDeviceAlertSoundUrl, deviceRuntimeDebugInfoEnabled, setDeviceRuntimeDebugInfoEnabled, linkedDisplayId, setLinkedDisplayId, displayPrinterId, setDisplayPrinterId, displayAllowPrinterChange, setDisplayAllowPrinterChange, displayAutoPrintProductEnabled, setDisplayAutoPrintProductEnabled, savingDisplayPrintingConfig,
50
+ setSavingDisplayPrintingConfig, hasLoadedCurrentConfig, setHasLoadedCurrentConfig, hasLoadedCompanyConfigs, setHasLoadedCompanyConfigs, hasLoadedMovementData, setHasLoadedMovementData, hasLoadedCurrentConfigRef, hasLoadedCompanyConfigsRef, hasLoadedMovementDataRef, hasInitializedPdvTabRef, alias,
51
+ setAlias, editingAlias, setEditingAlias, aliasInput, setAliasInput, savingAlias, setSavingAlias, removingDevice, setRemovingDevice, aliasInputRef, skipAliasSyncFromStoreRef, isOpen,
52
+ hasLocalPaymentGateway, paymentDeviceOptions, displayOptions, printerOptions, selectedPosOperationModeOption, pickerMode, packageVersion, appVersion, runtimeDeviceId, runtimeDeviceType,
53
+ } = deps;
54
+ .toUpperCase(),
55
+ [runtimeDevice?.deviceType, runtimeDevice?.type],
56
+ );
57
+ const isEditingRuntimeDevice = useMemo(
58
+ () =>
59
+ !!runtimeDeviceId &&
60
+ runtimeDeviceId === normalizeDeviceId(deviceString) &&
61
+ runtimeDeviceType === deviceType,
62
+ [deviceString, deviceType, runtimeDeviceId, runtimeDeviceType],
63
+ );
64
+
65
+ const resolveDeviceContext = useCallback(async () => {
66
+ if (deviceString && deviceType) {
67
+ return {
68
+ isEditingRuntimeDevice,
69
+ resolveDeviceContext,
70
+ };
71
+ }
@@ -8,6 +8,7 @@ import pdvDeviceType, {
8
8
  PDV_SUBFILTER_KEYS,
9
9
  pdvCieloDeviceType,
10
10
  pdvInfinitePayDeviceType,
11
+ pdvGetnetDeviceType,
11
12
  } from './pdv';
12
13
  import printerDeviceType from './printer';
13
14
  import {createDeviceTypeTab} from './shared';
@@ -17,6 +18,7 @@ const registeredDeviceTypes = [
17
18
  pdvDeviceType,
18
19
  pdvCieloDeviceType,
19
20
  pdvInfinitePayDeviceType,
21
+ pdvGetnetDeviceType,
20
22
  displayDeviceType,
21
23
  printerDeviceType,
22
24
  ipCameraDeviceType,
@@ -3,6 +3,7 @@ import {
3
3
  getPaymentGateway,
4
4
  PAYMENT_GATEWAY_CIELO,
5
5
  PAYMENT_GATEWAY_INFINITE_PAY,
6
+ PAYMENT_GATEWAY_GETNET,
6
7
  } from '@controleonline/ui-common/src/react/utils/paymentDevices';
7
8
  import {createDeviceTypeTab} from './shared';
8
9
 
@@ -14,9 +15,11 @@ const emptyState = {
14
15
 
15
16
  export const PDV_CIELO_FILTER = 'PDV_CIELO';
16
17
  export const PDV_INFINITE_PAY_FILTER = 'PDV_INFINITE_PAY';
18
+ export const PDV_GETNET_FILTER = 'PDV_GETNET';
17
19
  export const PDV_SUBFILTER_KEYS = [
18
20
  PDV_CIELO_FILTER,
19
21
  PDV_INFINITE_PAY_FILTER,
22
+ PDV_GETNET_FILTER,
20
23
  ];
21
24
 
22
25
  const pdvDeviceType = {
@@ -85,4 +88,12 @@ export const pdvInfinitePayDeviceType = createPdvGatewayDeviceType({
85
88
  accentResolver: ({brandColors, hex}) => brandColors?.primary || hex.success,
86
89
  });
87
90
 
91
+ export const pdvGetnetDeviceType = createPdvGatewayDeviceType({
92
+ key: PDV_GETNET_FILTER,
93
+ label: 'Getnet',
94
+ gateway: PAYMENT_GATEWAY_GETNET,
95
+ title: 'Nenhum pdv Getnet encontrado',
96
+ accentResolver: ({brandColors, hex}) => brandColors?.primary || hex.info || hex.success,
97
+ });
98
+
88
99
  export default pdvDeviceType;
@@ -21,6 +21,7 @@ const {
21
21
  getImportErrorDetail,
22
22
  getImportStatusMeta,
23
23
  resolveImportLabels,
24
+ resolveImportTranslator,
24
25
  resolveImportStatusLabel: resolveImportStatusLabelValue,
25
26
  } = require('@controleonline/ui-common/src/react/utils/importStatus');
26
27
 
@@ -32,7 +33,7 @@ const formatDate = (dateString) => {
32
33
  const Imports = ({ context = {}, onClose }) => {
33
34
  const peopleStore = useStore('people');
34
35
  const themeStore = useStore('theme');
35
- const { getters: peopleGetters } = peopleStore.getters;
36
+ const peopleGetters = peopleStore.getters || {};
36
37
  const { currentCompany } = peopleGetters;
37
38
  const themeColors = themeStore?.getters?.colors || {};
38
39
  const buttonPalette = useMemo(
@@ -63,7 +64,7 @@ const Imports = ({ context = {}, onClose }) => {
63
64
  doneLabel,
64
65
  noStatusLabel,
65
66
  processingHelpLabel,
66
- } = resolveImportLabels(global.t?.t);
67
+ } = resolveImportLabels(resolveImportTranslator());
67
68
 
68
69
  const navigation = useNavigation();
69
70