@controleonline/ui-common 1.2.70
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/.github/agents/developer.agent.md +30 -0
- package/.github/agents/devops.agent.md +30 -0
- package/.github/agents/qa.agent.md +30 -0
- package/.github/agents/security.agent.md +30 -0
- package/.github/workflows/npmjs.yml +35 -0
- package/.github/workflows/pull-request-checks.yml +19 -0
- package/.scrutinizer.yml +24 -0
- package/FUNDING.yml +1 -0
- package/package.json +28 -0
- package/src/api/fetch.js +74 -0
- package/src/api/index.js +155 -0
- package/src/api/localDB.js +131 -0
- package/src/api/queue.js +66 -0
- package/src/react/assets/tap.mp3 +0 -0
- package/src/react/components/AddImportModal.js +157 -0
- package/src/react/components/AddImportModal.styles.js +81 -0
- package/src/react/components/BackgroundRuntimeBridge.js +219 -0
- package/src/react/components/BottomNavigationBar.config.js +238 -0
- package/src/react/components/BottomNavigationBar.js +120 -0
- package/src/react/components/BottomNavigationBar.styles.js +110 -0
- package/src/react/components/CategoryForm.js +572 -0
- package/src/react/components/CategoryForm.styles.js +334 -0
- package/src/react/components/ConfirmModal.js +24 -0
- package/src/react/components/ConfirmModal.styles.js +43 -0
- package/src/react/components/ContextHelpButton.js +69 -0
- package/src/react/components/ContextHelpButton.styles.js +62 -0
- package/src/react/components/DefaultProvider.native.js +848 -0
- package/src/react/components/DefaultProvider.styles.js +21 -0
- package/src/react/components/DefaultProvider.web.js +909 -0
- package/src/react/components/DeliveryPushBridge.native.js +314 -0
- package/src/react/components/DeliveryPushBridge.web.js +5 -0
- package/src/react/components/DeviceAlertSoundService.js +499 -0
- package/src/react/components/EntityLogContent.js +909 -0
- package/src/react/components/EntityLogContent.styles.js +400 -0
- package/src/react/components/EventBus.js +12 -0
- package/src/react/components/KioskModeBridge.js +65 -0
- package/src/react/components/LauncherModeBridge.js +47 -0
- package/src/react/components/LinkedOrderProductsTab.js +388 -0
- package/src/react/components/LinkedOrderProductsTab.styles.js +180 -0
- package/src/react/components/ManagerPushBridge.native.js +345 -0
- package/src/react/components/MessageService.js +314 -0
- package/src/react/components/Paywall/Google.js +89 -0
- package/src/react/components/PrintService.js +778 -0
- package/src/react/components/ProductCatalogCacheService.js +45 -0
- package/src/react/components/RemoteCheckoutService.js +292 -0
- package/src/react/components/RuntimeBottomNavigationBar.js +151 -0
- package/src/react/components/RuntimeInfoFooter.js +214 -0
- package/src/react/components/RuntimeInfoFooter.styles.js +56 -0
- package/src/react/components/SystemErrorToast.js +29 -0
- package/src/react/components/SystemErrorToast.styles.js +38 -0
- package/src/react/components/TouchFeedbackProvider.js +65 -0
- package/src/react/components/UnifiedPaymentBar.js +155 -0
- package/src/react/components/UnifiedPaymentBar.styles.js +174 -0
- package/src/react/components/WebsocketListener.native.js +487 -0
- package/src/react/components/WebsocketListener.web.js +102 -0
- package/src/react/components/inputs/IdInput.js +49 -0
- package/src/react/components/inputs/IdInput.styles.js +26 -0
- package/src/react/components/inputs/InvoiceDueDateFilterInput.js +74 -0
- package/src/react/components/inputs/InvoiceDueDateFilterInput.styles.js +34 -0
- package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.js +115 -0
- package/src/react/components/inputs/InvoiceDueDateRangeFilterInput.styles.js +39 -0
- package/src/react/components/lists/CategoriesList.js +56 -0
- package/src/react/components/lists/PaymentTypeList.js +55 -0
- package/src/react/components/lists/ReceiverList.js +56 -0
- package/src/react/components/lists/SelectList.styles.js +18 -0
- package/src/react/components/lists/StatusList.js +55 -0
- package/src/react/components/lists/WalletList.js +54 -0
- package/src/react/components/radio/Spotify.js +144 -0
- package/src/react/components/radio/Spotify.styles.js +32 -0
- package/src/react/components/radio/YouTube.js +82 -0
- package/src/react/components/radio/YouTube.styles.js +16 -0
- package/src/react/components/toastConfig.js +16 -0
- package/src/react/config/deviceConfigBootstrap.js +571 -0
- package/src/react/index.js +4 -0
- package/src/react/localStorage.js +30 -0
- package/src/react/pages/EntityLogPage.js +124 -0
- package/src/react/pages/EntityLogPage.styles.js +17 -0
- package/src/react/pages/GenericLogPage.js +760 -0
- package/src/react/pages/GenericLogPage.styles.js +401 -0
- package/src/react/pages/Imports.js +361 -0
- package/src/react/pages/Imports.styles.js +223 -0
- package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +462 -0
- package/src/react/pages/SettingsPage/index.js +1171 -0
- package/src/react/pages/SettingsPage/index.styles.js +122 -0
- package/src/react/print/jobs.js +147 -0
- package/src/react/print/providers/local.js +53 -0
- package/src/react/print/providers/remote.js +81 -0
- package/src/react/print/selection.js +296 -0
- package/src/react/print/usePrintButtonController.js +474 -0
- package/src/react/router/routes.js +42 -0
- package/src/react/services/NetworkPrinterService.native.js +391 -0
- package/src/react/services/NetworkPrinterService.web.js +15 -0
- package/src/react/stores/index.js +128 -0
- package/src/react/stores/storeErrorBridge.js +36 -0
- package/src/react/utils/backgroundRuntimeRegistration.js +69 -0
- package/src/react/utils/cashPayment.js +87 -0
- package/src/react/utils/commercialDocumentOrders.js +269 -0
- package/src/react/utils/dateRangeFilter.js +264 -0
- package/src/react/utils/deviceRuntime.js +193 -0
- package/src/react/utils/entityDisplay.js +231 -0
- package/src/react/utils/entityLog.js +649 -0
- package/src/react/utils/fileUrl.js +102 -0
- package/src/react/utils/frontendDebugLog.js +45 -0
- package/src/react/utils/googleMapsConfig.js +49 -0
- package/src/react/utils/importStatus.js +100 -0
- package/src/react/utils/invoiceDueDateMessages.js +14 -0
- package/src/react/utils/invoicePresentation.js +46 -0
- package/src/react/utils/logSettings.js +143 -0
- package/src/react/utils/maintenanceSettings.js +53 -0
- package/src/react/utils/managerOrderNotifications.js +523 -0
- package/src/react/utils/mapNavigation.js +76 -0
- package/src/react/utils/menuCatalogConfig.js +8 -0
- package/src/react/utils/menuCatalogDownload.js +157 -0
- package/src/react/utils/networkCameraDevices.js +175 -0
- package/src/react/utils/networkDeviceProfiles.js +135 -0
- package/src/react/utils/normalizedCatalogDownload.js +157 -0
- package/src/react/utils/notificationNavigation.js +94 -0
- package/src/react/utils/notificationSound.js +42 -0
- package/src/react/utils/paymentDevices.js +397 -0
- package/src/react/utils/paymentGatewayExecution.js +91 -0
- package/src/react/utils/paymentOptions.js +88 -0
- package/src/react/utils/peopleDisplay.js +39 -0
- package/src/react/utils/printerDevices.js +465 -0
- package/src/react/utils/remotePayment.js +61 -0
- package/src/react/utils/runtimeFooter.js +475 -0
- package/src/react/utils/runtimeLanguage.js +50 -0
- package/src/react/utils/runtimeMenu.js +224 -0
- package/src/react/utils/screenMetrics.js +30 -0
- package/src/react/utils/shopConfig.js +294 -0
- package/src/react/utils/shopFranchises.js +114 -0
- package/src/react/utils/socketRuntimePipeline.js +454 -0
- package/src/react/utils/spoolAckTracker.js +77 -0
- package/src/react/utils/storeColumns.js +427 -0
- package/src/react/utils/systemErrorChannel.js +109 -0
- package/src/react/utils/systemErrorMessage.js +67 -0
- package/src/react/utils/toastPresentation.js +53 -0
- package/src/react/utils/websocketSharedRuntime.js +826 -0
- package/src/store/acl/getters.js +4 -0
- package/src/store/acl/index.js +19 -0
- package/src/store/acl/mutation_types.js +4 -0
- package/src/store/acl/mutations.js +17 -0
- package/src/store/address/city.js +22 -0
- package/src/store/categories/category_file/index.js +25 -0
- package/src/store/categories/index.js +93 -0
- package/src/store/configs/customActions.js +131 -0
- package/src/store/configs/index.js +25 -0
- package/src/store/connections/customActions.js +26 -0
- package/src/store/connections/index.js +124 -0
- package/src/store/device/index.js +22 -0
- package/src/store/device_config/customActions.js +190 -0
- package/src/store/device_config/index.js +28 -0
- package/src/store/entity_log/customActions.js +63 -0
- package/src/store/entity_log/index.js +25 -0
- package/src/store/extra/data.js +85 -0
- package/src/store/extra/fields.js +88 -0
- package/src/store/file/actions.js +27 -0
- package/src/store/file/index.js +24 -0
- package/src/store/imports/index.js +88 -0
- package/src/store/print/customActions.js +251 -0
- package/src/store/print/index.js +28 -0
- package/src/store/printer/customActions.js +54 -0
- package/src/store/printer/index.js +26 -0
- package/src/store/runtime_debug/customActions.js +71 -0
- package/src/store/runtime_debug/index.js +30 -0
- package/src/store/status/index.js +65 -0
- package/src/store/timezones/index.js +43 -0
- package/src/store/websocket/customActions.js +24 -0
- package/src/store/websocket/index.js +28 -0
- package/src/tests/react/components/LauncherModeBridge.test.js +93 -0
- package/src/tests/react/config/deviceConfigBootstrap.test.js +337 -0
- package/src/tests/react/print/localPrintProvider.test.js +45 -0
- package/src/tests/react/utils/backgroundRuntimeRegistration.test.js +123 -0
- package/src/tests/react/utils/cashPayment.test.js +41 -0
- package/src/tests/react/utils/dateRangeFilter.test.mjs +29 -0
- package/src/tests/react/utils/entityDisplay.test.js +18 -0
- package/src/tests/react/utils/googleMapsConfig.test.js +32 -0
- package/src/tests/react/utils/importStatus.test.js +85 -0
- package/src/tests/react/utils/invoicePresentation.test.mjs +40 -0
- package/src/tests/react/utils/managerOrderNotifications.test.js +127 -0
- package/src/tests/react/utils/mapNavigation.test.js +58 -0
- package/src/tests/react/utils/notificationNavigation.test.js +39 -0
- package/src/tests/react/utils/notificationSound.test.js +27 -0
- package/src/tests/react/utils/paymentDevices.test.js +88 -0
- package/src/tests/react/utils/runtimeFooter.test.js +429 -0
- package/src/tests/react/utils/runtimeLanguage.test.js +80 -0
- package/src/tests/react/utils/runtimeMenu.test.js +174 -0
- package/src/tests/react/utils/shopFranchises.test.js +82 -0
- package/src/tests/react/utils/socketRuntimePipeline.test.js +124 -0
- package/src/tests/react/utils/spoolAckTracker.test.js +40 -0
- package/src/tests/react/utils/storeErrorBridge.test.js +66 -0
- package/src/tests/react/utils/systemErrorChannel.test.js +58 -0
- package/src/tests/react/utils/systemErrorMessage.test.js +59 -0
- package/src/tests/react/utils/toastPresentation.test.js +75 -0
- package/src/tests/react/utils/translate.test.mjs +396 -0
- package/src/tests/react/utils/websocketSharedRuntime.test.js +245 -0
- package/src/utils/apiEntryPoint.js +31 -0
- package/src/utils/appDomain.js +50 -0
- package/src/utils/config.js +14 -0
- package/src/utils/formatter.js +419 -0
- package/src/utils/integrationConfigs.js +79 -0
- package/src/utils/methods.js +23 -0
- package/src/utils/oauth.js +42 -0
- package/src/utils/translate.js +620 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const inlineStyle_565_16 = {
|
|
2
|
+
marginTop: 20,
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const inlineStyle_639_14 = {
|
|
6
|
+
marginTop: 16,
|
|
7
|
+
padding: 14,
|
|
8
|
+
backgroundColor: '#EFF6FF',
|
|
9
|
+
borderRadius: 12,
|
|
10
|
+
borderWidth: 1,
|
|
11
|
+
borderColor: '#BFDBFE',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const inlineStyle_650_20 = {
|
|
15
|
+
fontSize: 12,
|
|
16
|
+
lineHeight: 18,
|
|
17
|
+
color: '#1D4ED8',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const inlineStyle_659_16 = {
|
|
21
|
+
marginTop: 12,
|
|
22
|
+
marginBottom: 10,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const inlineStyle_676_16 = {
|
|
26
|
+
marginTop: 6,
|
|
27
|
+
marginBottom: 10,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const inlineStyle_690_16 = {
|
|
31
|
+
marginTop: 6,
|
|
32
|
+
marginBottom: 10,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const inlineStyle_704_12 = {
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
justifyContent: 'space-between',
|
|
39
|
+
marginTop: 12,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const inlineStyle_720_12 = {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'space-between',
|
|
46
|
+
marginTop: 12,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const inlineStyle_736_12 = {
|
|
50
|
+
marginTop: 16,
|
|
51
|
+
padding: 14,
|
|
52
|
+
backgroundColor: '#F8FAFC',
|
|
53
|
+
borderRadius: 12,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const inlineStyle_743_14 = {
|
|
57
|
+
flexDirection: 'row',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'space-between',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const inlineStyle_757_14 = {
|
|
63
|
+
fontSize: 12,
|
|
64
|
+
lineHeight: 18,
|
|
65
|
+
color: '#64748B',
|
|
66
|
+
marginTop: 8,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const inlineStyle_783_14 = {
|
|
70
|
+
minHeight: 46,
|
|
71
|
+
borderWidth: 1,
|
|
72
|
+
borderColor: '#E2E8F0',
|
|
73
|
+
borderRadius: 10,
|
|
74
|
+
backgroundColor: '#fff',
|
|
75
|
+
color: '#0F172A',
|
|
76
|
+
paddingHorizontal: 12,
|
|
77
|
+
paddingVertical: 10,
|
|
78
|
+
outlineStyle: 'none',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const inlineStyle_798_12 = {
|
|
82
|
+
marginTop: 16,
|
|
83
|
+
padding: 14,
|
|
84
|
+
backgroundColor: '#F8FAFC',
|
|
85
|
+
borderRadius: 12,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const inlineStyle_805_14 = {
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
justifyContent: 'space-between',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const inlineStyle_818_14 = {
|
|
95
|
+
fontSize: 12,
|
|
96
|
+
lineHeight: 18,
|
|
97
|
+
color: '#64748B',
|
|
98
|
+
marginTop: 8,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const inlineStyle_830_16 = {
|
|
102
|
+
marginTop: 6,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const inlineStyle_841_16 = {
|
|
106
|
+
marginTop: 6,
|
|
107
|
+
marginBottom: 10,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const inlineStyle_852_16 = {
|
|
111
|
+
marginTop: 6,
|
|
112
|
+
marginBottom: 10,
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const inlineStyle_871_18 = {
|
|
116
|
+
marginTop: 10,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const inlineStyle_899_18 = {
|
|
120
|
+
color: '#fff',
|
|
121
|
+
marginLeft: 8,
|
|
122
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import {normalizeDeviceId} from '@controleonline/ui-common/src/react/utils/paymentDevices';
|
|
2
|
+
|
|
3
|
+
export const PRINT_JOB_TYPE_ORDER = 'order';
|
|
4
|
+
export const PRINT_JOB_TYPE_ORDER_PRODUCT = 'order-product';
|
|
5
|
+
export const PRINT_JOB_TYPE_ORDER_PRODUCT_QUEUE = 'order-product-queue';
|
|
6
|
+
export const PRINT_JOB_TYPE_CASH_REGISTER = 'cash-register';
|
|
7
|
+
export const PRINT_JOB_TYPE_PURCHASING_SUGGESTION = 'purchasing-suggestion';
|
|
8
|
+
export const PRINT_JOB_TYPE_INVENTORY = 'inventory';
|
|
9
|
+
export const PRINT_JOB_TYPE_PRODUCT_LABEL = 'product-label';
|
|
10
|
+
export const PRINT_JOB_TYPE_SPOOL = 'spool';
|
|
11
|
+
|
|
12
|
+
export const PRINT_CONTEXT_DEVICE = 'device';
|
|
13
|
+
export const PRINT_CONTEXT_DISPLAY = 'display';
|
|
14
|
+
export const PRINT_CONTEXT_SPOOL = 'spool';
|
|
15
|
+
|
|
16
|
+
const normalizeEntityId = value =>
|
|
17
|
+
String(value || '')
|
|
18
|
+
.replace(/\D+/g, '')
|
|
19
|
+
.trim();
|
|
20
|
+
|
|
21
|
+
const normalizeIds = value =>
|
|
22
|
+
(Array.isArray(value) ? value : [value])
|
|
23
|
+
.map(item => normalizeEntityId(item))
|
|
24
|
+
.filter(Boolean);
|
|
25
|
+
|
|
26
|
+
export const buildPrintSelectionKey = ({
|
|
27
|
+
companyId = '',
|
|
28
|
+
contextType = PRINT_CONTEXT_DEVICE,
|
|
29
|
+
deviceId = '',
|
|
30
|
+
displayId = '',
|
|
31
|
+
} = {}) =>
|
|
32
|
+
[
|
|
33
|
+
String(contextType || PRINT_CONTEXT_DEVICE).trim().toLowerCase(),
|
|
34
|
+
normalizeEntityId(companyId),
|
|
35
|
+
normalizeDeviceId(deviceId),
|
|
36
|
+
normalizeEntityId(displayId),
|
|
37
|
+
]
|
|
38
|
+
.filter(Boolean)
|
|
39
|
+
.join(':');
|
|
40
|
+
|
|
41
|
+
export const buildPrintRequestKey = ({
|
|
42
|
+
type = '',
|
|
43
|
+
id = '',
|
|
44
|
+
orderId = '',
|
|
45
|
+
orderProductId = '',
|
|
46
|
+
orderProductQueueId = '',
|
|
47
|
+
spoolId = '',
|
|
48
|
+
selectionKey = '',
|
|
49
|
+
} = {}) =>
|
|
50
|
+
[
|
|
51
|
+
String(type || '').trim().toLowerCase(),
|
|
52
|
+
normalizeEntityId(id),
|
|
53
|
+
normalizeEntityId(orderId),
|
|
54
|
+
normalizeEntityId(orderProductId),
|
|
55
|
+
normalizeEntityId(orderProductQueueId),
|
|
56
|
+
normalizeEntityId(spoolId),
|
|
57
|
+
String(selectionKey || '').trim(),
|
|
58
|
+
]
|
|
59
|
+
.filter(Boolean)
|
|
60
|
+
.join(':');
|
|
61
|
+
|
|
62
|
+
export const normalizePrintJob = ({
|
|
63
|
+
job = {},
|
|
64
|
+
fallbackType = '',
|
|
65
|
+
fallbackId = '',
|
|
66
|
+
} = {}) => {
|
|
67
|
+
const type = String(job?.type || fallbackType || '')
|
|
68
|
+
.trim()
|
|
69
|
+
.toLowerCase();
|
|
70
|
+
|
|
71
|
+
if (!type) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (type === PRINT_JOB_TYPE_SPOOL) {
|
|
76
|
+
const spoolId = normalizeEntityId(job?.spoolId || job?.id || fallbackId);
|
|
77
|
+
return spoolId ? {type, spoolId} : null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (type === PRINT_JOB_TYPE_ORDER_PRODUCT) {
|
|
81
|
+
const orderProductId = normalizeEntityId(
|
|
82
|
+
job?.orderProductId || job?.id || fallbackId,
|
|
83
|
+
);
|
|
84
|
+
if (!orderProductId) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
type,
|
|
90
|
+
orderProductId,
|
|
91
|
+
orderProductQueueIds: normalizeIds(job?.orderProductQueueIds),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (type === PRINT_JOB_TYPE_ORDER_PRODUCT_QUEUE) {
|
|
96
|
+
const orderProductQueueId = normalizeEntityId(
|
|
97
|
+
job?.orderProductQueueId || job?.id || fallbackId,
|
|
98
|
+
);
|
|
99
|
+
if (!orderProductQueueId) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
type,
|
|
105
|
+
orderProductQueueId,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (type === PRINT_JOB_TYPE_ORDER) {
|
|
110
|
+
const orderId = normalizeEntityId(job?.orderId || job?.id || fallbackId);
|
|
111
|
+
if (!orderId) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
type,
|
|
117
|
+
orderId,
|
|
118
|
+
queueIds: normalizeIds(job?.queueIds),
|
|
119
|
+
orderProductQueueIds: normalizeIds(job?.orderProductQueueIds),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (
|
|
124
|
+
[
|
|
125
|
+
PRINT_JOB_TYPE_CASH_REGISTER,
|
|
126
|
+
PRINT_JOB_TYPE_PURCHASING_SUGGESTION,
|
|
127
|
+
PRINT_JOB_TYPE_INVENTORY,
|
|
128
|
+
].includes(type)
|
|
129
|
+
) {
|
|
130
|
+
return {type};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (type === PRINT_JOB_TYPE_PRODUCT_LABEL) {
|
|
134
|
+
return {
|
|
135
|
+
type,
|
|
136
|
+
id: normalizeEntityId(job?.id || job?.productId || fallbackId),
|
|
137
|
+
productId: normalizeEntityId(job?.productId || job?.id || fallbackId),
|
|
138
|
+
productName: String(job?.productName || '').trim(),
|
|
139
|
+
handlingDate: String(job?.handlingDate || '').trim(),
|
|
140
|
+
expirationDate: String(job?.expirationDate || '').trim(),
|
|
141
|
+
freeText: String(job?.freeText || '').trim(),
|
|
142
|
+
labelText: String(job?.labelText || '').trim(),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return null;
|
|
147
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {CieloPrint} from '@controleonline/ui-orders/src/react/services/Cielo/Print';
|
|
2
|
+
|
|
3
|
+
export const LOCAL_CIELO_PRINT_UNAVAILABLE_MESSAGE =
|
|
4
|
+
'Impressao local Cielo indisponivel neste equipamento.';
|
|
5
|
+
|
|
6
|
+
export const resolveLocalCieloPrintErrorMessage = response => {
|
|
7
|
+
const result = String(response?.result || '').trim();
|
|
8
|
+
|
|
9
|
+
if (/No Activity found to handle Intent/i.test(result)) {
|
|
10
|
+
return (
|
|
11
|
+
global.t?.t('orders', 'message', 'localCieloPrintUnavailable') ||
|
|
12
|
+
LOCAL_CIELO_PRINT_UNAVAILABLE_MESSAGE
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
result ||
|
|
18
|
+
global.t?.t('orders', 'message', 'printProcessingError') ||
|
|
19
|
+
'Falha ao imprimir.'
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const decodeLocalPrintPayload = content => {
|
|
24
|
+
if (content === null || content === undefined) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof content !== 'string') {
|
|
29
|
+
return JSON.stringify(content);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (typeof globalThis.atob === 'function') {
|
|
33
|
+
try {
|
|
34
|
+
return globalThis.atob(content);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return content;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return content;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const printOnLocalCielo = async content => {
|
|
44
|
+
const cielo = new CieloPrint();
|
|
45
|
+
const payload = decodeLocalPrintPayload(content);
|
|
46
|
+
const response = await cielo.print(payload);
|
|
47
|
+
|
|
48
|
+
if (response?.success === false) {
|
|
49
|
+
throw new Error(resolveLocalCieloPrintErrorMessage(response));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return response;
|
|
53
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PRINT_JOB_TYPE_CASH_REGISTER,
|
|
3
|
+
PRINT_JOB_TYPE_INVENTORY,
|
|
4
|
+
PRINT_JOB_TYPE_ORDER,
|
|
5
|
+
PRINT_JOB_TYPE_ORDER_PRODUCT,
|
|
6
|
+
PRINT_JOB_TYPE_ORDER_PRODUCT_QUEUE,
|
|
7
|
+
PRINT_JOB_TYPE_PRODUCT_LABEL,
|
|
8
|
+
PRINT_JOB_TYPE_PURCHASING_SUGGESTION,
|
|
9
|
+
} from '@controleonline/ui-common/src/react/print/jobs';
|
|
10
|
+
|
|
11
|
+
export const executeRemotePrintRequest = async ({
|
|
12
|
+
printActions,
|
|
13
|
+
printJob,
|
|
14
|
+
targetDeviceId,
|
|
15
|
+
targetDeviceType = '',
|
|
16
|
+
currentCompanyId = null,
|
|
17
|
+
}) => {
|
|
18
|
+
const commonParams = {
|
|
19
|
+
device: targetDeviceId,
|
|
20
|
+
...(targetDeviceType ? {type: targetDeviceType} : {}),
|
|
21
|
+
...(currentCompanyId ? {people: currentCompanyId} : {}),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
if (printJob.type === PRINT_JOB_TYPE_ORDER) {
|
|
25
|
+
return await printActions.printOrder({
|
|
26
|
+
id: printJob.orderId,
|
|
27
|
+
...commonParams,
|
|
28
|
+
...(Array.isArray(printJob.queueIds) && printJob.queueIds.length > 0
|
|
29
|
+
? {queueIds: printJob.queueIds}
|
|
30
|
+
: {}),
|
|
31
|
+
...(Array.isArray(printJob.orderProductQueueIds) &&
|
|
32
|
+
printJob.orderProductQueueIds.length > 0
|
|
33
|
+
? {orderProductQueueIds: printJob.orderProductQueueIds}
|
|
34
|
+
: {}),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (printJob.type === PRINT_JOB_TYPE_ORDER_PRODUCT) {
|
|
39
|
+
return await printActions.printOrderProduct({
|
|
40
|
+
id: printJob.orderProductId,
|
|
41
|
+
...commonParams,
|
|
42
|
+
...(Array.isArray(printJob.orderProductQueueIds) &&
|
|
43
|
+
printJob.orderProductQueueIds.length > 0
|
|
44
|
+
? {orderProductQueueIds: printJob.orderProductQueueIds}
|
|
45
|
+
: {}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (printJob.type === PRINT_JOB_TYPE_ORDER_PRODUCT_QUEUE) {
|
|
50
|
+
return await printActions.printOrderProductQueue({
|
|
51
|
+
id: printJob.orderProductQueueId,
|
|
52
|
+
...commonParams,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (printJob.type === PRINT_JOB_TYPE_CASH_REGISTER) {
|
|
57
|
+
return await printActions.getCashRegisterPrint(commonParams);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (printJob.type === PRINT_JOB_TYPE_PURCHASING_SUGGESTION) {
|
|
61
|
+
return await printActions.printPurchasingSuggestion(commonParams);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (printJob.type === PRINT_JOB_TYPE_INVENTORY) {
|
|
65
|
+
return await printActions.printInventory(commonParams);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (printJob.type === PRINT_JOB_TYPE_PRODUCT_LABEL) {
|
|
69
|
+
return await printActions.printProductLabel({
|
|
70
|
+
...commonParams,
|
|
71
|
+
productId: printJob.productId || null,
|
|
72
|
+
productName: printJob.productName || '',
|
|
73
|
+
handlingDate: printJob.handlingDate || '',
|
|
74
|
+
expirationDate: printJob.expirationDate || '',
|
|
75
|
+
freeText: printJob.freeText || '',
|
|
76
|
+
labelText: printJob.labelText || '',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import {parseConfigsObject} from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
|
|
2
|
+
import {
|
|
3
|
+
PDV_DEVICE_TYPE,
|
|
4
|
+
findPrinterOptionByValue,
|
|
5
|
+
getPrinterOptions,
|
|
6
|
+
getPrinterOptionValue,
|
|
7
|
+
} from '@controleonline/ui-common/src/react/utils/printerDevices';
|
|
8
|
+
import {
|
|
9
|
+
filterDeviceConfigsByCompany,
|
|
10
|
+
isPdvPrinterEnabled,
|
|
11
|
+
normalizeDeviceId,
|
|
12
|
+
normalizeDeviceIds,
|
|
13
|
+
} from '@controleonline/ui-common/src/react/utils/paymentDevices';
|
|
14
|
+
import {
|
|
15
|
+
PRINT_CONTEXT_DEVICE,
|
|
16
|
+
PRINT_CONTEXT_DISPLAY,
|
|
17
|
+
} from '@controleonline/ui-common/src/react/print/jobs';
|
|
18
|
+
|
|
19
|
+
export const DISPLAY_DEVICE_LINK_CONFIG_KEY = 'display-id';
|
|
20
|
+
export const DISPLAY_DEVICE_PRINTER_CONFIG_KEY = 'printer';
|
|
21
|
+
export const COMPANY_ORDER_PRINT_DEVICES_CONFIG_KEY = 'order-print-devices';
|
|
22
|
+
|
|
23
|
+
const normalizeEntityId = value =>
|
|
24
|
+
String(value || '')
|
|
25
|
+
.replace(/\D+/g, '')
|
|
26
|
+
.trim();
|
|
27
|
+
|
|
28
|
+
const getDeviceConfigType = deviceConfig =>
|
|
29
|
+
String(deviceConfig?.type || deviceConfig?.device?.type || '')
|
|
30
|
+
.trim()
|
|
31
|
+
.toUpperCase();
|
|
32
|
+
|
|
33
|
+
const normalizePrinterRuntimeType = value =>
|
|
34
|
+
String(value || '')
|
|
35
|
+
.trim()
|
|
36
|
+
.toUpperCase();
|
|
37
|
+
|
|
38
|
+
const canUseCurrentPdvAsPrinter = ({
|
|
39
|
+
currentDeviceConfig = null,
|
|
40
|
+
currentDeviceId = '',
|
|
41
|
+
runtimeDeviceType = '',
|
|
42
|
+
}) =>
|
|
43
|
+
normalizePrinterRuntimeType(runtimeDeviceType) === PDV_DEVICE_TYPE &&
|
|
44
|
+
normalizeDeviceId(currentDeviceId) !== '' &&
|
|
45
|
+
isPdvPrinterEnabled(currentDeviceConfig);
|
|
46
|
+
|
|
47
|
+
export const resolveDisplayDeviceConfig = ({
|
|
48
|
+
deviceConfigs = [],
|
|
49
|
+
companyId = null,
|
|
50
|
+
currentDeviceId = '',
|
|
51
|
+
displayId = '',
|
|
52
|
+
}) => {
|
|
53
|
+
const normalizedDisplayId = normalizeEntityId(displayId);
|
|
54
|
+
if (!normalizedDisplayId) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const matchingConfigs = filterDeviceConfigsByCompany(deviceConfigs, companyId)
|
|
59
|
+
.filter(deviceConfig => {
|
|
60
|
+
if (getDeviceConfigType(deviceConfig) !== 'DISPLAY') {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const configs = parseConfigsObject(deviceConfig?.configs);
|
|
65
|
+
return (
|
|
66
|
+
normalizeEntityId(configs?.[DISPLAY_DEVICE_LINK_CONFIG_KEY]) ===
|
|
67
|
+
normalizedDisplayId
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (matchingConfigs.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
matchingConfigs.find(
|
|
77
|
+
deviceConfig =>
|
|
78
|
+
normalizeDeviceId(deviceConfig?.device?.device) ===
|
|
79
|
+
normalizeDeviceId(currentDeviceId),
|
|
80
|
+
) || matchingConfigs[0]
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const resolvePrintDeviceConfig = ({
|
|
85
|
+
contextType = PRINT_CONTEXT_DEVICE,
|
|
86
|
+
companyDeviceConfigs = [],
|
|
87
|
+
currentCompanyId = null,
|
|
88
|
+
currentDeviceId = '',
|
|
89
|
+
displayId = '',
|
|
90
|
+
runtimeDeviceConfig = null,
|
|
91
|
+
}) => {
|
|
92
|
+
if (contextType === PRINT_CONTEXT_DISPLAY) {
|
|
93
|
+
return resolveDisplayDeviceConfig({
|
|
94
|
+
deviceConfigs: companyDeviceConfigs,
|
|
95
|
+
companyId: currentCompanyId,
|
|
96
|
+
currentDeviceId,
|
|
97
|
+
displayId,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (runtimeDeviceConfig?.configs) {
|
|
102
|
+
return runtimeDeviceConfig;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
(Array.isArray(companyDeviceConfigs) ? companyDeviceConfigs : []).find(
|
|
107
|
+
deviceConfig =>
|
|
108
|
+
normalizeDeviceId(deviceConfig?.device?.device) ===
|
|
109
|
+
normalizeDeviceId(currentDeviceId),
|
|
110
|
+
) || null
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const resolveConfiguredPrinterValue = deviceConfig =>
|
|
115
|
+
normalizeDeviceId(
|
|
116
|
+
parseConfigsObject(deviceConfig?.configs)?.[DISPLAY_DEVICE_PRINTER_CONFIG_KEY],
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export const resolveCompanyConfiguredPrinterValue = ({
|
|
120
|
+
companyConfigs = {},
|
|
121
|
+
currentDeviceConfig = null,
|
|
122
|
+
printerOptions = [],
|
|
123
|
+
currentDeviceId = '',
|
|
124
|
+
runtimeDeviceType = '',
|
|
125
|
+
}) => {
|
|
126
|
+
const configuredPrinterValues = normalizeDeviceIds(
|
|
127
|
+
parseConfigsObject(companyConfigs)?.[COMPANY_ORDER_PRINT_DEVICES_CONFIG_KEY],
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
for (const printerValue of configuredPrinterValues) {
|
|
131
|
+
const validatedPrinterValue = resolveValidatedPrinterValue({
|
|
132
|
+
printerValue,
|
|
133
|
+
currentDeviceConfig,
|
|
134
|
+
printerOptions,
|
|
135
|
+
currentDeviceId,
|
|
136
|
+
runtimeDeviceType,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (validatedPrinterValue) {
|
|
140
|
+
return validatedPrinterValue;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return '';
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const resolveValidatedPrinterValue = ({
|
|
148
|
+
printerValue = '',
|
|
149
|
+
currentDeviceConfig = null,
|
|
150
|
+
printerOptions = [],
|
|
151
|
+
currentDeviceId = '',
|
|
152
|
+
runtimeDeviceType = '',
|
|
153
|
+
}) => {
|
|
154
|
+
const normalizedPrinterValue = normalizeDeviceId(printerValue);
|
|
155
|
+
if (!normalizedPrinterValue) {
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const matchedPrinter = findPrinterOptionByValue(
|
|
160
|
+
printerOptions,
|
|
161
|
+
normalizedPrinterValue,
|
|
162
|
+
);
|
|
163
|
+
if (matchedPrinter) {
|
|
164
|
+
return normalizeDeviceId(
|
|
165
|
+
getPrinterOptionValue(matchedPrinter) || matchedPrinter?.device,
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (
|
|
170
|
+
canUseCurrentPdvAsPrinter({
|
|
171
|
+
currentDeviceConfig,
|
|
172
|
+
currentDeviceId,
|
|
173
|
+
runtimeDeviceType,
|
|
174
|
+
}) &&
|
|
175
|
+
normalizedPrinterValue === normalizeDeviceId(currentDeviceId)
|
|
176
|
+
) {
|
|
177
|
+
return normalizedPrinterValue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return '';
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const resolveAutoPrinterValue = ({
|
|
184
|
+
printerOptions = [],
|
|
185
|
+
currentDeviceId = '',
|
|
186
|
+
runtimeDeviceType = '',
|
|
187
|
+
}) => {
|
|
188
|
+
const options = Array.isArray(printerOptions) ? printerOptions : [];
|
|
189
|
+
|
|
190
|
+
if (options.length === 1) {
|
|
191
|
+
return normalizeDeviceId(
|
|
192
|
+
getPrinterOptionValue(options[0]) || options[0]?.device,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (normalizePrinterRuntimeType(runtimeDeviceType) !== PDV_DEVICE_TYPE) {
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const currentDevicePrinter = options.find(
|
|
201
|
+
option => normalizeDeviceId(option?.device) === normalizeDeviceId(currentDeviceId),
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
return normalizeDeviceId(
|
|
205
|
+
getPrinterOptionValue(currentDevicePrinter) || currentDevicePrinter?.device,
|
|
206
|
+
);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export const resolvePrintSelectionValue = ({
|
|
210
|
+
transientPrinterValue = '',
|
|
211
|
+
configuredPrinterValue = '',
|
|
212
|
+
companyConfiguredPrinterValue = '',
|
|
213
|
+
currentDeviceConfig = null,
|
|
214
|
+
printerOptions = [],
|
|
215
|
+
currentDeviceId = '',
|
|
216
|
+
runtimeDeviceType = '',
|
|
217
|
+
}) =>
|
|
218
|
+
resolveValidatedPrinterValue({
|
|
219
|
+
printerValue: transientPrinterValue,
|
|
220
|
+
currentDeviceConfig,
|
|
221
|
+
printerOptions,
|
|
222
|
+
currentDeviceId,
|
|
223
|
+
runtimeDeviceType,
|
|
224
|
+
}) ||
|
|
225
|
+
resolveValidatedPrinterValue({
|
|
226
|
+
printerValue: configuredPrinterValue,
|
|
227
|
+
currentDeviceConfig,
|
|
228
|
+
printerOptions,
|
|
229
|
+
currentDeviceId,
|
|
230
|
+
runtimeDeviceType,
|
|
231
|
+
}) ||
|
|
232
|
+
normalizeDeviceId(companyConfiguredPrinterValue) ||
|
|
233
|
+
resolveAutoPrinterValue({
|
|
234
|
+
printerOptions,
|
|
235
|
+
currentDeviceId,
|
|
236
|
+
runtimeDeviceType,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const resolvePrinterOptions = ({
|
|
240
|
+
printers = [],
|
|
241
|
+
companyDeviceConfigs = [],
|
|
242
|
+
currentCompanyId = null,
|
|
243
|
+
}) =>
|
|
244
|
+
getPrinterOptions({
|
|
245
|
+
printers,
|
|
246
|
+
deviceConfigs: companyDeviceConfigs,
|
|
247
|
+
companyId: currentCompanyId,
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
export const resolveSelectedPrinter = ({
|
|
251
|
+
currentDeviceConfig = null,
|
|
252
|
+
printerOptions = [],
|
|
253
|
+
selectedPrinterValue = '',
|
|
254
|
+
currentDevice = null,
|
|
255
|
+
runtimeDeviceType = '',
|
|
256
|
+
}) => {
|
|
257
|
+
const matchedPrinter = findPrinterOptionByValue(
|
|
258
|
+
printerOptions,
|
|
259
|
+
selectedPrinterValue,
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
if (matchedPrinter) {
|
|
263
|
+
return matchedPrinter;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const currentDeviceId = normalizeDeviceId(currentDevice?.id || currentDevice?.device);
|
|
267
|
+
if (!currentDeviceId) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (normalizeDeviceId(selectedPrinterValue) !== currentDeviceId) {
|
|
272
|
+
return null;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (
|
|
276
|
+
!canUseCurrentPdvAsPrinter({
|
|
277
|
+
currentDeviceConfig,
|
|
278
|
+
currentDeviceId,
|
|
279
|
+
runtimeDeviceType,
|
|
280
|
+
})
|
|
281
|
+
) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
device: currentDeviceId,
|
|
287
|
+
type: String(runtimeDeviceType || currentDevice?.type || '')
|
|
288
|
+
.trim()
|
|
289
|
+
.toUpperCase(),
|
|
290
|
+
alias: currentDevice?.alias || currentDeviceId,
|
|
291
|
+
selectionValue: currentDeviceId,
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
export const resolvePrinterSelectionValue = printer =>
|
|
296
|
+
normalizeDeviceId(getPrinterOptionValue(printer) || printer?.device);
|