@controleonline/ui-common 1.2.70 → 1.2.75
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/actions/workers/manager/action.yml +147 -0
- package/.github/actions/workers/qa/action.yml +44 -0
- package/.github/actions/workers/security/action.yml +44 -0
- package/.github/actions/workers/technical-documenter/action.yml +51 -0
- package/.github/workflows/manager-worker.yml +168 -0
- package/.github/workflows/publish-npm.yml +45 -0
- package/.gitmodules +3 -0
- package/AGENTS.md +6 -0
- package/README.md +14 -0
- package/package.json +32 -28
- package/src/api/fetch.js +1 -1
- package/src/api/index.js +328 -58
- package/src/react/components/AddImportModal.js +95 -111
- package/src/react/components/AnimatedModal.js +171 -0
- package/src/react/components/AnimatedModal.styles.js +21 -0
- package/src/react/components/AppTypeSwitcher.js +164 -0
- package/src/react/components/AppTypeSwitcher.styles.js +109 -0
- package/src/react/components/BackgroundRuntimeBridge.js +5 -4
- package/src/react/components/BottomNavigationBar.config.js +211 -231
- package/src/react/components/BottomNavigationBar.js +86 -31
- package/src/react/components/BottomNavigationBar.styles.js +118 -110
- package/src/react/components/CategoryForm.js +52 -35
- package/src/react/components/DefaultProvider.native.js +194 -156
- package/src/react/components/DefaultProvider.web.js +188 -112
- package/src/react/components/DeliveryPushBridge.native.js +2 -2
- package/src/react/components/DeviceAlertSoundService.js +3 -3
- package/src/react/components/KioskModeBridge.js +2 -2
- package/src/react/components/LauncherModeBridge.js +2 -2
- package/src/react/components/ManagerPushBridge.native.js +2 -2
- package/src/react/components/NetworkPrinterPreviewModal.js +249 -0
- package/src/react/components/NetworkPrinterPreviewModal.styles.js +159 -0
- package/src/react/components/RemoteCheckoutService.js +28 -20
- package/src/react/components/RuntimeBottomNavigationBar.js +146 -119
- package/src/react/components/RuntimeInfoFooter.js +137 -45
- package/src/react/components/RuntimeInfoFooter.styles.js +3 -0
- package/src/react/components/StateStore.js +258 -0
- package/src/react/components/UnifiedPaymentBar.js +7 -4
- package/src/react/components/UserAvatar.js +160 -0
- package/src/react/components/WebsocketListener.native.js +11 -11
- package/src/react/components/integrations/IntegrationHero/index.js +48 -0
- package/src/react/components/integrations/IntegrationHero/styles.js +57 -0
- package/src/react/components/integrations/IntegrationTabs/index.js +89 -0
- package/src/react/components/integrations/IntegrationTabs/styles.js +44 -0
- package/src/react/config/deviceConfigBootstrap.js +71 -30
- package/src/react/css/orders.js +72 -0
- package/src/react/pages/Connections.js +229 -0
- package/src/react/pages/Connections.styles.js +222 -0
- package/src/react/pages/DeviceDetailPage.js +2814 -0
- package/src/react/pages/DeviceDetailPage.styles.js +308 -0
- package/src/react/pages/Devices/currentDevice.js +194 -0
- package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +257 -0
- package/src/react/pages/Devices/deviceTypes/all.js +23 -0
- package/src/react/pages/Devices/deviceTypes/device.js +25 -0
- package/src/react/pages/Devices/deviceTypes/deviceListHelpers.js +178 -0
- package/src/react/pages/Devices/deviceTypes/display.js +26 -0
- package/src/react/pages/Devices/deviceTypes/index.js +145 -0
- package/src/react/pages/Devices/deviceTypes/ipCamera.js +35 -0
- package/src/react/pages/Devices/deviceTypes/pdv.js +88 -0
- package/src/react/pages/Devices/deviceTypes/printer.js +37 -0
- package/src/react/pages/Devices/deviceTypes/shared.js +453 -0
- package/src/react/pages/Devices/deviceTypes/useDeviceNetworkConnectivity.js +145 -0
- package/src/react/pages/Devices.js +183 -0
- package/src/react/pages/Devices.styles.js +353 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99ProductCard.js +1 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +181 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -0
- package/src/react/pages/Food99IntegrationPage/index.js +1530 -0
- package/src/react/pages/Food99IntegrationPage/styles.js +792 -0
- package/src/react/pages/Food99IntegrationPage/utils.js +155 -0
- package/src/react/pages/Food99IntegrationPage.js +1 -0
- package/src/react/pages/Food99IntegrationPage.styles.js +1 -0
- package/src/react/pages/GenericLogPage.js +42 -167
- package/src/react/pages/IFoodIntegrationPage/components/IFoodCatalogTab.js +8 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +420 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +103 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodProductCard.js +1 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -0
- package/src/react/pages/IFoodIntegrationPage/index.js +1298 -0
- package/src/react/pages/IFoodIntegrationPage/styles.js +764 -0
- package/src/react/pages/IFoodIntegrationPage/utils.js +91 -0
- package/src/react/pages/IFoodIntegrationPage.js +1 -0
- package/src/react/pages/IFoodIntegrationPage.styles.js +1 -0
- package/src/react/pages/Imports.js +214 -166
- package/src/react/pages/IntegrationConfigPage.js +744 -0
- package/src/react/pages/IntegrationConfigPage.styles.js +269 -0
- package/src/react/pages/Integrations.js +299 -0
- package/src/react/pages/Integrations.styles.js +130 -0
- package/src/react/pages/ManagerOrderNotificationsPage.js +642 -0
- package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -0
- package/src/react/pages/MarketplaceIntegrationPage/components/RemoteMarketplaceMenuTab.js +335 -0
- package/src/react/pages/MarketplaceIntegrationPage/index.js +60 -0
- package/src/react/pages/MarketplaceIntegrationPage/utils.js +137 -0
- package/src/react/pages/MercadoLivreIntegrationPage.js +538 -0
- package/src/react/pages/PrinterDeviceDetailPage.js +1916 -0
- package/src/react/pages/PrinterDeviceDetailPage.styles.js +223 -0
- package/src/react/pages/PrinterDeviceFormPage.js +521 -0
- package/src/react/pages/PrinterDeviceFormPage.styles.js +159 -0
- package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +484 -454
- package/src/react/pages/SettingsPage/index.js +1266 -1167
- package/src/react/pages/WhatsAppConnectionPage.js +459 -0
- package/src/react/pages/WhatsAppConnectionPage.styles.js +284 -0
- package/src/react/pages/integrationsCatalog.js +399 -0
- package/src/react/print/providers/local.js +1 -1
- package/src/react/router/publicRoutes.js +25 -0
- package/src/react/services/Cielo/Checkout.js +39 -0
- package/src/react/services/Cielo/Cielo.js +193 -0
- package/src/react/services/Cielo/Print.js +7 -0
- package/src/react/services/InfinitePay/Checkout.js +33 -0
- package/src/react/services/InfinitePay/InfinitePay.js +24 -0
- package/src/react/{utils → services}/paymentGatewayExecution.js +91 -91
- package/src/react/styles/global.js +115 -0
- package/src/react/utils/categoryContexts.js +46 -0
- package/src/react/utils/entityDisplay.js +222 -217
- package/src/react/utils/fileUrl.js +201 -16
- package/src/react/utils/integrationPage.js +16 -0
- package/src/react/utils/menuNavigation.js +31 -0
- package/src/react/utils/orderIdentity.js +277 -0
- package/src/react/utils/remotePayment.js +115 -61
- package/src/react/utils/runtimeFooter.js +40 -22
- package/src/react/utils/runtimeLanguage.js +50 -9
- package/src/react/utils/runtimeMenu.js +190 -98
- package/src/react/utils/runtimeZoom.js +43 -0
- package/src/react/utils/shopConfig.js +72 -34
- package/src/react/utils/shopFranchises.js +182 -23
- package/src/react/utils/socketRuntimePipeline.js +14 -14
- package/src/react/utils/storeColumns.js +23 -4
- package/src/react/utils/userAvatar.js +104 -0
- package/src/store/categories/index.js +48 -20
- package/src/store/configs/index.js +2 -2
- package/src/store/device_config/index.js +62 -21
- package/src/store/entity_log/index.js +22 -1
- package/src/store/imports/customActions.js +51 -0
- package/src/store/imports/index.js +89 -88
- package/src/store/status/index.js +11 -11
- package/src/store/themes/index.js +22 -0
- package/src/store/timezones/index.js +3 -1
- package/src/tests/browser/manager/connections.spec.js +143 -0
- package/src/tests/browser/manager/devices-current.spec.js +343 -0
- package/src/tests/browser/manager/mercado-livre-integration.spec.js +268 -0
- package/src/tests/react/api/deviceHeaders.test.js +114 -0
- package/src/tests/react/api/loadSmokeIndex.test.js +75 -0
- package/src/tests/react/components/AddImportModal.test.js +166 -0
- package/src/tests/react/components/BottomNavigationBar.config.test.js +20 -0
- package/src/tests/react/components/UserAvatar.test.js +52 -0
- package/src/tests/react/config/deviceConfigBootstrap.test.js +47 -0
- package/src/tests/react/pages/DevicePickerStyles.test.js +47 -0
- package/src/tests/react/pages/Devices/deviceListHelpers.test.js +39 -0
- package/src/tests/react/pages/DevicesCurrentDevice.test.js +198 -0
- package/src/tests/react/pages/connectionsHelpers.test.js +34 -0
- package/src/tests/react/pages/mercadoLivreIntegrationPageContract.test.mjs +16 -0
- package/src/tests/react/print/localPrintProvider.test.js +1 -1
- package/src/tests/react/services/Cielo.test.js +190 -0
- package/src/tests/react/store/categoriesOrdering.test.js +26 -0
- package/src/tests/react/utils/appDomain.test.js +62 -0
- package/src/tests/react/utils/entityDisplay.test.js +2 -2
- package/src/tests/react/utils/fileUrl.test.js +62 -0
- package/src/tests/react/utils/formatter.test.mjs +33 -0
- package/src/tests/react/utils/importStatus.test.js +2 -2
- package/src/tests/react/utils/orderIdentity.test.js +139 -0
- package/src/tests/react/utils/remotePayment.test.js +62 -0
- package/src/tests/react/utils/runtimeFooter.test.js +32 -9
- package/src/tests/react/utils/runtimeLanguage.test.js +80 -10
- package/src/tests/react/utils/runtimeMenu.test.js +195 -111
- package/src/tests/react/utils/runtimeZoom.test.js +38 -0
- package/src/tests/react/utils/shopConfig.test.js +75 -0
- package/src/tests/react/utils/shopFranchises.test.js +122 -12
- package/src/tests/react/utils/translate.discovery.test.mjs +170 -0
- package/src/tests/react/utils/translate.test.helpers.mjs +152 -0
- package/src/tests/react/utils/translate.test.mjs +252 -396
- package/src/tests/react/utils/userAvatar.test.js +63 -0
- package/src/utils/appDomain.js +15 -4
- package/src/utils/formatter.js +122 -16
- package/src/utils/integrationConfigs.js +1 -0
- package/src/utils/translate.js +277 -398
- package/src/utils/translateDiscovery.js +96 -0
- package/src/utils/translateNormalize.js +33 -0
- package/src/utils/translatePending.js +92 -0
- package/src/utils/translateStorage.js +142 -0
- package/.github/agents/developer.agent.md +0 -30
- package/.github/agents/devops.agent.md +0 -30
- package/.github/agents/qa.agent.md +0 -30
- package/.github/agents/security.agent.md +0 -30
- package/.github/workflows/npmjs.yml +0 -35
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import React, {useMemo} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Image,
|
|
4
|
+
Modal,
|
|
5
|
+
ScrollView,
|
|
6
|
+
Text,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import Icon from 'react-native-vector-icons/Feather';
|
|
11
|
+
|
|
12
|
+
import styles from './NetworkPrinterPreviewModal.styles';
|
|
13
|
+
|
|
14
|
+
const tt = key => global.t?.t('configs', 'printPreview', key);
|
|
15
|
+
|
|
16
|
+
const clampColumns = value => {
|
|
17
|
+
const parsedValue = Number(String(value || '').replace(/\D+/g, ''));
|
|
18
|
+
if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
|
|
19
|
+
return 48;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return Math.min(Math.max(parsedValue, 24), 80);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const safeText = value => String(value || '').trim();
|
|
26
|
+
|
|
27
|
+
const normalizePreviewLine = line => {
|
|
28
|
+
if (line && typeof line === 'object') {
|
|
29
|
+
return {
|
|
30
|
+
...line,
|
|
31
|
+
text: safeText(line.text),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
text: safeText(line),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const centerLine = (value, columns) => {
|
|
41
|
+
const text = safeText(value);
|
|
42
|
+
if (text.length >= columns) {
|
|
43
|
+
return text.slice(0, columns);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const leftPad = Math.floor((columns - text.length) / 2);
|
|
47
|
+
return `${' '.repeat(leftPad)}${text}`;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const wrapLine = (value, columns) => {
|
|
51
|
+
const words = safeText(value).split(/\s+/).filter(Boolean);
|
|
52
|
+
const lines = [];
|
|
53
|
+
let currentLine = '';
|
|
54
|
+
|
|
55
|
+
words.forEach(word => {
|
|
56
|
+
if (!currentLine) {
|
|
57
|
+
currentLine = word;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (`${currentLine} ${word}`.length <= columns) {
|
|
62
|
+
currentLine = `${currentLine} ${word}`;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
lines.push(currentLine);
|
|
67
|
+
currentLine = word;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (currentLine) {
|
|
71
|
+
lines.push(currentLine);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return lines.length > 0 ? lines : [''];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const wrapPreviewLine = (line, columns) => {
|
|
78
|
+
const normalizedLine = normalizePreviewLine(line);
|
|
79
|
+
return wrapLine(normalizedLine.text, columns).map(text => ({
|
|
80
|
+
...normalizedLine,
|
|
81
|
+
text,
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const NetworkPrinterPreviewModal = ({
|
|
86
|
+
visible = false,
|
|
87
|
+
onClose,
|
|
88
|
+
codePage = '',
|
|
89
|
+
columns,
|
|
90
|
+
documents = [],
|
|
91
|
+
error = '',
|
|
92
|
+
logoUrl = '',
|
|
93
|
+
loading = false,
|
|
94
|
+
printerModel,
|
|
95
|
+
printerManufacturer,
|
|
96
|
+
subtitle = '',
|
|
97
|
+
title = '',
|
|
98
|
+
transport,
|
|
99
|
+
}) => {
|
|
100
|
+
const normalizedColumns = useMemo(() => clampColumns(columns), [columns]);
|
|
101
|
+
const normalizedDocuments = useMemo(
|
|
102
|
+
() => (Array.isArray(documents) ? documents : []),
|
|
103
|
+
[documents],
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Modal
|
|
108
|
+
visible={visible}
|
|
109
|
+
transparent
|
|
110
|
+
animationType="fade"
|
|
111
|
+
onRequestClose={onClose}>
|
|
112
|
+
<View style={styles.backdrop}>
|
|
113
|
+
<View style={styles.panel}>
|
|
114
|
+
<View style={styles.header}>
|
|
115
|
+
<View style={styles.headerCopy}>
|
|
116
|
+
<Text style={styles.title}>{title || tt('title') || 'Visualizacao da impressao'}</Text>
|
|
117
|
+
<Text style={styles.subtitle}>
|
|
118
|
+
{subtitle ||
|
|
119
|
+
tt('subtitle') ||
|
|
120
|
+
'Simulacao local para conferir largura, quebras e campos do cupom.'}
|
|
121
|
+
</Text>
|
|
122
|
+
</View>
|
|
123
|
+
<TouchableOpacity
|
|
124
|
+
style={styles.closeButton}
|
|
125
|
+
activeOpacity={0.85}
|
|
126
|
+
onPress={onClose}>
|
|
127
|
+
<Icon name="x" size={18} color="#0F172A" />
|
|
128
|
+
</TouchableOpacity>
|
|
129
|
+
</View>
|
|
130
|
+
|
|
131
|
+
<ScrollView contentContainerStyle={styles.content}>
|
|
132
|
+
<View style={styles.metaGrid}>
|
|
133
|
+
<View style={styles.metaChip}>
|
|
134
|
+
<Text style={styles.metaText}>
|
|
135
|
+
{`${normalizedColumns} ${tt('columns') || 'colunas'}`}
|
|
136
|
+
</Text>
|
|
137
|
+
</View>
|
|
138
|
+
<View style={styles.metaChip}>
|
|
139
|
+
<Text style={styles.metaText}>
|
|
140
|
+
{`${tt('codePage') || 'Code page'}: ${safeText(codePage) || 'cp850'}`}
|
|
141
|
+
</Text>
|
|
142
|
+
</View>
|
|
143
|
+
<View style={styles.metaChip}>
|
|
144
|
+
<Text style={styles.metaText}>
|
|
145
|
+
{safeText(transport) || tt('transportFallback') || 'tcp-raw'}
|
|
146
|
+
</Text>
|
|
147
|
+
</View>
|
|
148
|
+
<View style={styles.metaChip}>
|
|
149
|
+
<Text style={styles.metaText}>
|
|
150
|
+
{[printerManufacturer, printerModel]
|
|
151
|
+
.map(safeText)
|
|
152
|
+
.filter(Boolean)
|
|
153
|
+
.join(' ') || tt('modelMissing') || 'Modelo nao informado'}
|
|
154
|
+
</Text>
|
|
155
|
+
</View>
|
|
156
|
+
</View>
|
|
157
|
+
|
|
158
|
+
{loading ? (
|
|
159
|
+
<View style={styles.stateBox}>
|
|
160
|
+
<Text style={styles.stateText}>{tt('loadingRealData') || 'Carregando dados reais...'}</Text>
|
|
161
|
+
</View>
|
|
162
|
+
) : error ? (
|
|
163
|
+
<View style={styles.errorBox}>
|
|
164
|
+
<Text style={styles.errorText}>{error}</Text>
|
|
165
|
+
</View>
|
|
166
|
+
) : normalizedDocuments.length > 0 ? (
|
|
167
|
+
normalizedDocuments.map((document, index) => {
|
|
168
|
+
const lines = Array.isArray(document?.lines)
|
|
169
|
+
? document.lines
|
|
170
|
+
: [];
|
|
171
|
+
const defaultHeaderLines = document?.hideDefaultHeader
|
|
172
|
+
? []
|
|
173
|
+
: [
|
|
174
|
+
{
|
|
175
|
+
text: centerLine(
|
|
176
|
+
document?.title || `${tt('copy') || 'Via'} ${index + 1}`,
|
|
177
|
+
normalizedColumns,
|
|
178
|
+
),
|
|
179
|
+
},
|
|
180
|
+
document?.subtitle
|
|
181
|
+
? {text: centerLine(document.subtitle, normalizedColumns)}
|
|
182
|
+
: null,
|
|
183
|
+
{text: '-'.repeat(normalizedColumns)},
|
|
184
|
+
].filter(Boolean);
|
|
185
|
+
const paperLines = [
|
|
186
|
+
...defaultHeaderLines,
|
|
187
|
+
...lines.flatMap(line => wrapPreviewLine(line, normalizedColumns)),
|
|
188
|
+
].filter(Boolean);
|
|
189
|
+
const receiptWidth = normalizedColumns * 8;
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<View key={`${document?.title || 'preview'}-${index}`}>
|
|
193
|
+
{index > 0 ? (
|
|
194
|
+
<View style={styles.cutLine}>
|
|
195
|
+
<Text style={styles.cutText}>{tt('cutLine') || 'picote'}</Text>
|
|
196
|
+
</View>
|
|
197
|
+
) : null}
|
|
198
|
+
<View style={styles.paper}>
|
|
199
|
+
<View style={[styles.receiptWrap, {width: receiptWidth}]}>
|
|
200
|
+
{logoUrl && !document?.hideLogo ? (
|
|
201
|
+
<View style={styles.logoWrap}>
|
|
202
|
+
<Image
|
|
203
|
+
source={{uri: logoUrl}}
|
|
204
|
+
style={styles.logo}
|
|
205
|
+
resizeMode="contain"
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
208
|
+
) : null}
|
|
209
|
+
{paperLines.map((line, lineIndex) => (
|
|
210
|
+
<Text
|
|
211
|
+
key={`${document?.title || 'preview'}-${index}-${lineIndex}`}
|
|
212
|
+
style={[
|
|
213
|
+
styles.receiptText,
|
|
214
|
+
line.center ? styles.receiptTextCenter : null,
|
|
215
|
+
line.bold ? styles.receiptTextBold : null,
|
|
216
|
+
line.reverse ? styles.receiptTextReverse : null,
|
|
217
|
+
line.reverse && line.center
|
|
218
|
+
? styles.receiptTextReverseCenter
|
|
219
|
+
: null,
|
|
220
|
+
line.large ? styles.receiptTextLarge : null,
|
|
221
|
+
]}>
|
|
222
|
+
{line.text || ' '}
|
|
223
|
+
</Text>
|
|
224
|
+
))}
|
|
225
|
+
</View>
|
|
226
|
+
</View>
|
|
227
|
+
</View>
|
|
228
|
+
);
|
|
229
|
+
})
|
|
230
|
+
) : (
|
|
231
|
+
<View style={styles.stateBox}>
|
|
232
|
+
<Text style={styles.stateText}>
|
|
233
|
+
{tt('emptyData') || 'Nenhum dado real encontrado para visualizar.'}
|
|
234
|
+
</Text>
|
|
235
|
+
</View>
|
|
236
|
+
)}
|
|
237
|
+
|
|
238
|
+
<Text style={styles.hint}>
|
|
239
|
+
{tt('hint') ||
|
|
240
|
+
'Esta visualizacao ainda nao envia dados para a impressora. Os blocos separados simulam os cortes de papel usados pelas filas.'}
|
|
241
|
+
</Text>
|
|
242
|
+
</ScrollView>
|
|
243
|
+
</View>
|
|
244
|
+
</View>
|
|
245
|
+
</Modal>
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export default NetworkPrinterPreviewModal;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {Platform, StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
backdrop: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
backgroundColor: 'rgba(15,23,42,0.42)',
|
|
7
|
+
justifyContent: 'center',
|
|
8
|
+
padding: 16,
|
|
9
|
+
},
|
|
10
|
+
panel: {
|
|
11
|
+
maxHeight: '88%',
|
|
12
|
+
borderRadius: 16,
|
|
13
|
+
backgroundColor: '#fff',
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
},
|
|
16
|
+
header: {
|
|
17
|
+
borderBottomWidth: 1,
|
|
18
|
+
borderBottomColor: '#E2E8F0',
|
|
19
|
+
paddingHorizontal: 16,
|
|
20
|
+
paddingVertical: 14,
|
|
21
|
+
flexDirection: 'row',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
gap: 12,
|
|
24
|
+
},
|
|
25
|
+
headerCopy: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
gap: 4,
|
|
28
|
+
},
|
|
29
|
+
title: {
|
|
30
|
+
fontSize: 16,
|
|
31
|
+
fontWeight: '800',
|
|
32
|
+
color: '#0F172A',
|
|
33
|
+
},
|
|
34
|
+
subtitle: {
|
|
35
|
+
fontSize: 12,
|
|
36
|
+
color: '#64748B',
|
|
37
|
+
lineHeight: 17,
|
|
38
|
+
},
|
|
39
|
+
closeButton: {
|
|
40
|
+
width: 36,
|
|
41
|
+
height: 36,
|
|
42
|
+
borderRadius: 10,
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
backgroundColor: '#F1F5F9',
|
|
46
|
+
},
|
|
47
|
+
content: {
|
|
48
|
+
padding: 16,
|
|
49
|
+
gap: 12,
|
|
50
|
+
},
|
|
51
|
+
metaGrid: {
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
flexWrap: 'wrap',
|
|
54
|
+
gap: 8,
|
|
55
|
+
},
|
|
56
|
+
metaChip: {
|
|
57
|
+
borderRadius: 999,
|
|
58
|
+
backgroundColor: '#E0F2FE',
|
|
59
|
+
paddingHorizontal: 10,
|
|
60
|
+
paddingVertical: 6,
|
|
61
|
+
},
|
|
62
|
+
metaText: {
|
|
63
|
+
fontSize: 11,
|
|
64
|
+
fontWeight: '800',
|
|
65
|
+
color: '#075985',
|
|
66
|
+
},
|
|
67
|
+
paper: {
|
|
68
|
+
borderWidth: 1,
|
|
69
|
+
borderColor: '#CBD5E1',
|
|
70
|
+
borderRadius: 12,
|
|
71
|
+
backgroundColor: '#F8FAFC',
|
|
72
|
+
padding: 12,
|
|
73
|
+
},
|
|
74
|
+
receiptWrap: {
|
|
75
|
+
alignSelf: 'center',
|
|
76
|
+
maxWidth: '100%',
|
|
77
|
+
},
|
|
78
|
+
logoWrap: {
|
|
79
|
+
alignItems: 'center',
|
|
80
|
+
marginBottom: 8,
|
|
81
|
+
},
|
|
82
|
+
logo: {
|
|
83
|
+
width: 96,
|
|
84
|
+
height: 40,
|
|
85
|
+
},
|
|
86
|
+
cutLine: {
|
|
87
|
+
marginVertical: 12,
|
|
88
|
+
borderTopWidth: 1,
|
|
89
|
+
borderTopColor: '#94A3B8',
|
|
90
|
+
borderStyle: 'dashed',
|
|
91
|
+
alignItems: 'center',
|
|
92
|
+
},
|
|
93
|
+
cutText: {
|
|
94
|
+
marginTop: -9,
|
|
95
|
+
paddingHorizontal: 8,
|
|
96
|
+
backgroundColor: '#fff',
|
|
97
|
+
fontSize: 11,
|
|
98
|
+
fontWeight: '800',
|
|
99
|
+
color: '#64748B',
|
|
100
|
+
textTransform: 'uppercase',
|
|
101
|
+
},
|
|
102
|
+
receiptText: {
|
|
103
|
+
fontFamily: Platform.select({
|
|
104
|
+
ios: 'Courier',
|
|
105
|
+
android: 'monospace',
|
|
106
|
+
default: 'monospace',
|
|
107
|
+
}),
|
|
108
|
+
fontSize: 12,
|
|
109
|
+
lineHeight: 17,
|
|
110
|
+
color: '#0F172A',
|
|
111
|
+
},
|
|
112
|
+
receiptTextCenter: {
|
|
113
|
+
textAlign: 'center',
|
|
114
|
+
},
|
|
115
|
+
receiptTextBold: {
|
|
116
|
+
fontWeight: '800',
|
|
117
|
+
},
|
|
118
|
+
receiptTextLarge: {
|
|
119
|
+
fontSize: 22,
|
|
120
|
+
lineHeight: 28,
|
|
121
|
+
fontWeight: '900',
|
|
122
|
+
},
|
|
123
|
+
receiptTextReverse: {
|
|
124
|
+
alignSelf: 'flex-start',
|
|
125
|
+
backgroundColor: '#0F172A',
|
|
126
|
+
color: '#F8FAFC',
|
|
127
|
+
paddingHorizontal: 3,
|
|
128
|
+
},
|
|
129
|
+
receiptTextReverseCenter: {
|
|
130
|
+
alignSelf: 'stretch',
|
|
131
|
+
},
|
|
132
|
+
hint: {
|
|
133
|
+
fontSize: 12,
|
|
134
|
+
lineHeight: 18,
|
|
135
|
+
color: '#64748B',
|
|
136
|
+
},
|
|
137
|
+
stateBox: {
|
|
138
|
+
borderRadius: 12,
|
|
139
|
+
backgroundColor: '#F1F5F9',
|
|
140
|
+
padding: 14,
|
|
141
|
+
},
|
|
142
|
+
stateText: {
|
|
143
|
+
fontSize: 13,
|
|
144
|
+
fontWeight: '700',
|
|
145
|
+
color: '#475569',
|
|
146
|
+
},
|
|
147
|
+
errorBox: {
|
|
148
|
+
borderRadius: 12,
|
|
149
|
+
backgroundColor: '#FEF2F2',
|
|
150
|
+
padding: 14,
|
|
151
|
+
},
|
|
152
|
+
errorText: {
|
|
153
|
+
fontSize: 13,
|
|
154
|
+
fontWeight: '700',
|
|
155
|
+
color: '#B91C1C',
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
export default styles;
|
|
@@ -2,17 +2,18 @@ import React, {useEffect, useCallback, useRef} from 'react';
|
|
|
2
2
|
|
|
3
3
|
import {api} from '@controleonline/ui-common/src/api';
|
|
4
4
|
import Formatter from '@controleonline/ui-common/src/utils/formatter';
|
|
5
|
+
import {
|
|
6
|
+
createInvoiceForGatewayFreePayment,
|
|
7
|
+
isGatewayFreePayment,
|
|
8
|
+
} from '@controleonline/ui-common/src/react/utils/cashPayment';
|
|
9
|
+
import {
|
|
10
|
+
normalizeGatewayPaymentError,
|
|
11
|
+
runConfiguredGatewayPayment,
|
|
12
|
+
} from '../services/paymentGatewayExecution';
|
|
5
13
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
normalizeGatewayPaymentError,
|
|
11
|
-
runConfiguredGatewayPayment,
|
|
12
|
-
} from '@controleonline/ui-common/src/react/utils/paymentGatewayExecution';
|
|
13
|
-
import {
|
|
14
|
-
buildRemotePaymentResultMessage,
|
|
15
|
-
isRemotePaymentRequestMessage,
|
|
14
|
+
buildRemotePaymentResultMessage,
|
|
15
|
+
isRemotePaymentCancellation,
|
|
16
|
+
isRemotePaymentRequestMessage,
|
|
16
17
|
normalizeRemotePaymentRequestKey,
|
|
17
18
|
} from '@controleonline/ui-common/src/react/utils/remotePayment';
|
|
18
19
|
|
|
@@ -255,16 +256,23 @@ const Checkout = () => {
|
|
|
255
256
|
paidAmount,
|
|
256
257
|
status: 'success',
|
|
257
258
|
});
|
|
258
|
-
} catch (error) {
|
|
259
|
-
const errorMessage = normalizeGatewayPaymentError(
|
|
260
|
-
error,
|
|
261
|
-
'Nao foi possivel concluir o pagamento remoto.',
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
error: errorMessage,
|
|
266
|
-
|
|
267
|
-
|
|
259
|
+
} catch (error) {
|
|
260
|
+
const errorMessage = normalizeGatewayPaymentError(
|
|
261
|
+
error,
|
|
262
|
+
'Nao foi possivel concluir o pagamento remoto.',
|
|
263
|
+
);
|
|
264
|
+
const wasCanceled = isRemotePaymentCancellation({
|
|
265
|
+
status: error?.status,
|
|
266
|
+
error: errorMessage,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
if (!wasCanceled) {
|
|
270
|
+
invoiceActions.setError(errorMessage);
|
|
271
|
+
}
|
|
272
|
+
await sendRemoteResult({
|
|
273
|
+
error: errorMessage,
|
|
274
|
+
status: wasCanceled ? 'canceled' : 'error',
|
|
275
|
+
});
|
|
268
276
|
} finally {
|
|
269
277
|
clear();
|
|
270
278
|
processingMessageKeyRef.current = '';
|