@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.
- package/AGENTS.md +8 -0
- package/package.json +9 -3
- package/src/api/fetch.js +7 -7
- package/src/react/components/AddImportModal.js +6 -2
- package/src/react/components/BackgroundRuntimeBridge.js +201 -215
- package/src/react/components/ConfirmModal.js +44 -9
- package/src/react/components/ConfirmModal.styles.js +55 -41
- package/src/react/components/CopyDeviceConfigModal.js +193 -0
- package/src/react/components/CopyDeviceConfigModal.styles.js +123 -0
- package/src/react/components/DefaultProvider.native.js +22 -0
- package/src/react/components/DefaultProvider.web.js +25 -1
- package/src/react/components/EntityLogBranch.js +482 -0
- package/src/react/components/EntityLogCards.js +369 -0
- package/src/react/components/EntityLogContent.js +113 -794
- package/src/react/components/LinkedOrderProductsTab.js +3 -3
- package/src/react/components/PrintService.js +130 -409
- package/src/react/components/RemoteCheckoutService.js +2 -2
- package/src/react/components/RuntimeBottomNavigationBar.js +141 -146
- package/src/react/components/RuntimeFooterMarqueeText.js +137 -0
- package/src/react/components/RuntimeInfoFooter.js +12 -15
- package/src/react/components/SystemErrorToast.js +49 -29
- package/src/react/components/SystemErrorToast.styles.js +43 -38
- package/src/react/components/UserAvatar.js +120 -28
- package/src/react/config/deviceConfigBootstrap.js +330 -304
- package/src/react/hooks/usePrintSpoolEffects.js +161 -0
- package/src/react/pages/DeviceDetailPage.js +6 -2882
- package/src/react/pages/Devices/detail/DeviceDetailAlertsCommandsSection.js +233 -0
- package/src/react/pages/Devices/detail/DeviceDetailHeader.js +138 -0
- package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +167 -0
- package/src/react/pages/Devices/detail/DeviceDetailOrdersPrintSection.js +216 -0
- package/src/react/pages/Devices/detail/DeviceDetailPaymentSection.js +40 -0
- package/src/react/pages/Devices/detail/DeviceDetailPdvConfigSection.js +390 -0
- package/src/react/pages/Devices/detail/DeviceDetailRenderers.js +135 -0
- package/src/react/pages/Devices/detail/DeviceDetailScreen.js +493 -0
- package/src/react/pages/Devices/detail/OptionButtonChip.js +65 -0
- package/src/react/pages/Devices/detail/deviceDetailConstants.js +36 -0
- package/src/react/pages/Devices/detail/deviceDetailHelpers.js +70 -0
- package/src/react/pages/Devices/detail/useDeviceDetailActions.js +483 -0
- package/src/react/pages/Devices/detail/useDeviceDetailCopyConfig.js +87 -0
- package/src/react/pages/Devices/detail/useDeviceDetailLoaders.js +327 -0
- package/src/react/pages/Devices/detail/useDeviceDetailSaves.js +429 -0
- package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +484 -0
- package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +71 -0
- package/src/react/pages/Devices/deviceTypes/index.js +2 -0
- package/src/react/pages/Devices/deviceTypes/pdv.js +11 -0
- package/src/react/pages/Imports.js +3 -2
- package/src/react/pages/IntegrationConfigFields.js +126 -0
- package/src/react/pages/IntegrationConfigPage.js +122 -591
- package/src/react/pages/IntegrationConfigPage.utils.js +95 -0
- package/src/react/print/usePrintButtonController.js +9 -1
- package/src/react/services/Getnet/Checkout.js +81 -0
- package/src/react/services/Getnet/Getnet.js +77 -0
- package/src/react/services/paymentGatewayExecution.js +20 -0
- package/src/react/utils/bottomNavigationToolbar.js +161 -0
- package/src/react/utils/commercialDocumentOrders.js +18 -6
- package/src/react/utils/copyDeviceConfigs.js +198 -0
- package/src/react/utils/fileUrl.js +43 -0
- package/src/react/utils/importStatus.js +19 -10
- package/src/react/utils/logSettings.js +7 -7
- package/src/react/utils/maintenanceSettings.js +16 -0
- package/src/react/utils/paymentDevices.js +6 -0
- package/src/react/utils/printManagedPrinter.js +45 -0
- package/src/react/utils/printRouting.js +63 -0
- package/src/react/utils/printSpoolUtils.js +119 -0
- package/src/react/utils/printerDevices.js +368 -368
- package/src/react/utils/runtimeFooter.js +10 -19
- package/src/react/utils/shopFranchises.js +186 -65
- package/src/react/utils/systemErrorMessage.js +71 -67
- package/src/store/device_config/customActions.js +119 -30
- package/src/tests/browser/manager/bottom-navigation-role-toolbar.spec.js +353 -0
- package/src/tests/browser/manager/device-detail-alias-save.spec.js +345 -0
- package/src/tests/browser/manager/device-detail-copy-config.spec.js +365 -0
- package/src/tests/browser/manager/runtime-footer-marquee.spec.js +262 -0
- package/src/tests/browser/manager/theme-confirm-toast.spec.js +236 -0
- package/src/tests/react/components/RuntimeFooterMarqueeText.test.js +171 -0
- package/src/tests/react/components/UserAvatar.test.js +6 -2
- package/src/tests/react/components/themeAwareModals.test.mjs +60 -0
- package/src/tests/react/config/deviceConfigBootstrap.test.js +104 -66
- package/src/tests/react/pages/deviceDetailDelete.test.js +78 -0
- package/src/tests/react/pages/receitaFederalIntegrationContract.test.mjs +48 -0
- package/src/tests/react/utils/bottomNavigationToolbar.test.js +222 -0
- package/src/tests/react/utils/copyDeviceConfigs.test.mjs +127 -0
- package/src/tests/react/utils/fileUrl.test.js +38 -0
- package/src/tests/react/utils/importStatus.test.js +26 -9
- package/src/tests/react/utils/passwordPolicy.test.js +27 -0
- package/src/tests/react/utils/printRouting.test.mjs +86 -0
- package/src/tests/react/utils/printSpoolUtils.test.mjs +52 -0
- package/src/tests/react/utils/runtimeFooter.test.js +7 -0
- package/src/tests/react/utils/shopFranchises.test.js +121 -115
- package/src/tests/react/utils/systemErrorMessage.test.js +32 -59
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {useEffect} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
SOCKET_PRINT_POLL_INTERVAL_DISCONNECTED,
|
|
4
|
+
SOCKET_PRINT_POLL_DELAY_CONNECTED,
|
|
5
|
+
} from '@controleonline/ui-common/src/react/utils/printSpoolUtils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Side-effects for PrintService: dependency bootstrap, polling, queue drain, messages.
|
|
9
|
+
* Keeps PrintService.js under the absolute 500-line limit.
|
|
10
|
+
*/
|
|
11
|
+
export function usePrintSpoolEffects({
|
|
12
|
+
currentCompanyId,
|
|
13
|
+
printActions,
|
|
14
|
+
shouldHandleSpool,
|
|
15
|
+
loadOpenSpools,
|
|
16
|
+
reload,
|
|
17
|
+
websocketConnected,
|
|
18
|
+
lastPrintCommandAt,
|
|
19
|
+
connectedPollTimeoutRef,
|
|
20
|
+
print,
|
|
21
|
+
executePrintRequest,
|
|
22
|
+
spoolRef,
|
|
23
|
+
isPrintingRef,
|
|
24
|
+
goPrint,
|
|
25
|
+
spool,
|
|
26
|
+
clearAckRetry,
|
|
27
|
+
message,
|
|
28
|
+
messages,
|
|
29
|
+
markPrintCommand,
|
|
30
|
+
}) {
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!currentCompanyId) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
printActions
|
|
37
|
+
.ensurePrintDependenciesLoaded({
|
|
38
|
+
companyId: currentCompanyId,
|
|
39
|
+
})
|
|
40
|
+
.catch(() => {});
|
|
41
|
+
}, [currentCompanyId, printActions]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (shouldHandleSpool) {
|
|
45
|
+
printActions.setReload(true);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
printActions.setItems([]);
|
|
50
|
+
printActions.setReload(false);
|
|
51
|
+
}, [printActions, shouldHandleSpool]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!reload) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
loadOpenSpools();
|
|
59
|
+
}, [loadOpenSpools, reload]);
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!shouldHandleSpool || websocketConnected === true) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
printActions.setReload(true);
|
|
67
|
+
const intervalId = setInterval(() => {
|
|
68
|
+
printActions.setReload(true);
|
|
69
|
+
}, SOCKET_PRINT_POLL_INTERVAL_DISCONNECTED);
|
|
70
|
+
|
|
71
|
+
return () => {
|
|
72
|
+
clearInterval(intervalId);
|
|
73
|
+
};
|
|
74
|
+
}, [printActions, shouldHandleSpool, websocketConnected]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (connectedPollTimeoutRef.current) {
|
|
78
|
+
clearTimeout(connectedPollTimeoutRef.current);
|
|
79
|
+
connectedPollTimeoutRef.current = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!shouldHandleSpool || !websocketConnected || !lastPrintCommandAt) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const elapsed = Date.now() - lastPrintCommandAt;
|
|
87
|
+
const delay = Math.max(SOCKET_PRINT_POLL_DELAY_CONNECTED - elapsed, 0);
|
|
88
|
+
|
|
89
|
+
connectedPollTimeoutRef.current = setTimeout(() => {
|
|
90
|
+
printActions.setReload(true);
|
|
91
|
+
}, delay);
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
if (connectedPollTimeoutRef.current) {
|
|
95
|
+
clearTimeout(connectedPollTimeoutRef.current);
|
|
96
|
+
connectedPollTimeoutRef.current = null;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}, [
|
|
100
|
+
connectedPollTimeoutRef,
|
|
101
|
+
lastPrintCommandAt,
|
|
102
|
+
printActions,
|
|
103
|
+
shouldHandleSpool,
|
|
104
|
+
websocketConnected,
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (print && print.length > 0) {
|
|
109
|
+
for (const p of print) {
|
|
110
|
+
printActions.addToQueue(() => executePrintRequest(p));
|
|
111
|
+
}
|
|
112
|
+
printActions.initQueue(() => {
|
|
113
|
+
printActions.setPrint([]);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, [executePrintRequest, print, printActions]);
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!spoolRef.current?.length || isPrintingRef.current) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
goPrint(spoolRef.current[0]);
|
|
124
|
+
}, [goPrint, isPrintingRef, spool, spoolRef]);
|
|
125
|
+
|
|
126
|
+
useEffect(
|
|
127
|
+
() => () => {
|
|
128
|
+
clearAckRetry();
|
|
129
|
+
},
|
|
130
|
+
[clearAckRetry],
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!message || Object.keys(message).length === 0) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (message?.action === 'print' || message?.store === 'print') {
|
|
139
|
+
if (shouldHandleSpool) {
|
|
140
|
+
markPrintCommand();
|
|
141
|
+
printActions.setReload(true);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
printActions.setMessage(null);
|
|
146
|
+
}, [markPrintCommand, message, printActions, shouldHandleSpool]);
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
if (
|
|
150
|
+
messages &&
|
|
151
|
+
messages.length > 0 &&
|
|
152
|
+
(!message || Object.keys(message).length === 0)
|
|
153
|
+
) {
|
|
154
|
+
const queuedMessages = [...messages];
|
|
155
|
+
printActions.setMessage(queuedMessages.pop());
|
|
156
|
+
printActions.setMessages(queuedMessages);
|
|
157
|
+
}
|
|
158
|
+
}, [messages, message, printActions]);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export default usePrintSpoolEffects;
|