@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,571 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendScreenMetrics,
|
|
3
|
+
hasScreenMetricsChanges,
|
|
4
|
+
} from '@controleonline/ui-common/src/react/utils/screenMetrics';
|
|
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
|
+
export const DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY =
|
|
27
|
+
'android-kiosk-enabled';
|
|
28
|
+
export const DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY =
|
|
29
|
+
'android-launcher-enabled';
|
|
30
|
+
export const POS_AUTO_PRINT_ENABLED_CONFIG_KEY = 'pos-auto-print-enabled';
|
|
31
|
+
export const POS_CASH_MANAGEMENT_MODE_CONFIG_KEY =
|
|
32
|
+
'pos-cash-management-mode';
|
|
33
|
+
export const POS_CHECK_ORDER_TYPE_CONFIG_KEY = 'check-order-type';
|
|
34
|
+
export const POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY =
|
|
35
|
+
'check-order-management-mode';
|
|
36
|
+
export const POS_OPERATION_MODE_COUNTER = 'counter';
|
|
37
|
+
export const POS_OPERATION_MODE_WAITER = 'waiter';
|
|
38
|
+
export const POS_OPERATION_MODE_TOTEM = 'totem';
|
|
39
|
+
export const POS_OPERATION_MODE_SINGLE_ITEM = 'single-item';
|
|
40
|
+
export const POS_OPERATION_MODE_CASHIER = 'cashier';
|
|
41
|
+
export const POS_CHECK_ORDER_TYPE_NONE = 'none';
|
|
42
|
+
export const POS_CHECK_ORDER_TYPE_TAB = 'tab';
|
|
43
|
+
export const POS_CHECK_ORDER_TYPE_TABLE = 'table';
|
|
44
|
+
export const POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE = 'manage';
|
|
45
|
+
export const POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY = 'existing-only';
|
|
46
|
+
export const POS_OPERATION_MODE_DEFAULT = POS_OPERATION_MODE_CASHIER;
|
|
47
|
+
export const POS_PRINT_MODE_ORDER = 'order';
|
|
48
|
+
export const POS_PRINT_MODE_FORM = 'form';
|
|
49
|
+
export const POS_PRINT_MODE_DEFAULT = POS_PRINT_MODE_ORDER;
|
|
50
|
+
export const POS_CASH_MANAGEMENT_MODE_CASH_REGISTER = 'cash-register';
|
|
51
|
+
export const POS_CASH_MANAGEMENT_MODE_DAILY = 'daily';
|
|
52
|
+
export const POS_CASH_MANAGEMENT_MODE_DEFAULT =
|
|
53
|
+
POS_CASH_MANAGEMENT_MODE_CASH_REGISTER;
|
|
54
|
+
export const POS_OPERATION_MODE_OPTIONS = [
|
|
55
|
+
{
|
|
56
|
+
value: POS_OPERATION_MODE_COUNTER,
|
|
57
|
+
translationKey: 'counterService',
|
|
58
|
+
descriptionKey: 'counterServiceDescription',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: POS_OPERATION_MODE_WAITER,
|
|
62
|
+
translationKey: 'waiterService',
|
|
63
|
+
descriptionKey: 'waiterServiceDescription',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: POS_OPERATION_MODE_TOTEM,
|
|
67
|
+
translationKey: 'selfServiceKiosk',
|
|
68
|
+
descriptionKey: 'selfServiceKioskDescription',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: POS_OPERATION_MODE_SINGLE_ITEM,
|
|
72
|
+
translationKey: 'singleItemSale',
|
|
73
|
+
descriptionKey: 'singleItemSaleDescription',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: POS_OPERATION_MODE_CASHIER,
|
|
77
|
+
translationKey: 'cashierPOS',
|
|
78
|
+
descriptionKey: 'cashierPOSDescription',
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
export const DEFAULT_DEVICE_CONFIGS = {
|
|
83
|
+
'pos-type': 'full',
|
|
84
|
+
'print-mode': 'order',
|
|
85
|
+
'check-type': 'manual',
|
|
86
|
+
'product-input-type': 'manual',
|
|
87
|
+
'selection-type': 'single',
|
|
88
|
+
sound: '0',
|
|
89
|
+
vibration: '0',
|
|
90
|
+
[DEVICE_ORDER_VISIBILITY_KEY]: DEVICE_ORDER_VISIBILITY_DEVICE,
|
|
91
|
+
[POS_DELIVERY_ENABLED_CONFIG_KEY]: '1',
|
|
92
|
+
[DEVICE_ALERT_SOUND_ENABLED_KEY]: '0',
|
|
93
|
+
[DEVICE_ALERT_SOUND_URL_KEY]: '',
|
|
94
|
+
[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY]: '0',
|
|
95
|
+
[DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: '0',
|
|
96
|
+
[DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY]: '0',
|
|
97
|
+
[DISPLAY_SIZE_CONFIG_KEY]: String(DISPLAY_SIZE_DEFAULT),
|
|
98
|
+
[DISPLAY_SIDE_BREAK_CONFIG_KEY]: '0',
|
|
99
|
+
[POS_CHECK_ORDER_TYPE_CONFIG_KEY]: POS_CHECK_ORDER_TYPE_NONE,
|
|
100
|
+
[POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY]:
|
|
101
|
+
POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
102
|
+
[POS_OPERATION_MODE_CONFIG_KEY]: POS_OPERATION_MODE_DEFAULT,
|
|
103
|
+
[POS_AUTO_PRINT_ENABLED_CONFIG_KEY]: '0',
|
|
104
|
+
[POS_CASH_MANAGEMENT_MODE_CONFIG_KEY]: POS_CASH_MANAGEMENT_MODE_DEFAULT,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const isTruthyValue = value =>
|
|
108
|
+
value === true || value === '1' || value === 1 || value === 'true';
|
|
109
|
+
|
|
110
|
+
export const isMissingConfigValue = value =>
|
|
111
|
+
value === undefined || value === null || value === '';
|
|
112
|
+
|
|
113
|
+
export const parseConfigsObject = configs => {
|
|
114
|
+
if (!configs) return {};
|
|
115
|
+
|
|
116
|
+
if (typeof configs === 'string') {
|
|
117
|
+
try {
|
|
118
|
+
const parsed = JSON.parse(configs);
|
|
119
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
120
|
+
} catch {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return typeof configs === 'object' ? {...configs} : {};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const normalizeDisplaySize = value => {
|
|
129
|
+
const normalizedValue = String(value ?? '').trim();
|
|
130
|
+
|
|
131
|
+
if (normalizedValue === '') {
|
|
132
|
+
return DISPLAY_SIZE_DEFAULT;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const numericValue = Number(normalizedValue);
|
|
136
|
+
|
|
137
|
+
if (!Number.isFinite(numericValue)) {
|
|
138
|
+
return DISPLAY_SIZE_DEFAULT;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return Math.min(
|
|
142
|
+
DISPLAY_SIZE_MAX,
|
|
143
|
+
Math.max(DISPLAY_SIZE_MIN, Math.round(numericValue)),
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const resolveDisplaySize = configs =>
|
|
148
|
+
normalizeDisplaySize(
|
|
149
|
+
parseConfigsObject(configs)?.[DISPLAY_SIZE_CONFIG_KEY],
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
export const isDisplaySideBreakEnabled = configs =>
|
|
153
|
+
isTruthyValue(
|
|
154
|
+
parseConfigsObject(configs)?.[DISPLAY_SIDE_BREAK_CONFIG_KEY],
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
export const normalizePosOperationMode = value => {
|
|
158
|
+
const normalizedValue = String(value || '')
|
|
159
|
+
.trim()
|
|
160
|
+
.toLowerCase()
|
|
161
|
+
.normalize('NFD')
|
|
162
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
163
|
+
.replace(/[\s_]/g, '-');
|
|
164
|
+
|
|
165
|
+
if (
|
|
166
|
+
[
|
|
167
|
+
POS_OPERATION_MODE_COUNTER,
|
|
168
|
+
'balcao',
|
|
169
|
+
'counter-service',
|
|
170
|
+
'front-counter',
|
|
171
|
+
].includes(normalizedValue)
|
|
172
|
+
) {
|
|
173
|
+
return POS_OPERATION_MODE_COUNTER;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (
|
|
177
|
+
[
|
|
178
|
+
POS_OPERATION_MODE_WAITER,
|
|
179
|
+
'garcon',
|
|
180
|
+
'garcom',
|
|
181
|
+
'table-service',
|
|
182
|
+
].includes(normalizedValue)
|
|
183
|
+
) {
|
|
184
|
+
return POS_OPERATION_MODE_WAITER;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (
|
|
188
|
+
[
|
|
189
|
+
POS_OPERATION_MODE_TOTEM,
|
|
190
|
+
].includes(normalizedValue)
|
|
191
|
+
) {
|
|
192
|
+
return POS_OPERATION_MODE_TOTEM;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (
|
|
196
|
+
[
|
|
197
|
+
POS_OPERATION_MODE_SINGLE_ITEM,
|
|
198
|
+
'single-sale',
|
|
199
|
+
'single-item-sale',
|
|
200
|
+
'sale-unit',
|
|
201
|
+
'sale-single',
|
|
202
|
+
'venda-unitaria',
|
|
203
|
+
'venda-unica',
|
|
204
|
+
'item-unico',
|
|
205
|
+
'unit-sale',
|
|
206
|
+
'unitary-sale',
|
|
207
|
+
].includes(normalizedValue)
|
|
208
|
+
) {
|
|
209
|
+
return POS_OPERATION_MODE_SINGLE_ITEM;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (
|
|
213
|
+
[
|
|
214
|
+
POS_OPERATION_MODE_CASHIER,
|
|
215
|
+
'pdv',
|
|
216
|
+
'pos',
|
|
217
|
+
'checkout',
|
|
218
|
+
'cashier-pos',
|
|
219
|
+
].includes(normalizedValue)
|
|
220
|
+
) {
|
|
221
|
+
return POS_OPERATION_MODE_CASHIER;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return '';
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const resolvePosOperationMode = configs =>
|
|
228
|
+
normalizePosOperationMode(
|
|
229
|
+
parseConfigsObject(configs)?.[POS_OPERATION_MODE_CONFIG_KEY],
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
export const normalizePosCheckOrderType = value => {
|
|
233
|
+
const normalizedValue = String(value || '')
|
|
234
|
+
.trim()
|
|
235
|
+
.toLowerCase()
|
|
236
|
+
.normalize('NFD')
|
|
237
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
238
|
+
.replace(/[\s_]/g, '-');
|
|
239
|
+
|
|
240
|
+
if (
|
|
241
|
+
[
|
|
242
|
+
POS_CHECK_ORDER_TYPE_TAB,
|
|
243
|
+
'tab',
|
|
244
|
+
].includes(normalizedValue)
|
|
245
|
+
) {
|
|
246
|
+
return POS_CHECK_ORDER_TYPE_TAB;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (
|
|
250
|
+
[
|
|
251
|
+
POS_CHECK_ORDER_TYPE_TABLE,
|
|
252
|
+
'table',
|
|
253
|
+
].includes(normalizedValue)
|
|
254
|
+
) {
|
|
255
|
+
return POS_CHECK_ORDER_TYPE_TABLE;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return POS_CHECK_ORDER_TYPE_NONE;
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const resolvePosCheckOrderType = configs =>
|
|
262
|
+
normalizePosCheckOrderType(
|
|
263
|
+
parseConfigsObject(configs)?.[POS_CHECK_ORDER_TYPE_CONFIG_KEY],
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
export const normalizePosCheckOrderManagementMode = value => {
|
|
267
|
+
const normalizedValue = String(value || '')
|
|
268
|
+
.trim()
|
|
269
|
+
.toLowerCase()
|
|
270
|
+
.normalize('NFD')
|
|
271
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
272
|
+
.replace(/[\s_]/g, '-');
|
|
273
|
+
|
|
274
|
+
if (
|
|
275
|
+
[
|
|
276
|
+
POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
|
|
277
|
+
'existing',
|
|
278
|
+
'existing-open',
|
|
279
|
+
'opened-only',
|
|
280
|
+
'already-open',
|
|
281
|
+
'use-open-only',
|
|
282
|
+
'use-existing-only',
|
|
283
|
+
].includes(normalizedValue)
|
|
284
|
+
) {
|
|
285
|
+
return POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (
|
|
289
|
+
[
|
|
290
|
+
POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
291
|
+
'open-close',
|
|
292
|
+
'open-and-close',
|
|
293
|
+
'full',
|
|
294
|
+
'manage-open-close',
|
|
295
|
+
].includes(normalizedValue)
|
|
296
|
+
) {
|
|
297
|
+
return POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
return POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const resolvePosCheckOrderManagementMode = configs =>
|
|
304
|
+
normalizePosCheckOrderManagementMode(
|
|
305
|
+
parseConfigsObject(configs)?.[POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY],
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
export const canManagePosCheckOrders = configs =>
|
|
309
|
+
resolvePosCheckOrderManagementMode(configs) ===
|
|
310
|
+
POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE;
|
|
311
|
+
|
|
312
|
+
export const usesPosCheckLinkedOrder = configs =>
|
|
313
|
+
resolvePosCheckOrderType(configs) !== POS_CHECK_ORDER_TYPE_NONE;
|
|
314
|
+
|
|
315
|
+
export const isPosTotemMode = configs =>
|
|
316
|
+
resolvePosOperationMode(configs) === POS_OPERATION_MODE_TOTEM;
|
|
317
|
+
|
|
318
|
+
export const isPosKioskMode = isPosTotemMode;
|
|
319
|
+
|
|
320
|
+
export const isAndroidKioskEnabled = configs => {
|
|
321
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
322
|
+
const storedValue = parsedConfigs?.[DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY];
|
|
323
|
+
|
|
324
|
+
return isTruthyValue(storedValue);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export const isAndroidLauncherEnabled = configs => {
|
|
328
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
329
|
+
const storedValue =
|
|
330
|
+
parsedConfigs?.[DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY];
|
|
331
|
+
|
|
332
|
+
return isTruthyValue(storedValue);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export const isPosSingleItemMode = configs =>
|
|
336
|
+
resolvePosOperationMode(configs) === POS_OPERATION_MODE_SINGLE_ITEM;
|
|
337
|
+
|
|
338
|
+
export const shouldEnableAndroidKioskMode = ({
|
|
339
|
+
appType,
|
|
340
|
+
configs,
|
|
341
|
+
platform,
|
|
342
|
+
}) =>
|
|
343
|
+
String(appType || '').trim().toUpperCase() === 'POS' &&
|
|
344
|
+
platform === 'android' &&
|
|
345
|
+
isAndroidKioskEnabled(configs);
|
|
346
|
+
|
|
347
|
+
export const shouldEnableAndroidLauncherMode = ({
|
|
348
|
+
appType,
|
|
349
|
+
configs,
|
|
350
|
+
platform,
|
|
351
|
+
}) =>
|
|
352
|
+
String(appType || '').trim().toUpperCase() === 'POS' &&
|
|
353
|
+
platform === 'android' &&
|
|
354
|
+
isAndroidLauncherEnabled(configs);
|
|
355
|
+
|
|
356
|
+
export const isPosCounterMode = configs =>
|
|
357
|
+
resolvePosOperationMode(configs) === POS_OPERATION_MODE_COUNTER;
|
|
358
|
+
|
|
359
|
+
export const isPosSelfServiceMode = configs =>
|
|
360
|
+
isPosTotemMode(configs) || isPosCounterMode(configs);
|
|
361
|
+
|
|
362
|
+
export const resolvePosPrintMode = configs => {
|
|
363
|
+
const value = String(parseConfigsObject(configs)?.['print-mode'] || '')
|
|
364
|
+
.trim()
|
|
365
|
+
.toLowerCase();
|
|
366
|
+
|
|
367
|
+
return value === POS_PRINT_MODE_FORM
|
|
368
|
+
? POS_PRINT_MODE_FORM
|
|
369
|
+
: POS_PRINT_MODE_DEFAULT;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
export const isPosAutoPrintEnabled = configs => {
|
|
373
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
374
|
+
const storedValue = parsedConfigs?.[POS_AUTO_PRINT_ENABLED_CONFIG_KEY];
|
|
375
|
+
|
|
376
|
+
if (
|
|
377
|
+
storedValue === undefined ||
|
|
378
|
+
storedValue === null ||
|
|
379
|
+
String(storedValue).trim() === ''
|
|
380
|
+
) {
|
|
381
|
+
return !isPosCounterMode(parsedConfigs);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return isTruthyValue(storedValue);
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
export const resolvePosCashManagementMode = configs => {
|
|
388
|
+
const normalizedValue = String(
|
|
389
|
+
parseConfigsObject(configs)?.[POS_CASH_MANAGEMENT_MODE_CONFIG_KEY] || '',
|
|
390
|
+
)
|
|
391
|
+
.trim()
|
|
392
|
+
.toLowerCase()
|
|
393
|
+
.normalize('NFD')
|
|
394
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
395
|
+
.replace(/[\s_]/g, '-');
|
|
396
|
+
|
|
397
|
+
if (
|
|
398
|
+
normalizedValue === POS_CASH_MANAGEMENT_MODE_DAILY
|
|
399
|
+
) {
|
|
400
|
+
return POS_CASH_MANAGEMENT_MODE_DAILY;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (
|
|
404
|
+
normalizedValue === POS_CASH_MANAGEMENT_MODE_CASH_REGISTER
|
|
405
|
+
) {
|
|
406
|
+
return POS_CASH_MANAGEMENT_MODE_CASH_REGISTER;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
return POS_CASH_MANAGEMENT_MODE_DEFAULT;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
export const shouldUsePosCashRegisterLifecycle = configs => {
|
|
413
|
+
if (isPosTotemMode(configs)) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (isPosCounterMode(configs)) {
|
|
418
|
+
return (
|
|
419
|
+
resolvePosCashManagementMode(configs) ===
|
|
420
|
+
POS_CASH_MANAGEMENT_MODE_CASH_REGISTER
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return true;
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
export const isPosCashRegisterOpen = configs => {
|
|
428
|
+
if (!shouldUsePosCashRegisterLifecycle(configs)) {
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
433
|
+
|
|
434
|
+
if (Object.keys(parsedConfigs).length === 0) {
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const closedValue = parsedConfigs?.['cash-wallet-closed-id'];
|
|
439
|
+
|
|
440
|
+
if (closedValue === undefined || closedValue === null || closedValue === '') {
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
return closedValue === 0 || closedValue === '0';
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
export const isPosCashRegisterClosed = configs =>
|
|
448
|
+
!isPosCashRegisterOpen(configs);
|
|
449
|
+
|
|
450
|
+
export const getPosOperationModeOption = mode => {
|
|
451
|
+
const normalizedMode = normalizePosOperationMode(mode);
|
|
452
|
+
|
|
453
|
+
return POS_OPERATION_MODE_OPTIONS.find(
|
|
454
|
+
option => option.value === normalizedMode,
|
|
455
|
+
);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
export const resolveDeviceOrderVisibility = configs => {
|
|
459
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
460
|
+
const value = String(parsedConfigs?.[DEVICE_ORDER_VISIBILITY_KEY] || '')
|
|
461
|
+
.trim()
|
|
462
|
+
.toLowerCase();
|
|
463
|
+
|
|
464
|
+
return value === DEVICE_ORDER_VISIBILITY_COMPANY
|
|
465
|
+
? DEVICE_ORDER_VISIBILITY_COMPANY
|
|
466
|
+
: DEVICE_ORDER_VISIBILITY_DEVICE;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
export const canDeviceViewCompanyOrders = configs =>
|
|
470
|
+
resolveDeviceOrderVisibility(configs) === DEVICE_ORDER_VISIBILITY_COMPANY;
|
|
471
|
+
|
|
472
|
+
export const isPosDeliveryEnabled = configs => {
|
|
473
|
+
const parsedConfigs = parseConfigsObject(configs);
|
|
474
|
+
const storedValue = parsedConfigs?.[POS_DELIVERY_ENABLED_CONFIG_KEY];
|
|
475
|
+
|
|
476
|
+
if (isMissingConfigValue(storedValue)) {
|
|
477
|
+
return true;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return isTruthyValue(storedValue);
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
export const isDeviceRuntimeDebugInfoEnabled = configs =>
|
|
484
|
+
isTruthyValue(
|
|
485
|
+
parseConfigsObject(configs)?.[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY],
|
|
486
|
+
);
|
|
487
|
+
|
|
488
|
+
export const canDisplayChangePrinter = configs =>
|
|
489
|
+
isTruthyValue(
|
|
490
|
+
parseConfigsObject(configs)?.[DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY],
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
export const resolveDefaultGateway = deviceInfo => {
|
|
494
|
+
const manufacturer = String(deviceInfo?.manufacturer || '').toLowerCase();
|
|
495
|
+
const isEmulator = isTruthyValue(deviceInfo?.isEmulator);
|
|
496
|
+
|
|
497
|
+
return CIELO_DEVICES.includes(manufacturer) && !isEmulator
|
|
498
|
+
? 'cielo'
|
|
499
|
+
: 'infinite-pay';
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
export const normalizePersistedGateway = value => {
|
|
503
|
+
const normalizedValue = String(value || '')
|
|
504
|
+
.trim()
|
|
505
|
+
.toLowerCase()
|
|
506
|
+
.replace(/[\s_]/g, '-');
|
|
507
|
+
|
|
508
|
+
return SUPPORTED_POS_GATEWAYS.includes(normalizedValue)
|
|
509
|
+
? normalizedValue
|
|
510
|
+
: '';
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
export const buildDefaultDeviceConfigs = ({configs, appVersion, deviceInfo}) => {
|
|
514
|
+
let nextConfigs = parseConfigsObject(configs);
|
|
515
|
+
let needsUpdate = false;
|
|
516
|
+
|
|
517
|
+
const metricsConfigs = appendScreenMetrics(nextConfigs);
|
|
518
|
+
if (hasScreenMetricsChanges(nextConfigs, metricsConfigs)) {
|
|
519
|
+
nextConfigs = metricsConfigs;
|
|
520
|
+
needsUpdate = true;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
Object.entries(DEFAULT_DEVICE_CONFIGS).forEach(([key, defaultValue]) => {
|
|
524
|
+
if (isMissingConfigValue(nextConfigs[key])) {
|
|
525
|
+
nextConfigs[key] = defaultValue;
|
|
526
|
+
needsUpdate = true;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
if (isMissingConfigValue(nextConfigs['config-version'])) {
|
|
531
|
+
nextConfigs['config-version'] = appVersion || deviceInfo?.appVersion || '1.0.0';
|
|
532
|
+
needsUpdate = true;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (isMissingConfigValue(nextConfigs['pos-gateway'])) {
|
|
536
|
+
nextConfigs['pos-gateway'] = resolveDefaultGateway(deviceInfo);
|
|
537
|
+
needsUpdate = true;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return {nextConfigs, needsUpdate};
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
export const buildProviderManagedDeviceConfigs = ({
|
|
544
|
+
configs,
|
|
545
|
+
appVersion,
|
|
546
|
+
deviceInfo,
|
|
547
|
+
}) => {
|
|
548
|
+
let nextConfigs = parseConfigsObject(configs);
|
|
549
|
+
let needsUpdate = false;
|
|
550
|
+
|
|
551
|
+
const metricsConfigs = appendScreenMetrics(nextConfigs);
|
|
552
|
+
if (hasScreenMetricsChanges(nextConfigs, metricsConfigs)) {
|
|
553
|
+
nextConfigs = metricsConfigs;
|
|
554
|
+
needsUpdate = true;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const nextVersion = appVersion || deviceInfo?.appVersion || '1.0.0';
|
|
558
|
+
if (nextVersion && nextConfigs['config-version'] !== nextVersion) {
|
|
559
|
+
nextConfigs['config-version'] = nextVersion;
|
|
560
|
+
needsUpdate = true;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const persistedGateway = normalizePersistedGateway(nextConfigs['pos-gateway']);
|
|
564
|
+
const nextGateway = persistedGateway || resolveDefaultGateway(deviceInfo);
|
|
565
|
+
if (nextGateway && nextConfigs['pos-gateway'] !== nextGateway) {
|
|
566
|
+
nextConfigs['pos-gateway'] = nextGateway;
|
|
567
|
+
needsUpdate = true;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
return {nextConfigs, needsUpdate};
|
|
571
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
3
|
+
|
|
4
|
+
if (Platform.OS !== 'web') {
|
|
5
|
+
let store = {};
|
|
6
|
+
|
|
7
|
+
(async () => {
|
|
8
|
+
const keys = await AsyncStorage.getAllKeys();
|
|
9
|
+
const pairs = await AsyncStorage.multiGet(keys);
|
|
10
|
+
pairs.forEach(([key, value]) => {
|
|
11
|
+
store[key] = value;
|
|
12
|
+
});
|
|
13
|
+
})();
|
|
14
|
+
|
|
15
|
+
global.localStorage = {
|
|
16
|
+
getItem: key => store[key] ?? null,
|
|
17
|
+
setItem: (key, value) => {
|
|
18
|
+
store[key] = value;
|
|
19
|
+
AsyncStorage.setItem(key, value);
|
|
20
|
+
},
|
|
21
|
+
removeItem: key => {
|
|
22
|
+
delete store[key];
|
|
23
|
+
AsyncStorage.removeItem(key);
|
|
24
|
+
},
|
|
25
|
+
clear: () => {
|
|
26
|
+
store = {};
|
|
27
|
+
AsyncStorage.clear();
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|