@controleonline/ui-common 1.2.80 → 1.2.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +8 -0
- package/package.json +9 -3
- package/src/api/fetch.js +7 -7
- package/src/react/components/AddImportModal.js +6 -2
- package/src/react/components/BackgroundRuntimeBridge.js +201 -215
- package/src/react/components/ConfirmModal.js +44 -9
- package/src/react/components/ConfirmModal.styles.js +55 -41
- package/src/react/components/CopyDeviceConfigModal.js +193 -0
- package/src/react/components/CopyDeviceConfigModal.styles.js +123 -0
- package/src/react/components/DefaultProvider.native.js +22 -0
- package/src/react/components/DefaultProvider.web.js +25 -1
- package/src/react/components/EntityLogBranch.js +482 -0
- package/src/react/components/EntityLogCards.js +369 -0
- package/src/react/components/EntityLogContent.js +113 -794
- package/src/react/components/LinkedOrderProductsTab.js +3 -3
- package/src/react/components/PrintService.js +130 -409
- package/src/react/components/RemoteCheckoutService.js +2 -2
- package/src/react/components/RuntimeBottomNavigationBar.js +141 -146
- package/src/react/components/RuntimeFooterMarqueeText.js +137 -0
- package/src/react/components/RuntimeInfoFooter.js +12 -15
- package/src/react/components/SystemErrorToast.js +49 -29
- package/src/react/components/SystemErrorToast.styles.js +43 -38
- package/src/react/components/UserAvatar.js +120 -28
- package/src/react/config/deviceConfigBootstrap.js +330 -304
- package/src/react/hooks/usePrintSpoolEffects.js +161 -0
- package/src/react/pages/DeviceDetailPage.js +6 -2882
- package/src/react/pages/Devices/detail/DeviceDetailAlertsCommandsSection.js +233 -0
- package/src/react/pages/Devices/detail/DeviceDetailHeader.js +138 -0
- package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +167 -0
- package/src/react/pages/Devices/detail/DeviceDetailOrdersPrintSection.js +216 -0
- package/src/react/pages/Devices/detail/DeviceDetailPaymentSection.js +44 -0
- package/src/react/pages/Devices/detail/DeviceDetailPdvConfigSection.js +390 -0
- package/src/react/pages/Devices/detail/DeviceDetailRenderers.js +135 -0
- package/src/react/pages/Devices/detail/DeviceDetailScreen.js +495 -0
- package/src/react/pages/Devices/detail/OptionButtonChip.js +65 -0
- package/src/react/pages/Devices/detail/deviceDetailConstants.js +36 -0
- package/src/react/pages/Devices/detail/deviceDetailHelpers.js +70 -0
- package/src/react/pages/Devices/detail/useDeviceDetailActions.js +483 -0
- package/src/react/pages/Devices/detail/useDeviceDetailCopyConfig.js +87 -0
- package/src/react/pages/Devices/detail/useDeviceDetailLoaders.js +327 -0
- package/src/react/pages/Devices/detail/useDeviceDetailSaves.js +429 -0
- package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +489 -0
- package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +98 -0
- package/src/react/pages/Devices/deviceTypes/index.js +2 -0
- package/src/react/pages/Devices/deviceTypes/pdv.js +11 -0
- package/src/react/pages/Imports.js +3 -2
- package/src/react/pages/IntegrationConfigFields.js +126 -0
- package/src/react/pages/IntegrationConfigPage.js +122 -591
- package/src/react/pages/IntegrationConfigPage.utils.js +95 -0
- package/src/react/print/usePrintButtonController.js +9 -1
- package/src/react/services/Getnet/Checkout.js +81 -0
- package/src/react/services/Getnet/Getnet.js +77 -0
- package/src/react/services/paymentGatewayExecution.js +20 -0
- package/src/react/utils/bottomNavigationToolbar.js +161 -0
- package/src/react/utils/commercialDocumentOrders.js +18 -6
- package/src/react/utils/copyDeviceConfigs.js +198 -0
- package/src/react/utils/fileUrl.js +43 -0
- package/src/react/utils/importStatus.js +19 -10
- package/src/react/utils/logSettings.js +7 -7
- package/src/react/utils/maintenanceSettings.js +16 -0
- package/src/react/utils/paymentDevices.js +6 -0
- package/src/react/utils/printManagedPrinter.js +45 -0
- package/src/react/utils/printRouting.js +63 -0
- package/src/react/utils/printSpoolUtils.js +119 -0
- package/src/react/utils/printerDevices.js +368 -368
- package/src/react/utils/runtimeFooter.js +10 -19
- package/src/react/utils/shopFranchises.js +186 -65
- package/src/react/utils/systemErrorMessage.js +71 -67
- package/src/store/device_config/customActions.js +119 -30
- package/src/tests/browser/manager/bottom-navigation-role-toolbar.spec.js +353 -0
- package/src/tests/browser/manager/device-detail-alias-save.spec.js +345 -0
- package/src/tests/browser/manager/device-detail-copy-config.spec.js +365 -0
- package/src/tests/browser/manager/runtime-footer-marquee.spec.js +262 -0
- package/src/tests/browser/manager/theme-confirm-toast.spec.js +236 -0
- package/src/tests/react/components/RuntimeFooterMarqueeText.test.js +171 -0
- package/src/tests/react/components/UserAvatar.test.js +6 -2
- package/src/tests/react/components/themeAwareModals.test.mjs +60 -0
- package/src/tests/react/config/deviceConfigBootstrap.test.js +104 -66
- package/src/tests/react/pages/deviceDetailDelete.test.js +78 -0
- package/src/tests/react/pages/receitaFederalIntegrationContract.test.mjs +48 -0
- package/src/tests/react/utils/bottomNavigationToolbar.test.js +222 -0
- package/src/tests/react/utils/copyDeviceConfigs.test.mjs +127 -0
- package/src/tests/react/utils/fileUrl.test.js +38 -0
- package/src/tests/react/utils/importStatus.test.js +26 -9
- package/src/tests/react/utils/passwordPolicy.test.js +27 -0
- package/src/tests/react/utils/printRouting.test.mjs +86 -0
- package/src/tests/react/utils/printSpoolUtils.test.mjs +52 -0
- package/src/tests/react/utils/runtimeFooter.test.js +7 -0
- package/src/tests/react/utils/shopFranchises.test.js +121 -115
- package/src/tests/react/utils/systemErrorMessage.test.js +32 -59
|
@@ -1,2882 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { api } from '@controleonline/ui-common/src/api';
|
|
8
|
-
import Formatter from '@controleonline/ui-common/src/utils/formatter';
|
|
9
|
-
import StateStore from '@controleonline/ui-common/src/react/components/StateStore';
|
|
10
|
-
import PaymentTypesByWalletTab from '@controleonline/ui-common/src/react/pages/SettingsPage/PaymentTypesByWalletTab';
|
|
11
|
-
import { appendScreenMetrics } from '@controleonline/ui-common/src/react/utils/screenMetrics';
|
|
12
|
-
import { useMessage } from '@controleonline/ui-common/src/react/components/MessageService';
|
|
13
|
-
import { resolveThemePalette, withOpacity } from '@controleonline/../../src/styles/branding';
|
|
14
|
-
import { colors } from '@controleonline/../../src/styles/colors';
|
|
15
|
-
import Icon from 'react-native-vector-icons/Feather';
|
|
16
|
-
import styles from './DeviceDetailPage.styles';
|
|
17
|
-
import packageJson from '@package';
|
|
18
|
-
import DefaultTooltip from '@controleonline/ui-default/src/react/components/help/DefaultTooltip';
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
canDisplayChangePrinter,
|
|
22
|
-
DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY,
|
|
23
|
-
DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY,
|
|
24
|
-
DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY,
|
|
25
|
-
DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY,
|
|
26
|
-
DEVICE_ALERT_SOUND_ENABLED_KEY,
|
|
27
|
-
DEVICE_ALERT_SOUND_URL_KEY,
|
|
28
|
-
DEVICE_ORDER_VISIBILITY_COMPANY,
|
|
29
|
-
DEVICE_ORDER_VISIBILITY_DEVICE,
|
|
30
|
-
DEVICE_ORDER_VISIBILITY_KEY,
|
|
31
|
-
DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY,
|
|
32
|
-
isPosAutoPrintEnabled,
|
|
33
|
-
isPosCashRegisterOpen,
|
|
34
|
-
isTruthyValue,
|
|
35
|
-
parseConfigsObject,
|
|
36
|
-
POS_AUTO_PRINT_ENABLED_CONFIG_KEY,
|
|
37
|
-
POS_CASH_MANAGEMENT_MODE_CASH_REGISTER,
|
|
38
|
-
POS_CASH_MANAGEMENT_MODE_CONFIG_KEY,
|
|
39
|
-
POS_CASH_MANAGEMENT_MODE_DAILY,
|
|
40
|
-
POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY,
|
|
41
|
-
POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
|
|
42
|
-
POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
43
|
-
POS_CHECK_ORDER_TYPE_CONFIG_KEY,
|
|
44
|
-
POS_CHECK_ORDER_TYPE_NONE,
|
|
45
|
-
POS_CHECK_ORDER_TYPE_TAB,
|
|
46
|
-
POS_CHECK_ORDER_TYPE_TABLE,
|
|
47
|
-
POS_CHECK_ORDER_TYPE_STAMP,
|
|
48
|
-
POS_DELIVERY_ENABLED_CONFIG_KEY,
|
|
49
|
-
POS_OPERATION_MODE_COUNTER,
|
|
50
|
-
POS_OPERATION_MODE_CONFIG_KEY,
|
|
51
|
-
POS_OPERATION_MODE_OPTIONS,
|
|
52
|
-
POS_PRODUCT_SHOWCASE_CONFIG_KEY,
|
|
53
|
-
POS_PRINT_MODE_FORM,
|
|
54
|
-
POS_PRINT_MODE_ORDER,
|
|
55
|
-
getPosOperationModeOption,
|
|
56
|
-
isAndroidKioskEnabled,
|
|
57
|
-
isAndroidLauncherEnabled,
|
|
58
|
-
isPosDeliveryEnabled,
|
|
59
|
-
resolvePosCheckOrderManagementMode,
|
|
60
|
-
resolvePosCheckOrderType,
|
|
61
|
-
resolvePosCheckOrderTypeForShop,
|
|
62
|
-
resolveDeviceOrderVisibility,
|
|
63
|
-
resolvePosCashManagementMode,
|
|
64
|
-
resolvePosOperationMode,
|
|
65
|
-
resolvePosPrintMode,
|
|
66
|
-
} from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
|
|
67
|
-
import { buildDeviceAliasStoreUpdates } from '@controleonline/ui-common/src/react/utils/deviceAliasSync';
|
|
68
|
-
|
|
69
|
-
import {
|
|
70
|
-
filterDeviceConfigsByCompany,
|
|
71
|
-
getCompanyPaymentDeviceOptions,
|
|
72
|
-
getPaymentGatewayFromConfigs,
|
|
73
|
-
getPaymentGatewayLabel,
|
|
74
|
-
isPaymentCapableDeviceConfig,
|
|
75
|
-
isPdvPrinterEnabled,
|
|
76
|
-
normalizeDeviceId,
|
|
77
|
-
normalizeEntityId,
|
|
78
|
-
PAYMENT_TYPE_IDS_CONFIG_KEY,
|
|
79
|
-
PAYMENT_GATEWAY_CIELO,
|
|
80
|
-
PDV_PRINTER_ENABLED_CONFIG_KEY,
|
|
81
|
-
ORDER_PAYMENT_DEVICE_CONFIG_KEY,
|
|
82
|
-
POS_GATEWAY_CONFIG_KEY,
|
|
83
|
-
} from '@controleonline/ui-common/src/react/utils/paymentDevices';
|
|
84
|
-
import {
|
|
85
|
-
normalizeBooleanConfig,
|
|
86
|
-
SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
|
|
87
|
-
} from '@controleonline/ui-common/src/react/utils/shopConfig';
|
|
88
|
-
|
|
89
|
-
import {
|
|
90
|
-
getPrinterOptionValue,
|
|
91
|
-
getDeviceTypeLabel,
|
|
92
|
-
getPrinterLabel,
|
|
93
|
-
getPrinterOptions,
|
|
94
|
-
} from '@controleonline/ui-common/src/react/utils/printerDevices';
|
|
95
|
-
|
|
96
|
-
import { inlineStyle_667_12, inlineStyle_1301_61 } from './DeviceDetailPage.styles';
|
|
97
|
-
|
|
98
|
-
const hex = {
|
|
99
|
-
success: '#10b981',
|
|
100
|
-
danger: '#c10015',
|
|
101
|
-
warning: '#e67e22',
|
|
102
|
-
info: '#0EA5E9',
|
|
103
|
-
purple: '#8B5CF6',
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const PAYMENT_ICONS = {
|
|
107
|
-
dinheiro: 'dollar-sign',
|
|
108
|
-
pix: 'zap',
|
|
109
|
-
debito: 'credit-card',
|
|
110
|
-
credito: 'credit-card',
|
|
111
|
-
default: 'hash',
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const paymentIcon = label => {
|
|
115
|
-
const l = String(label || '').toLowerCase();
|
|
116
|
-
if (l.includes('pix')) return PAYMENT_ICONS.pix;
|
|
117
|
-
if (l.includes('debit')) return PAYMENT_ICONS.debito;
|
|
118
|
-
if (l.includes('crédit') || l.includes('credit')) return PAYMENT_ICONS.credito;
|
|
119
|
-
if (l.includes('dinh')) return PAYMENT_ICONS.dinheiro;
|
|
120
|
-
return PAYMENT_ICONS.default;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const DISPLAY_DEVICE_TYPE = 'DISPLAY';
|
|
124
|
-
const PDV_DEVICE_TYPE = 'PDV';
|
|
125
|
-
const DISPLAY_DEVICE_LINK_CONFIG_KEY = 'display-id';
|
|
126
|
-
const DISPLAY_DEVICE_PRINTER_CONFIG_KEY = 'printer';
|
|
127
|
-
const tt = (type, key) => global.t?.t('configs', type, key);
|
|
128
|
-
|
|
129
|
-
const PDV_TAB_OPERATION = 'operation';
|
|
130
|
-
const PDV_TAB_ORDERS = 'orders';
|
|
131
|
-
const PDV_TAB_DEVICE = 'device';
|
|
132
|
-
const PDV_TAB_PAYMENT_TYPES = 'payment-types';
|
|
133
|
-
const PDV_TAB_MOVEMENT = 'movement';
|
|
134
|
-
|
|
135
|
-
const PDV_DETAIL_TABS = [
|
|
136
|
-
{key: PDV_TAB_OPERATION, icon: 'sliders', labelKey: 'pdvOperation'},
|
|
137
|
-
{key: PDV_TAB_ORDERS, icon: 'list', labelKey: 'pdvOrders'},
|
|
138
|
-
{key: PDV_TAB_DEVICE, icon: 'cpu', labelKey: 'pdvDevice'},
|
|
139
|
-
{key: PDV_TAB_PAYMENT_TYPES, icon: 'credit-card', labelKey: 'pdvPayments'},
|
|
140
|
-
{key: PDV_TAB_MOVEMENT, icon: 'bar-chart-2', labelKey: 'pdvMovement'},
|
|
141
|
-
];
|
|
142
|
-
|
|
143
|
-
const formatApiError = (error, fallback) => {
|
|
144
|
-
if (typeof error === 'string') {
|
|
145
|
-
return error.trim() || fallback;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (Array.isArray(error?.message)) {
|
|
149
|
-
return (
|
|
150
|
-
error.message
|
|
151
|
-
.map(item => item?.message || item?.title || String(item || '').trim())
|
|
152
|
-
.filter(Boolean)
|
|
153
|
-
.join('\n') || fallback
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return error?.message || error?.description || fallback;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const getDisplayLabel = display => {
|
|
161
|
-
const name = String(display?.display || '').trim();
|
|
162
|
-
const type = String(display?.displayType || '').trim().toUpperCase();
|
|
163
|
-
|
|
164
|
-
if (name && type) {
|
|
165
|
-
return `${name} (${type})`;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (name) {
|
|
169
|
-
return name;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return `Display #${normalizeEntityId(display) || '--'}`;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
const getProductShowcaseLabel = showcase => {
|
|
176
|
-
const name = String(showcase?.name || '').trim();
|
|
177
|
-
const externalCode = String(showcase?.externalStoreCode || '').trim();
|
|
178
|
-
if (name && externalCode) return `${name} (${externalCode})`;
|
|
179
|
-
return name || `Vitrine #${normalizeEntityId(showcase) || '--'}`;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const getIsOpen = configs => {
|
|
183
|
-
return isPosCashRegisterOpen(configs);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const confirm = (msg, cb) => {
|
|
187
|
-
if (Platform.OS === 'web') {
|
|
188
|
-
if (window.confirm(msg)) cb();
|
|
189
|
-
} else {
|
|
190
|
-
Alert.alert('Confirmação', msg, [
|
|
191
|
-
{ text: 'Cancelar', style: 'cancel' },
|
|
192
|
-
{ text: 'Confirmar', onPress: cb },
|
|
193
|
-
]);
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const getDeviceSwitchProps = ({
|
|
198
|
-
disabled = false,
|
|
199
|
-
palette,
|
|
200
|
-
value = false,
|
|
201
|
-
}) => {
|
|
202
|
-
const offTrackColor = disabled
|
|
203
|
-
? palette.switchDisabledTrack
|
|
204
|
-
: palette.switchOffTrack;
|
|
205
|
-
const onTrackColor = disabled
|
|
206
|
-
? palette.switchDisabledTrack
|
|
207
|
-
: palette.switchOnTrack;
|
|
208
|
-
|
|
209
|
-
return {
|
|
210
|
-
ios_backgroundColor: offTrackColor,
|
|
211
|
-
thumbColor: disabled
|
|
212
|
-
? palette.switchDisabledThumb
|
|
213
|
-
: value
|
|
214
|
-
? palette.switchOnThumb
|
|
215
|
-
: palette.switchOffThumb,
|
|
216
|
-
trackColor: {
|
|
217
|
-
false: offTrackColor,
|
|
218
|
-
true: onTrackColor,
|
|
219
|
-
},
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const OptionButtonChip = ({
|
|
224
|
-
label,
|
|
225
|
-
selected,
|
|
226
|
-
disabled,
|
|
227
|
-
colors: optionColors,
|
|
228
|
-
tooltip,
|
|
229
|
-
onPress,
|
|
230
|
-
}) => {
|
|
231
|
-
const [hovered, setHovered] = useState(false);
|
|
232
|
-
const showTooltip = Platform.OS === 'web' && disabled && Boolean(tooltip) && hovered;
|
|
233
|
-
|
|
234
|
-
return (
|
|
235
|
-
<Pressable
|
|
236
|
-
onHoverIn={() => setHovered(true)}
|
|
237
|
-
onHoverOut={() => setHovered(false)}
|
|
238
|
-
style={[styles.optionButtonHoverWrap, hovered && styles.optionButtonHoverWrapActive]}
|
|
239
|
-
>
|
|
240
|
-
<TouchableOpacity
|
|
241
|
-
style={[
|
|
242
|
-
styles.optionButton,
|
|
243
|
-
selected && styles.optionButtonActive,
|
|
244
|
-
optionColors && {
|
|
245
|
-
backgroundColor: selected
|
|
246
|
-
? optionColors.buttonBackground
|
|
247
|
-
: optionColors.buttonBackgroundSecondary,
|
|
248
|
-
borderColor: selected
|
|
249
|
-
? optionColors.buttonBorder
|
|
250
|
-
: optionColors.buttonBorderSecondary,
|
|
251
|
-
},
|
|
252
|
-
disabled && {opacity: 0.55},
|
|
253
|
-
]}
|
|
254
|
-
accessibilityHint={tooltip || undefined}
|
|
255
|
-
activeOpacity={disabled ? 1 : 0.85}
|
|
256
|
-
disabled={disabled}
|
|
257
|
-
onPress={disabled ? undefined : onPress}
|
|
258
|
-
>
|
|
259
|
-
<Text
|
|
260
|
-
style={[
|
|
261
|
-
styles.optionButtonText,
|
|
262
|
-
selected && styles.optionButtonTextActive,
|
|
263
|
-
optionColors && {
|
|
264
|
-
color: selected
|
|
265
|
-
? optionColors.buttonText
|
|
266
|
-
: optionColors.buttonTextSecondary,
|
|
267
|
-
},
|
|
268
|
-
]}
|
|
269
|
-
>
|
|
270
|
-
{label}
|
|
271
|
-
</Text>
|
|
272
|
-
</TouchableOpacity>
|
|
273
|
-
|
|
274
|
-
{showTooltip ? (
|
|
275
|
-
<View pointerEvents="none" style={styles.optionButtonTooltip}>
|
|
276
|
-
<Text style={styles.optionButtonTooltipText}>{tooltip}</Text>
|
|
277
|
-
</View>
|
|
278
|
-
) : null}
|
|
279
|
-
</Pressable>
|
|
280
|
-
);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const DeviceDetailPage = () => {
|
|
284
|
-
const route = useRoute();
|
|
285
|
-
const navigation = useNavigation();
|
|
286
|
-
const {
|
|
287
|
-
deviceId: routeDeviceId,
|
|
288
|
-
} = route.params || {};
|
|
289
|
-
const deviceId = useMemo(
|
|
290
|
-
() => normalizeEntityId(routeDeviceId),
|
|
291
|
-
[routeDeviceId],
|
|
292
|
-
);
|
|
293
|
-
|
|
294
|
-
const invoiceStore = useStore('invoice');
|
|
295
|
-
const deviceConfigStore = useStore('device_config');
|
|
296
|
-
const deviceStore = useStore('device');
|
|
297
|
-
const displayStore = useStore('displays');
|
|
298
|
-
const peopleStore = useStore('people');
|
|
299
|
-
const printerStore = useStore('printer');
|
|
300
|
-
const themeStore = useStore('theme');
|
|
301
|
-
const websocketStore = useStore('websocket');
|
|
302
|
-
const messageApi = useMessage() || {};
|
|
303
|
-
|
|
304
|
-
const { currentCompany } = peopleStore.getters;
|
|
305
|
-
const { item: runtimeDevice } = deviceStore.getters;
|
|
306
|
-
const { item: runtimeDeviceConfig } = deviceConfigStore.getters;
|
|
307
|
-
const { items: displays = [], isLoading: isLoadingDisplays } = displayStore.getters;
|
|
308
|
-
const { items: printers = [], isLoading: isLoadingPrinters } = printerStore.getters;
|
|
309
|
-
const { colors: themeColors } = themeStore.getters;
|
|
310
|
-
const websocketActions = websocketStore.actions;
|
|
311
|
-
const runtimeCompanyConfigs = useMemo(
|
|
312
|
-
() => parseConfigsObject(currentCompany?.configs),
|
|
313
|
-
[currentCompany?.configs],
|
|
314
|
-
);
|
|
315
|
-
const showSystemError = useCallback(
|
|
316
|
-
(error, fallback) => {
|
|
317
|
-
messageApi.showError?.(formatApiError(error, fallback));
|
|
318
|
-
},
|
|
319
|
-
[messageApi],
|
|
320
|
-
);
|
|
321
|
-
const loyaltyCouponsEnabled = useMemo(
|
|
322
|
-
() => {
|
|
323
|
-
const hasLoyaltyCouponsEnabledKey = Object.prototype.hasOwnProperty.call(
|
|
324
|
-
runtimeCompanyConfigs || {},
|
|
325
|
-
SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
|
|
326
|
-
);
|
|
327
|
-
|
|
328
|
-
return hasLoyaltyCouponsEnabledKey
|
|
329
|
-
? normalizeBooleanConfig(
|
|
330
|
-
runtimeCompanyConfigs?.[SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY],
|
|
331
|
-
)
|
|
332
|
-
: true;
|
|
333
|
-
},
|
|
334
|
-
[runtimeCompanyConfigs],
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
const currentDevice =
|
|
338
|
-
deviceId &&
|
|
339
|
-
normalizeEntityId(runtimeDevice?.id || runtimeDevice?.['@id']) === deviceId
|
|
340
|
-
? runtimeDevice
|
|
341
|
-
: {};
|
|
342
|
-
const currentDeviceConfig =
|
|
343
|
-
deviceId &&
|
|
344
|
-
normalizeEntityId(
|
|
345
|
-
runtimeDeviceConfig?.device?.id ||
|
|
346
|
-
runtimeDeviceConfig?.device?.['@id'] ||
|
|
347
|
-
runtimeDeviceConfig?.deviceId ||
|
|
348
|
-
runtimeDeviceConfig?.device?.deviceId,
|
|
349
|
-
) === deviceId
|
|
350
|
-
? runtimeDeviceConfig
|
|
351
|
-
: {};
|
|
352
|
-
const deviceString = String(
|
|
353
|
-
currentDevice?.device || currentDeviceConfig?.device?.device || '',
|
|
354
|
-
).trim();
|
|
355
|
-
const deviceType = String(
|
|
356
|
-
currentDevice?.type ||
|
|
357
|
-
currentDevice?.deviceType ||
|
|
358
|
-
currentDeviceConfig?.type ||
|
|
359
|
-
currentDeviceConfig?.device?.type ||
|
|
360
|
-
'',
|
|
361
|
-
)
|
|
362
|
-
.trim()
|
|
363
|
-
.toUpperCase();
|
|
364
|
-
const normalizedInitialConfigs = useMemo(
|
|
365
|
-
() => parseConfigsObject(currentDeviceConfig?.configs),
|
|
366
|
-
[currentDeviceConfig?.configs],
|
|
367
|
-
);
|
|
368
|
-
const initialAlias = String(
|
|
369
|
-
currentDevice?.alias || currentDeviceConfig?.device?.alias || currentDevice?.device || '',
|
|
370
|
-
).trim();
|
|
371
|
-
const isDisplayDevice = deviceType === DISPLAY_DEVICE_TYPE;
|
|
372
|
-
const isPdvDevice = deviceType === PDV_DEVICE_TYPE;
|
|
373
|
-
|
|
374
|
-
const actionsRef = useRef({});
|
|
375
|
-
const stampAutoDisableSignatureRef = useRef('');
|
|
376
|
-
actionsRef.current = {
|
|
377
|
-
invoiceActions: invoiceStore.actions,
|
|
378
|
-
deviceConfigActions: deviceConfigStore.actions,
|
|
379
|
-
deviceActions: deviceStore.actions,
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const brandColors = useMemo(
|
|
383
|
-
() => resolveThemePalette({ ...themeColors, ...(currentCompany?.theme?.colors || {}) }, colors),
|
|
384
|
-
[themeColors, currentCompany?.id],
|
|
385
|
-
);
|
|
386
|
-
|
|
387
|
-
const [products, setProducts] = useState([]);
|
|
388
|
-
const [productShowcases, setProductShowcases] = useState([]);
|
|
389
|
-
const [companyDeviceConfigs, setCompanyDeviceConfigs] = useState([]);
|
|
390
|
-
const [inflowData, setInflowData] = useState(null);
|
|
391
|
-
const [configs, setConfigs] = useState(normalizedInitialConfigs || {});
|
|
392
|
-
const [loadingConfigData, setLoadingConfigData] = useState(false);
|
|
393
|
-
const [loadingCompanyDeviceConfigs, setLoadingCompanyDeviceConfigs] =
|
|
394
|
-
useState(false);
|
|
395
|
-
const [loadingMovementData, setLoadingMovementData] = useState(false);
|
|
396
|
-
const [actionLoading, setActionLoading] = useState(false);
|
|
397
|
-
const [activePdvTab, setActivePdvTab] = useState(PDV_TAB_OPERATION);
|
|
398
|
-
const [savingPaymentTarget, setSavingPaymentTarget] = useState(false);
|
|
399
|
-
const [savingPdvSettings, setSavingPdvSettings] = useState(false);
|
|
400
|
-
const [savingPaymentTypes, setSavingPaymentTypes] = useState(false);
|
|
401
|
-
const [savingPosOperationMode, setSavingPosOperationMode] = useState(false);
|
|
402
|
-
const [savingProductShowcase, setSavingProductShowcase] = useState(false);
|
|
403
|
-
const [savingLauncherMode, setSavingLauncherMode] = useState(false);
|
|
404
|
-
const [savingAlertSound, setSavingAlertSound] = useState(false);
|
|
405
|
-
const [savingOrderVisibility, setSavingOrderVisibility] = useState(false);
|
|
406
|
-
const [savingDeviceDeliverySettings, setSavingDeviceDeliverySettings] =
|
|
407
|
-
useState(false);
|
|
408
|
-
const [savingRuntimeDebugInfo, setSavingRuntimeDebugInfo] = useState(false);
|
|
409
|
-
const [sendingCatalogRefresh, setSendingCatalogRefresh] = useState(false);
|
|
410
|
-
const [loadingProductShowcases, setLoadingProductShowcases] = useState(false);
|
|
411
|
-
const [search, setSearch] = useState('');
|
|
412
|
-
const [devicePaymentTarget, setDevicePaymentTarget] = useState(
|
|
413
|
-
normalizeDeviceId(normalizedInitialConfigs?.[ORDER_PAYMENT_DEVICE_CONFIG_KEY]),
|
|
414
|
-
);
|
|
415
|
-
const [pdvGateway, setPdvGateway] = useState(
|
|
416
|
-
getPaymentGatewayFromConfigs(normalizedInitialConfigs),
|
|
417
|
-
);
|
|
418
|
-
const [pdvPrinterEnabled, setPdvPrinterEnabled] = useState(
|
|
419
|
-
isPdvPrinterEnabled(normalizedInitialConfigs),
|
|
420
|
-
);
|
|
421
|
-
const [posOperationMode, setPosOperationMode] = useState(
|
|
422
|
-
resolvePosOperationMode(normalizedInitialConfigs),
|
|
423
|
-
);
|
|
424
|
-
const [productShowcaseId, setProductShowcaseId] = useState(
|
|
425
|
-
normalizeEntityId(normalizedInitialConfigs?.[POS_PRODUCT_SHOWCASE_CONFIG_KEY]),
|
|
426
|
-
);
|
|
427
|
-
const [androidKioskEnabled, setAndroidKioskEnabled] = useState(
|
|
428
|
-
isAndroidKioskEnabled(normalizedInitialConfigs),
|
|
429
|
-
);
|
|
430
|
-
const [androidLauncherEnabled, setAndroidLauncherEnabled] = useState(
|
|
431
|
-
isAndroidLauncherEnabled(normalizedInitialConfigs),
|
|
432
|
-
);
|
|
433
|
-
const [counterAutoPrintEnabled, setCounterAutoPrintEnabled] = useState(
|
|
434
|
-
isPosAutoPrintEnabled(normalizedInitialConfigs),
|
|
435
|
-
);
|
|
436
|
-
const [counterPrintMode, setCounterPrintMode] = useState(
|
|
437
|
-
resolvePosPrintMode(normalizedInitialConfigs),
|
|
438
|
-
);
|
|
439
|
-
const [counterCashManagementMode, setCounterCashManagementMode] = useState(
|
|
440
|
-
resolvePosCashManagementMode(normalizedInitialConfigs),
|
|
441
|
-
);
|
|
442
|
-
const [checkOrderType, setCheckOrderType] = useState(
|
|
443
|
-
resolvePosCheckOrderTypeForShop(
|
|
444
|
-
normalizedInitialConfigs,
|
|
445
|
-
runtimeCompanyConfigs,
|
|
446
|
-
),
|
|
447
|
-
);
|
|
448
|
-
const [checkOrderManagementMode, setCheckOrderManagementMode] = useState(
|
|
449
|
-
resolvePosCheckOrderManagementMode(normalizedInitialConfigs),
|
|
450
|
-
);
|
|
451
|
-
const [deviceOrderVisibility, setDeviceOrderVisibility] = useState(
|
|
452
|
-
resolveDeviceOrderVisibility(normalizedInitialConfigs),
|
|
453
|
-
);
|
|
454
|
-
const [deviceDeliveryEnabled, setDeviceDeliveryEnabled] = useState(
|
|
455
|
-
isPosDeliveryEnabled(normalizedInitialConfigs),
|
|
456
|
-
);
|
|
457
|
-
const [deviceAlertSoundEnabled, setDeviceAlertSoundEnabled] = useState(
|
|
458
|
-
isTruthyValue(normalizedInitialConfigs?.[DEVICE_ALERT_SOUND_ENABLED_KEY]),
|
|
459
|
-
);
|
|
460
|
-
const [deviceAlertSoundUrl, setDeviceAlertSoundUrl] = useState(
|
|
461
|
-
String(normalizedInitialConfigs?.[DEVICE_ALERT_SOUND_URL_KEY] || ''),
|
|
462
|
-
);
|
|
463
|
-
const [deviceRuntimeDebugInfoEnabled, setDeviceRuntimeDebugInfoEnabled] =
|
|
464
|
-
useState(
|
|
465
|
-
isTruthyValue(
|
|
466
|
-
normalizedInitialConfigs?.[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY],
|
|
467
|
-
),
|
|
468
|
-
);
|
|
469
|
-
const [linkedDisplayId, setLinkedDisplayId] = useState(
|
|
470
|
-
normalizeEntityId(normalizedInitialConfigs?.[DISPLAY_DEVICE_LINK_CONFIG_KEY]),
|
|
471
|
-
);
|
|
472
|
-
const [displayPrinterId, setDisplayPrinterId] = useState(
|
|
473
|
-
normalizeDeviceId(normalizedInitialConfigs?.[DISPLAY_DEVICE_PRINTER_CONFIG_KEY]),
|
|
474
|
-
);
|
|
475
|
-
const [displayAllowPrinterChange, setDisplayAllowPrinterChange] = useState(
|
|
476
|
-
canDisplayChangePrinter(normalizedInitialConfigs),
|
|
477
|
-
);
|
|
478
|
-
const [displayAutoPrintProductEnabled, setDisplayAutoPrintProductEnabled] =
|
|
479
|
-
useState(
|
|
480
|
-
isTruthyValue(
|
|
481
|
-
normalizedInitialConfigs?.[DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY],
|
|
482
|
-
),
|
|
483
|
-
);
|
|
484
|
-
const [savingDisplayPrintingConfig, setSavingDisplayPrintingConfig] = useState(false);
|
|
485
|
-
const [hasLoadedCurrentConfig, setHasLoadedCurrentConfig] = useState(false);
|
|
486
|
-
const [hasLoadedCompanyConfigs, setHasLoadedCompanyConfigs] = useState(false);
|
|
487
|
-
const [hasLoadedMovementData, setHasLoadedMovementData] = useState(false);
|
|
488
|
-
const hasLoadedCurrentConfigRef = useRef(false);
|
|
489
|
-
const hasLoadedCompanyConfigsRef = useRef(false);
|
|
490
|
-
const hasLoadedMovementDataRef = useRef(false);
|
|
491
|
-
const hasInitializedPdvTabRef = useRef(false);
|
|
492
|
-
|
|
493
|
-
// Edição inline do alias
|
|
494
|
-
const [alias, setAlias] = useState(initialAlias || '');
|
|
495
|
-
const [editingAlias, setEditingAlias] = useState(false);
|
|
496
|
-
const [aliasInput, setAliasInput] = useState(alias);
|
|
497
|
-
const [savingAlias, setSavingAlias] = useState(false);
|
|
498
|
-
const [removingDevice, setRemovingDevice] = useState(false);
|
|
499
|
-
const aliasInputRef = useRef(null);
|
|
500
|
-
const skipAliasSyncFromStoreRef = useRef(false);
|
|
501
|
-
|
|
502
|
-
useEffect(() => {
|
|
503
|
-
if (editingAlias) {
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
if (skipAliasSyncFromStoreRef.current) {
|
|
507
|
-
skipAliasSyncFromStoreRef.current = false;
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
setAlias(initialAlias || '');
|
|
512
|
-
setAliasInput(initialAlias || '');
|
|
513
|
-
}, [editingAlias, initialAlias]);
|
|
514
|
-
|
|
515
|
-
useEffect(() => {
|
|
516
|
-
hasLoadedCurrentConfigRef.current = hasLoadedCurrentConfig;
|
|
517
|
-
}, [hasLoadedCurrentConfig]);
|
|
518
|
-
|
|
519
|
-
useEffect(() => {
|
|
520
|
-
hasLoadedCompanyConfigsRef.current = hasLoadedCompanyConfigs;
|
|
521
|
-
}, [hasLoadedCompanyConfigs]);
|
|
522
|
-
|
|
523
|
-
useEffect(() => {
|
|
524
|
-
hasLoadedMovementDataRef.current = hasLoadedMovementData;
|
|
525
|
-
}, [hasLoadedMovementData]);
|
|
526
|
-
|
|
527
|
-
const isOpen = useMemo(() => getIsOpen(configs), [configs]);
|
|
528
|
-
const hasLocalPaymentGateway = useMemo(
|
|
529
|
-
() =>
|
|
530
|
-
isPaymentCapableDeviceConfig({
|
|
531
|
-
configs,
|
|
532
|
-
type: deviceType,
|
|
533
|
-
device: {type: deviceType},
|
|
534
|
-
}),
|
|
535
|
-
[configs, deviceType],
|
|
536
|
-
);
|
|
537
|
-
const paymentDeviceOptions = useMemo(
|
|
538
|
-
() =>
|
|
539
|
-
getCompanyPaymentDeviceOptions(
|
|
540
|
-
filterDeviceConfigsByCompany(companyDeviceConfigs, currentCompany?.id),
|
|
541
|
-
).filter(
|
|
542
|
-
option => option.deviceId !== deviceString,
|
|
543
|
-
),
|
|
544
|
-
[companyDeviceConfigs, currentCompany?.id, deviceString],
|
|
545
|
-
);
|
|
546
|
-
const displayOptions = useMemo(
|
|
547
|
-
() =>
|
|
548
|
-
(Array.isArray(displays) ? displays : [])
|
|
549
|
-
.filter(option => {
|
|
550
|
-
const companyId = normalizeEntityId(option?.company?.id || option?.company);
|
|
551
|
-
const currentCompanyId = normalizeEntityId(currentCompany?.id);
|
|
552
|
-
return !currentCompanyId || !companyId || companyId === currentCompanyId;
|
|
553
|
-
})
|
|
554
|
-
.sort((left, right) =>
|
|
555
|
-
String(left?.display || '').localeCompare(String(right?.display || '')),
|
|
556
|
-
),
|
|
557
|
-
[currentCompany?.id, displays],
|
|
558
|
-
);
|
|
559
|
-
const printerOptions = useMemo(
|
|
560
|
-
() =>
|
|
561
|
-
getPrinterOptions({
|
|
562
|
-
printers,
|
|
563
|
-
deviceConfigs: companyDeviceConfigs,
|
|
564
|
-
companyId: currentCompany?.id,
|
|
565
|
-
}),
|
|
566
|
-
[companyDeviceConfigs, currentCompany?.id, printers],
|
|
567
|
-
);
|
|
568
|
-
const selectedPosOperationModeOption = useMemo(
|
|
569
|
-
() => getPosOperationModeOption(posOperationMode),
|
|
570
|
-
[posOperationMode],
|
|
571
|
-
);
|
|
572
|
-
const pickerMode = Platform.OS === 'android' ? 'dropdown' : undefined;
|
|
573
|
-
const packageVersion = packageJson?.version || packageJson?.default?.version;
|
|
574
|
-
const appVersion = packageVersion || runtimeDevice?.appVersion || '';
|
|
575
|
-
const runtimeDeviceId = useMemo(
|
|
576
|
-
() => normalizeDeviceId(runtimeDevice?.id || runtimeDevice?.device),
|
|
577
|
-
[runtimeDevice?.device, runtimeDevice?.id],
|
|
578
|
-
);
|
|
579
|
-
const runtimeDeviceType = useMemo(
|
|
580
|
-
() =>
|
|
581
|
-
String(runtimeDevice?.type || runtimeDevice?.deviceType || '')
|
|
582
|
-
.trim()
|
|
583
|
-
.toUpperCase(),
|
|
584
|
-
[runtimeDevice?.deviceType, runtimeDevice?.type],
|
|
585
|
-
);
|
|
586
|
-
const isEditingRuntimeDevice = useMemo(
|
|
587
|
-
() =>
|
|
588
|
-
!!runtimeDeviceId &&
|
|
589
|
-
runtimeDeviceId === normalizeDeviceId(deviceString) &&
|
|
590
|
-
runtimeDeviceType === deviceType,
|
|
591
|
-
[deviceString, deviceType, runtimeDeviceId, runtimeDeviceType],
|
|
592
|
-
);
|
|
593
|
-
|
|
594
|
-
const resolveDeviceContext = useCallback(async () => {
|
|
595
|
-
if (deviceString && deviceType) {
|
|
596
|
-
return {
|
|
597
|
-
deviceData: null,
|
|
598
|
-
deviceString,
|
|
599
|
-
deviceType,
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if (!deviceId) {
|
|
604
|
-
return {
|
|
605
|
-
deviceData: null,
|
|
606
|
-
deviceString: '',
|
|
607
|
-
deviceType: '',
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
const fetchedDevice = await actionsRef.current.deviceActions
|
|
612
|
-
.get(deviceId)
|
|
613
|
-
.catch(() => null);
|
|
614
|
-
|
|
615
|
-
return {
|
|
616
|
-
deviceData: fetchedDevice,
|
|
617
|
-
deviceString: String(fetchedDevice?.device || '').trim(),
|
|
618
|
-
deviceType: String(fetchedDevice?.type || fetchedDevice?.deviceType || '')
|
|
619
|
-
.trim()
|
|
620
|
-
.toUpperCase(),
|
|
621
|
-
};
|
|
622
|
-
}, [deviceId, deviceString, deviceType]);
|
|
623
|
-
|
|
624
|
-
const applyCurrentDeviceConfig = useCallback((scopedItems, context = {}) => {
|
|
625
|
-
const currentDeviceString = String(
|
|
626
|
-
context.deviceString || deviceString || '',
|
|
627
|
-
).trim();
|
|
628
|
-
const currentDeviceType = String(
|
|
629
|
-
context.deviceType || deviceType || '',
|
|
630
|
-
)
|
|
631
|
-
.trim()
|
|
632
|
-
.toUpperCase();
|
|
633
|
-
const currentDeviceConfigId = normalizeEntityId(
|
|
634
|
-
context.deviceId || deviceId,
|
|
635
|
-
);
|
|
636
|
-
const dc = (scopedItems || []).find(d => {
|
|
637
|
-
const currentConfigType = String(d?.type || d?.device?.type || '')
|
|
638
|
-
.trim()
|
|
639
|
-
.toUpperCase();
|
|
640
|
-
const nextDeviceId = normalizeEntityId(
|
|
641
|
-
d?.device?.id ||
|
|
642
|
-
d?.device?.['@id'] ||
|
|
643
|
-
d?.deviceId ||
|
|
644
|
-
d?.device?.deviceId,
|
|
645
|
-
);
|
|
646
|
-
|
|
647
|
-
if (currentDeviceConfigId && nextDeviceId === currentDeviceConfigId) {
|
|
648
|
-
return true;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
return (
|
|
652
|
-
d?.device?.device === currentDeviceString &&
|
|
653
|
-
currentConfigType === currentDeviceType
|
|
654
|
-
);
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
if (dc) {
|
|
658
|
-
const nextConfigs = parseConfigsObject(dc.configs);
|
|
659
|
-
actionsRef.current.deviceConfigActions.setItem({
|
|
660
|
-
...dc,
|
|
661
|
-
configs: nextConfigs,
|
|
662
|
-
});
|
|
663
|
-
setConfigs(nextConfigs);
|
|
664
|
-
setDevicePaymentTarget(
|
|
665
|
-
normalizeDeviceId(nextConfigs[ORDER_PAYMENT_DEVICE_CONFIG_KEY]),
|
|
666
|
-
);
|
|
667
|
-
setPdvGateway(getPaymentGatewayFromConfigs(nextConfigs));
|
|
668
|
-
setPdvPrinterEnabled(isPdvPrinterEnabled(nextConfigs));
|
|
669
|
-
setPosOperationMode(resolvePosOperationMode(nextConfigs));
|
|
670
|
-
setProductShowcaseId(
|
|
671
|
-
normalizeEntityId(nextConfigs[POS_PRODUCT_SHOWCASE_CONFIG_KEY]),
|
|
672
|
-
);
|
|
673
|
-
setAndroidKioskEnabled(isAndroidKioskEnabled(nextConfigs));
|
|
674
|
-
setAndroidLauncherEnabled(isAndroidLauncherEnabled(nextConfigs));
|
|
675
|
-
setCounterAutoPrintEnabled(isPosAutoPrintEnabled(nextConfigs));
|
|
676
|
-
setCounterPrintMode(resolvePosPrintMode(nextConfigs));
|
|
677
|
-
setCounterCashManagementMode(resolvePosCashManagementMode(nextConfigs));
|
|
678
|
-
setCheckOrderType(
|
|
679
|
-
resolvePosCheckOrderTypeForShop(nextConfigs, runtimeCompanyConfigs),
|
|
680
|
-
);
|
|
681
|
-
setCheckOrderManagementMode(
|
|
682
|
-
resolvePosCheckOrderManagementMode(nextConfigs),
|
|
683
|
-
);
|
|
684
|
-
setDeviceOrderVisibility(
|
|
685
|
-
resolveDeviceOrderVisibility(nextConfigs),
|
|
686
|
-
);
|
|
687
|
-
setDeviceDeliveryEnabled(
|
|
688
|
-
isPosDeliveryEnabled(nextConfigs),
|
|
689
|
-
);
|
|
690
|
-
setDeviceAlertSoundEnabled(
|
|
691
|
-
isTruthyValue(nextConfigs[DEVICE_ALERT_SOUND_ENABLED_KEY]),
|
|
692
|
-
);
|
|
693
|
-
setDeviceAlertSoundUrl(
|
|
694
|
-
String(nextConfigs[DEVICE_ALERT_SOUND_URL_KEY] || ''),
|
|
695
|
-
);
|
|
696
|
-
setDeviceRuntimeDebugInfoEnabled(
|
|
697
|
-
isTruthyValue(nextConfigs[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY]),
|
|
698
|
-
);
|
|
699
|
-
setLinkedDisplayId(
|
|
700
|
-
normalizeEntityId(nextConfigs[DISPLAY_DEVICE_LINK_CONFIG_KEY]),
|
|
701
|
-
);
|
|
702
|
-
setDisplayPrinterId(
|
|
703
|
-
normalizeDeviceId(nextConfigs[DISPLAY_DEVICE_PRINTER_CONFIG_KEY]),
|
|
704
|
-
);
|
|
705
|
-
setDisplayAllowPrinterChange(
|
|
706
|
-
canDisplayChangePrinter(nextConfigs),
|
|
707
|
-
);
|
|
708
|
-
setDisplayAutoPrintProductEnabled(
|
|
709
|
-
isTruthyValue(nextConfigs[DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY]),
|
|
710
|
-
);
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
actionsRef.current.deviceConfigActions.setItem({});
|
|
715
|
-
|
|
716
|
-
setConfigs({});
|
|
717
|
-
setDevicePaymentTarget('');
|
|
718
|
-
setPdvGateway('');
|
|
719
|
-
setPdvPrinterEnabled(true);
|
|
720
|
-
setPosOperationMode(resolvePosOperationMode({}));
|
|
721
|
-
setProductShowcaseId('');
|
|
722
|
-
setAndroidKioskEnabled(false);
|
|
723
|
-
setAndroidLauncherEnabled(false);
|
|
724
|
-
setCounterAutoPrintEnabled(isPosAutoPrintEnabled({}));
|
|
725
|
-
setCounterPrintMode(resolvePosPrintMode({}));
|
|
726
|
-
setCounterCashManagementMode(resolvePosCashManagementMode({}));
|
|
727
|
-
setCheckOrderType(
|
|
728
|
-
resolvePosCheckOrderTypeForShop({}, runtimeCompanyConfigs),
|
|
729
|
-
);
|
|
730
|
-
setCheckOrderManagementMode(resolvePosCheckOrderManagementMode({}));
|
|
731
|
-
setDeviceOrderVisibility(DEVICE_ORDER_VISIBILITY_DEVICE);
|
|
732
|
-
setDeviceDeliveryEnabled(isPosDeliveryEnabled({}));
|
|
733
|
-
setDeviceAlertSoundEnabled(false);
|
|
734
|
-
setDeviceAlertSoundUrl('');
|
|
735
|
-
setDeviceRuntimeDebugInfoEnabled(false);
|
|
736
|
-
setLinkedDisplayId('');
|
|
737
|
-
setDisplayPrinterId('');
|
|
738
|
-
setDisplayAllowPrinterChange(false);
|
|
739
|
-
setDisplayAutoPrintProductEnabled(false);
|
|
740
|
-
}, [deviceId, deviceString, deviceType]);
|
|
741
|
-
|
|
742
|
-
const loadMovementData = useCallback(async () => {
|
|
743
|
-
if (!isPdvDevice) {
|
|
744
|
-
setProducts([]);
|
|
745
|
-
setInflowData(null);
|
|
746
|
-
setHasLoadedMovementData(false);
|
|
747
|
-
return;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
if (!currentCompany?.id) return;
|
|
751
|
-
const resolvedContext = await resolveDeviceContext();
|
|
752
|
-
const nextDeviceString = resolvedContext?.deviceString || deviceString;
|
|
753
|
-
if (!nextDeviceString) return;
|
|
754
|
-
setLoadingMovementData(true);
|
|
755
|
-
try {
|
|
756
|
-
const [cashData, inflowRaw] = await Promise.all([
|
|
757
|
-
actionsRef.current.invoiceActions.getCashRegister({
|
|
758
|
-
device: nextDeviceString,
|
|
759
|
-
provider: currentCompany.id,
|
|
760
|
-
}),
|
|
761
|
-
actionsRef.current.invoiceActions.getInflow({
|
|
762
|
-
'device.device': nextDeviceString,
|
|
763
|
-
receiver: currentCompany.id,
|
|
764
|
-
}),
|
|
765
|
-
]);
|
|
766
|
-
|
|
767
|
-
setProducts(Array.isArray(cashData) ? cashData : []);
|
|
768
|
-
|
|
769
|
-
// getInflow retorna data['member'] = [{ payments: {...} }]
|
|
770
|
-
const member = Array.isArray(inflowRaw) ? inflowRaw : [];
|
|
771
|
-
setInflowData(member[0]?.payments || null);
|
|
772
|
-
} catch {
|
|
773
|
-
setProducts([]);
|
|
774
|
-
setInflowData(null);
|
|
775
|
-
} finally {
|
|
776
|
-
setLoadingMovementData(false);
|
|
777
|
-
setHasLoadedMovementData(true);
|
|
778
|
-
}
|
|
779
|
-
}, [currentCompany?.id, deviceString, isPdvDevice, resolveDeviceContext]);
|
|
780
|
-
|
|
781
|
-
const refreshCurrentConfig = useCallback(async () => {
|
|
782
|
-
if (!currentCompany?.id) return;
|
|
783
|
-
setLoadingConfigData(true);
|
|
784
|
-
try {
|
|
785
|
-
const resolvedContext = await resolveDeviceContext();
|
|
786
|
-
const nextDeviceString = resolvedContext?.deviceString || deviceString;
|
|
787
|
-
const nextDeviceType = resolvedContext?.deviceType || deviceType;
|
|
788
|
-
if (!nextDeviceString || !nextDeviceType) {
|
|
789
|
-
applyCurrentDeviceConfig([], {
|
|
790
|
-
deviceId,
|
|
791
|
-
deviceString: nextDeviceString,
|
|
792
|
-
deviceType: nextDeviceType,
|
|
793
|
-
});
|
|
794
|
-
return;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
const items = await actionsRef.current.deviceConfigActions.getItems({
|
|
798
|
-
'device.device': nextDeviceString,
|
|
799
|
-
people: `/people/${currentCompany.id}`,
|
|
800
|
-
type: nextDeviceType,
|
|
801
|
-
});
|
|
802
|
-
const scopedItems = filterDeviceConfigsByCompany(items, currentCompany?.id);
|
|
803
|
-
const selectedDeviceConfig = scopedItems.find(d => {
|
|
804
|
-
const currentConfigType = String(d?.type || d?.device?.type || '')
|
|
805
|
-
.trim()
|
|
806
|
-
.toUpperCase();
|
|
807
|
-
const nextDeviceId = normalizeEntityId(
|
|
808
|
-
d?.device?.id ||
|
|
809
|
-
d?.device?.['@id'] ||
|
|
810
|
-
d?.deviceId ||
|
|
811
|
-
d?.device?.deviceId,
|
|
812
|
-
);
|
|
813
|
-
|
|
814
|
-
return (
|
|
815
|
-
(deviceId && nextDeviceId === deviceId) ||
|
|
816
|
-
(d?.device?.device === nextDeviceString &&
|
|
817
|
-
currentConfigType === nextDeviceType)
|
|
818
|
-
);
|
|
819
|
-
});
|
|
820
|
-
|
|
821
|
-
if (selectedDeviceConfig) {
|
|
822
|
-
actionsRef.current.deviceConfigActions.setItem({
|
|
823
|
-
...selectedDeviceConfig,
|
|
824
|
-
configs: parseConfigsObject(selectedDeviceConfig.configs),
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
applyCurrentDeviceConfig(
|
|
829
|
-
selectedDeviceConfig ? [selectedDeviceConfig] : scopedItems,
|
|
830
|
-
{
|
|
831
|
-
deviceId,
|
|
832
|
-
deviceString: nextDeviceString,
|
|
833
|
-
deviceType: nextDeviceType,
|
|
834
|
-
},
|
|
835
|
-
);
|
|
836
|
-
} catch {
|
|
837
|
-
applyCurrentDeviceConfig([], {deviceId});
|
|
838
|
-
} finally {
|
|
839
|
-
setLoadingConfigData(false);
|
|
840
|
-
setHasLoadedCurrentConfig(true);
|
|
841
|
-
}
|
|
842
|
-
}, [
|
|
843
|
-
applyCurrentDeviceConfig,
|
|
844
|
-
currentCompany?.id,
|
|
845
|
-
deviceString,
|
|
846
|
-
deviceType,
|
|
847
|
-
deviceId,
|
|
848
|
-
resolveDeviceContext,
|
|
849
|
-
]);
|
|
850
|
-
|
|
851
|
-
const loadCompanyConfigs = useCallback(async () => {
|
|
852
|
-
if (!currentCompany?.id) return;
|
|
853
|
-
|
|
854
|
-
setLoadingCompanyDeviceConfigs(true);
|
|
855
|
-
try {
|
|
856
|
-
const items = await actionsRef.current.deviceConfigActions.getItems({
|
|
857
|
-
people: `/people/${currentCompany.id}`,
|
|
858
|
-
});
|
|
859
|
-
const scopedItems = filterDeviceConfigsByCompany(items, currentCompany?.id);
|
|
860
|
-
setCompanyDeviceConfigs(Array.isArray(scopedItems) ? scopedItems : []);
|
|
861
|
-
} catch {
|
|
862
|
-
setCompanyDeviceConfigs([]);
|
|
863
|
-
} finally {
|
|
864
|
-
setLoadingCompanyDeviceConfigs(false);
|
|
865
|
-
setHasLoadedCompanyConfigs(true);
|
|
866
|
-
}
|
|
867
|
-
}, [currentCompany?.id]);
|
|
868
|
-
|
|
869
|
-
const loadProductShowcases = useCallback(async () => {
|
|
870
|
-
if (!currentCompany?.id || !isPdvDevice) {
|
|
871
|
-
setProductShowcases([]);
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
setLoadingProductShowcases(true);
|
|
876
|
-
try {
|
|
877
|
-
const response = await api.fetch('/product_showcases', {
|
|
878
|
-
params: {
|
|
879
|
-
company: `/people/${currentCompany.id}`,
|
|
880
|
-
integrationKey: 'pos',
|
|
881
|
-
active: 1,
|
|
882
|
-
'order[name]': 'ASC',
|
|
883
|
-
},
|
|
884
|
-
});
|
|
885
|
-
const items =
|
|
886
|
-
response?.member ||
|
|
887
|
-
response?.['hydra:member'] ||
|
|
888
|
-
response?.items ||
|
|
889
|
-
response;
|
|
890
|
-
setProductShowcases(Array.isArray(items) ? items : []);
|
|
891
|
-
} catch {
|
|
892
|
-
setProductShowcases([]);
|
|
893
|
-
} finally {
|
|
894
|
-
setLoadingProductShowcases(false);
|
|
895
|
-
}
|
|
896
|
-
}, [currentCompany?.id, isPdvDevice]);
|
|
897
|
-
|
|
898
|
-
const ensureActiveTabData = useCallback(async ({ force = false } = {}) => {
|
|
899
|
-
if (!currentCompany?.id) {
|
|
900
|
-
return;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
if (!isPdvDevice) {
|
|
904
|
-
await Promise.all([
|
|
905
|
-
refreshCurrentConfig(),
|
|
906
|
-
loadCompanyConfigs(),
|
|
907
|
-
]);
|
|
908
|
-
return;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
if (activePdvTab === PDV_TAB_MOVEMENT) {
|
|
912
|
-
if (!force && hasLoadedMovementDataRef.current) {
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
await loadMovementData();
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
if (activePdvTab === PDV_TAB_ORDERS) {
|
|
920
|
-
const pendingLoads = [];
|
|
921
|
-
if (force || !hasLoadedCurrentConfigRef.current) {
|
|
922
|
-
pendingLoads.push(refreshCurrentConfig());
|
|
923
|
-
}
|
|
924
|
-
if (force || !hasLoadedCompanyConfigsRef.current) {
|
|
925
|
-
pendingLoads.push(loadCompanyConfigs());
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
if (pendingLoads.length > 0) {
|
|
929
|
-
await Promise.all(pendingLoads);
|
|
930
|
-
}
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
if (force || !hasLoadedCurrentConfig) {
|
|
935
|
-
await refreshCurrentConfig();
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
if (activePdvTab === PDV_TAB_OPERATION) {
|
|
939
|
-
await loadProductShowcases();
|
|
940
|
-
}
|
|
941
|
-
}, [
|
|
942
|
-
activePdvTab,
|
|
943
|
-
currentCompany?.id,
|
|
944
|
-
isPdvDevice,
|
|
945
|
-
loadCompanyConfigs,
|
|
946
|
-
loadMovementData,
|
|
947
|
-
loadProductShowcases,
|
|
948
|
-
refreshCurrentConfig,
|
|
949
|
-
]);
|
|
950
|
-
|
|
951
|
-
useEffect(() => {
|
|
952
|
-
setHasLoadedCurrentConfig(false);
|
|
953
|
-
setHasLoadedCompanyConfigs(false);
|
|
954
|
-
setHasLoadedMovementData(false);
|
|
955
|
-
hasInitializedPdvTabRef.current = false;
|
|
956
|
-
setProducts([]);
|
|
957
|
-
setInflowData(null);
|
|
958
|
-
setCompanyDeviceConfigs([]);
|
|
959
|
-
}, [currentCompany?.id, deviceString, deviceType]);
|
|
960
|
-
|
|
961
|
-
const ensureActiveTabDataRef = useRef(ensureActiveTabData);
|
|
962
|
-
useEffect(() => {
|
|
963
|
-
ensureActiveTabDataRef.current = ensureActiveTabData;
|
|
964
|
-
}, [ensureActiveTabData]);
|
|
965
|
-
|
|
966
|
-
useFocusEffect(
|
|
967
|
-
useCallback(() => {
|
|
968
|
-
ensureActiveTabDataRef.current({ force: true });
|
|
969
|
-
}, []),
|
|
970
|
-
);
|
|
971
|
-
|
|
972
|
-
useEffect(() => {
|
|
973
|
-
if (!isPdvDevice) {
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
if (!hasInitializedPdvTabRef.current) {
|
|
978
|
-
hasInitializedPdvTabRef.current = true;
|
|
979
|
-
return;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
ensureActiveTabDataRef.current();
|
|
983
|
-
}, [activePdvTab, isPdvDevice]);
|
|
984
|
-
|
|
985
|
-
useFocusEffect(
|
|
986
|
-
useCallback(() => {
|
|
987
|
-
if (!isDisplayDevice || !currentCompany?.id) {
|
|
988
|
-
return;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
displayStore.actions
|
|
992
|
-
.getItems({
|
|
993
|
-
company: currentCompany.id,
|
|
994
|
-
})
|
|
995
|
-
.catch(() => {});
|
|
996
|
-
printerStore.actions
|
|
997
|
-
.getPrinters({people: currentCompany.id})
|
|
998
|
-
.catch(() => {});
|
|
999
|
-
}, [
|
|
1000
|
-
currentCompany?.id,
|
|
1001
|
-
displayStore.actions,
|
|
1002
|
-
isDisplayDevice,
|
|
1003
|
-
printerStore.actions,
|
|
1004
|
-
]),
|
|
1005
|
-
);
|
|
1006
|
-
|
|
1007
|
-
const handleToggle = useCallback(() => {
|
|
1008
|
-
if (!isPdvDevice) {
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const msg = isOpen ? 'Deseja fechar o caixa?' : 'Deseja abrir o caixa?';
|
|
1013
|
-
confirm(msg, async () => {
|
|
1014
|
-
setActionLoading(true);
|
|
1015
|
-
try {
|
|
1016
|
-
const action = isOpen
|
|
1017
|
-
? actionsRef.current.invoiceActions.closeCashRegister
|
|
1018
|
-
: actionsRef.current.invoiceActions.openCashRegister;
|
|
1019
|
-
await action({ device: deviceString, provider: currentCompany.id });
|
|
1020
|
-
await refreshCurrentConfig();
|
|
1021
|
-
if (activePdvTab === PDV_TAB_MOVEMENT || hasLoadedMovementData) {
|
|
1022
|
-
await loadMovementData();
|
|
1023
|
-
}
|
|
1024
|
-
} catch (error) {
|
|
1025
|
-
showSystemError(
|
|
1026
|
-
error,
|
|
1027
|
-
'Nao foi possivel atualizar o caixa deste device.',
|
|
1028
|
-
);
|
|
1029
|
-
} finally {
|
|
1030
|
-
setActionLoading(false);
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
}, [
|
|
1034
|
-
activePdvTab,
|
|
1035
|
-
currentCompany?.id,
|
|
1036
|
-
deviceString,
|
|
1037
|
-
hasLoadedMovementData,
|
|
1038
|
-
isOpen,
|
|
1039
|
-
isPdvDevice,
|
|
1040
|
-
loadMovementData,
|
|
1041
|
-
refreshCurrentConfig,
|
|
1042
|
-
showSystemError,
|
|
1043
|
-
]);
|
|
1044
|
-
|
|
1045
|
-
const startEditAlias = useCallback(() => {
|
|
1046
|
-
setAliasInput(alias);
|
|
1047
|
-
setEditingAlias(true);
|
|
1048
|
-
setTimeout(() => aliasInputRef.current?.focus(), 80);
|
|
1049
|
-
}, [alias]);
|
|
1050
|
-
|
|
1051
|
-
const cancelEditAlias = useCallback(() => {
|
|
1052
|
-
setEditingAlias(false);
|
|
1053
|
-
setAliasInput(alias);
|
|
1054
|
-
}, [alias]);
|
|
1055
|
-
|
|
1056
|
-
const saveAlias = useCallback(async () => {
|
|
1057
|
-
const trimmed = aliasInput.trim();
|
|
1058
|
-
if (!trimmed || trimmed === alias || !deviceId) {
|
|
1059
|
-
cancelEditAlias();
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
setSavingAlias(true);
|
|
1063
|
-
try {
|
|
1064
|
-
const savedDevice = await actionsRef.current.deviceActions.save({
|
|
1065
|
-
id: deviceId,
|
|
1066
|
-
alias: trimmed,
|
|
1067
|
-
});
|
|
1068
|
-
const nextAlias = String(savedDevice?.alias || trimmed).trim();
|
|
1069
|
-
const { mergedDevice, nextDeviceConfig } = buildDeviceAliasStoreUpdates({
|
|
1070
|
-
deviceId,
|
|
1071
|
-
nextAlias,
|
|
1072
|
-
runtimeDevice,
|
|
1073
|
-
runtimeDeviceConfig,
|
|
1074
|
-
savedDevice,
|
|
1075
|
-
normalizeEntityId,
|
|
1076
|
-
});
|
|
1077
|
-
actionsRef.current.deviceActions.setItem?.(mergedDevice);
|
|
1078
|
-
if (nextDeviceConfig && actionsRef.current.deviceConfigActions?.setItem) {
|
|
1079
|
-
actionsRef.current.deviceConfigActions.setItem(nextDeviceConfig);
|
|
1080
|
-
}
|
|
1081
|
-
skipAliasSyncFromStoreRef.current = true;
|
|
1082
|
-
setAlias(nextAlias);
|
|
1083
|
-
setAliasInput(nextAlias);
|
|
1084
|
-
setEditingAlias(false);
|
|
1085
|
-
} catch (error) {
|
|
1086
|
-
showSystemError(error, 'Nao foi possivel salvar o nome do device.');
|
|
1087
|
-
cancelEditAlias();
|
|
1088
|
-
} finally {
|
|
1089
|
-
setSavingAlias(false);
|
|
1090
|
-
}
|
|
1091
|
-
}, [aliasInput, alias, deviceId, cancelEditAlias, showSystemError]);
|
|
1092
|
-
|
|
1093
|
-
const confirmRemoveDevice = useCallback(() => {
|
|
1094
|
-
if (!deviceId || removingDevice) {
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
const label = String(alias || deviceString || deviceId).trim();
|
|
1098
|
-
const message = `Tem certeza que deseja excluir o device "${label}"? Esta ação não pode ser desfeita.`;
|
|
1099
|
-
// Use web-safe confirm() (window.confirm on web; Alert.alert on native).
|
|
1100
|
-
// Alert.alert alone is a no-op on Manager web — root cause of "click does nothing".
|
|
1101
|
-
confirm(message, async () => {
|
|
1102
|
-
setRemovingDevice(true);
|
|
1103
|
-
try {
|
|
1104
|
-
await actionsRef.current.deviceActions.remove(deviceId);
|
|
1105
|
-
if (navigation?.canGoBack?.()) {
|
|
1106
|
-
navigation.goBack();
|
|
1107
|
-
} else {
|
|
1108
|
-
navigation.navigate('DevicesIndex');
|
|
1109
|
-
}
|
|
1110
|
-
} catch (error) {
|
|
1111
|
-
showSystemError(error, 'Não foi possível excluir o device.');
|
|
1112
|
-
} finally {
|
|
1113
|
-
setRemovingDevice(false);
|
|
1114
|
-
}
|
|
1115
|
-
});
|
|
1116
|
-
}, [deviceId, removingDevice, alias, deviceString, navigation, showSystemError]);
|
|
1117
|
-
|
|
1118
|
-
const saveDevicePaymentTarget = useCallback(async (override = {}) => {
|
|
1119
|
-
const nextDevicePaymentTarget =
|
|
1120
|
-
override.devicePaymentTarget ?? devicePaymentTarget;
|
|
1121
|
-
|
|
1122
|
-
if (!currentCompany?.id || !deviceString) {
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
setSavingPaymentTarget(true);
|
|
1127
|
-
try {
|
|
1128
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1129
|
-
device: deviceString,
|
|
1130
|
-
configs: JSON.stringify({
|
|
1131
|
-
[ORDER_PAYMENT_DEVICE_CONFIG_KEY]: nextDevicePaymentTarget || '',
|
|
1132
|
-
}),
|
|
1133
|
-
people: '/people/' + currentCompany.id,
|
|
1134
|
-
type: deviceType,
|
|
1135
|
-
});
|
|
1136
|
-
await refreshCurrentConfig();
|
|
1137
|
-
} catch (error) {
|
|
1138
|
-
showSystemError(
|
|
1139
|
-
error,
|
|
1140
|
-
'Nao foi possivel salvar o device de pagamento.',
|
|
1141
|
-
);
|
|
1142
|
-
} finally {
|
|
1143
|
-
setSavingPaymentTarget(false);
|
|
1144
|
-
}
|
|
1145
|
-
}, [currentCompany?.id, devicePaymentTarget, deviceString, deviceType, refreshCurrentConfig, showSystemError]);
|
|
1146
|
-
|
|
1147
|
-
const savePdvSettings = useCallback(async (override = {}) => {
|
|
1148
|
-
const nextPdvGateway = override.pdvGateway ?? pdvGateway;
|
|
1149
|
-
const nextPdvPrinterEnabled =
|
|
1150
|
-
override.pdvPrinterEnabled ?? pdvPrinterEnabled;
|
|
1151
|
-
|
|
1152
|
-
if (
|
|
1153
|
-
!isPdvDevice ||
|
|
1154
|
-
!currentCompany?.id ||
|
|
1155
|
-
!deviceString ||
|
|
1156
|
-
savingPdvSettings
|
|
1157
|
-
) {
|
|
1158
|
-
return;
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
setSavingPdvSettings(true);
|
|
1162
|
-
try {
|
|
1163
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1164
|
-
device: deviceString,
|
|
1165
|
-
configs: JSON.stringify({
|
|
1166
|
-
[POS_GATEWAY_CONFIG_KEY]: nextPdvGateway || '',
|
|
1167
|
-
[PDV_PRINTER_ENABLED_CONFIG_KEY]: nextPdvPrinterEnabled ? '1' : '0',
|
|
1168
|
-
}),
|
|
1169
|
-
people: '/people/' + currentCompany.id,
|
|
1170
|
-
type: deviceType,
|
|
1171
|
-
});
|
|
1172
|
-
await refreshCurrentConfig();
|
|
1173
|
-
} catch (error) {
|
|
1174
|
-
showSystemError(
|
|
1175
|
-
error,
|
|
1176
|
-
'Nao foi possivel salvar as configuracoes de pagamento do PDV.',
|
|
1177
|
-
);
|
|
1178
|
-
} finally {
|
|
1179
|
-
setSavingPdvSettings(false);
|
|
1180
|
-
}
|
|
1181
|
-
}, [
|
|
1182
|
-
currentCompany?.id,
|
|
1183
|
-
deviceString,
|
|
1184
|
-
deviceType,
|
|
1185
|
-
isPdvDevice,
|
|
1186
|
-
pdvGateway,
|
|
1187
|
-
pdvPrinterEnabled,
|
|
1188
|
-
refreshCurrentConfig,
|
|
1189
|
-
savingPdvSettings,
|
|
1190
|
-
showSystemError,
|
|
1191
|
-
]);
|
|
1192
|
-
|
|
1193
|
-
const saveProductShowcaseConfig = useCallback(async (override = {}) => {
|
|
1194
|
-
const nextProductShowcaseId =
|
|
1195
|
-
override.productShowcaseId ?? productShowcaseId;
|
|
1196
|
-
|
|
1197
|
-
if (!currentCompany?.id || !deviceString || savingProductShowcase) {
|
|
1198
|
-
return;
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
setSavingProductShowcase(true);
|
|
1202
|
-
try {
|
|
1203
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1204
|
-
device: deviceString,
|
|
1205
|
-
configs: JSON.stringify({
|
|
1206
|
-
[POS_PRODUCT_SHOWCASE_CONFIG_KEY]: nextProductShowcaseId || '',
|
|
1207
|
-
}),
|
|
1208
|
-
people: '/people/' + currentCompany.id,
|
|
1209
|
-
type: deviceType,
|
|
1210
|
-
});
|
|
1211
|
-
await refreshCurrentConfig();
|
|
1212
|
-
} catch (error) {
|
|
1213
|
-
showSystemError(
|
|
1214
|
-
error,
|
|
1215
|
-
'Nao foi possivel salvar a vitrine deste PDV.',
|
|
1216
|
-
);
|
|
1217
|
-
} finally {
|
|
1218
|
-
setSavingProductShowcase(false);
|
|
1219
|
-
}
|
|
1220
|
-
}, [
|
|
1221
|
-
currentCompany?.id,
|
|
1222
|
-
deviceString,
|
|
1223
|
-
deviceType,
|
|
1224
|
-
productShowcaseId,
|
|
1225
|
-
refreshCurrentConfig,
|
|
1226
|
-
savingProductShowcase,
|
|
1227
|
-
showSystemError,
|
|
1228
|
-
]);
|
|
1229
|
-
|
|
1230
|
-
const savePaymentTypeConfigs = useCallback(
|
|
1231
|
-
async nextSelectedPaymentTypeIds => {
|
|
1232
|
-
if (
|
|
1233
|
-
!currentCompany?.id ||
|
|
1234
|
-
!deviceString ||
|
|
1235
|
-
savingPaymentTypes
|
|
1236
|
-
) {
|
|
1237
|
-
return;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
setSavingPaymentTypes(true);
|
|
1241
|
-
try {
|
|
1242
|
-
const nextConfigs = appendScreenMetrics({
|
|
1243
|
-
...(configs || {}),
|
|
1244
|
-
[PAYMENT_TYPE_IDS_CONFIG_KEY]: nextSelectedPaymentTypeIds,
|
|
1245
|
-
'config-version': appVersion,
|
|
1246
|
-
});
|
|
1247
|
-
|
|
1248
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1249
|
-
device: deviceString,
|
|
1250
|
-
configs: JSON.stringify(nextConfigs),
|
|
1251
|
-
people: '/people/' + currentCompany.id,
|
|
1252
|
-
type: deviceType,
|
|
1253
|
-
});
|
|
1254
|
-
|
|
1255
|
-
actionsRef.current.deviceConfigActions.setItem({
|
|
1256
|
-
...(currentDeviceConfig || {}),
|
|
1257
|
-
configs: nextConfigs,
|
|
1258
|
-
device:
|
|
1259
|
-
currentDeviceConfig?.device ||
|
|
1260
|
-
currentDevice ||
|
|
1261
|
-
{device: deviceString, type: deviceType},
|
|
1262
|
-
people:
|
|
1263
|
-
currentDeviceConfig?.people ||
|
|
1264
|
-
`/people/${currentCompany.id}`,
|
|
1265
|
-
type:
|
|
1266
|
-
currentDeviceConfig?.type ||
|
|
1267
|
-
deviceType,
|
|
1268
|
-
});
|
|
1269
|
-
setConfigs(nextConfigs);
|
|
1270
|
-
} catch (error) {
|
|
1271
|
-
showSystemError(
|
|
1272
|
-
error,
|
|
1273
|
-
'Nao foi possivel salvar os tipos de pagamento do device.',
|
|
1274
|
-
);
|
|
1275
|
-
} finally {
|
|
1276
|
-
setSavingPaymentTypes(false);
|
|
1277
|
-
}
|
|
1278
|
-
},
|
|
1279
|
-
[
|
|
1280
|
-
currentCompany?.id,
|
|
1281
|
-
appVersion,
|
|
1282
|
-
configs,
|
|
1283
|
-
currentDevice,
|
|
1284
|
-
currentDeviceConfig,
|
|
1285
|
-
deviceString,
|
|
1286
|
-
deviceType,
|
|
1287
|
-
savingPaymentTypes,
|
|
1288
|
-
showSystemError,
|
|
1289
|
-
],
|
|
1290
|
-
);
|
|
1291
|
-
|
|
1292
|
-
const savePosOperationMode = useCallback(async (override = {}) => {
|
|
1293
|
-
const nextPosOperationMode =
|
|
1294
|
-
override.posOperationMode ?? posOperationMode;
|
|
1295
|
-
const nextAndroidKioskEnabled =
|
|
1296
|
-
override.androidKioskEnabled ?? androidKioskEnabled;
|
|
1297
|
-
const nextCheckOrderType =
|
|
1298
|
-
override.checkOrderType ?? checkOrderType;
|
|
1299
|
-
const nextCheckOrderManagementMode =
|
|
1300
|
-
override.checkOrderManagementMode ?? checkOrderManagementMode;
|
|
1301
|
-
const nextCounterAutoPrintEnabled =
|
|
1302
|
-
override.counterAutoPrintEnabled ?? counterAutoPrintEnabled;
|
|
1303
|
-
const nextCounterPrintMode =
|
|
1304
|
-
override.counterPrintMode ?? counterPrintMode;
|
|
1305
|
-
const nextCounterCashManagementMode =
|
|
1306
|
-
override.counterCashManagementMode ?? counterCashManagementMode;
|
|
1307
|
-
|
|
1308
|
-
if (
|
|
1309
|
-
!isPdvDevice ||
|
|
1310
|
-
!currentCompany?.id ||
|
|
1311
|
-
!deviceString ||
|
|
1312
|
-
savingPosOperationMode
|
|
1313
|
-
) {
|
|
1314
|
-
return;
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
setSavingPosOperationMode(true);
|
|
1318
|
-
try {
|
|
1319
|
-
const nextOperationConfigs = {
|
|
1320
|
-
[POS_OPERATION_MODE_CONFIG_KEY]: nextPosOperationMode,
|
|
1321
|
-
[DEVICE_ANDROID_KIOSK_ENABLED_CONFIG_KEY]: nextAndroidKioskEnabled
|
|
1322
|
-
? '1'
|
|
1323
|
-
: '0',
|
|
1324
|
-
[POS_CHECK_ORDER_TYPE_CONFIG_KEY]: nextCheckOrderType,
|
|
1325
|
-
[POS_CHECK_ORDER_MANAGEMENT_MODE_CONFIG_KEY]:
|
|
1326
|
-
nextCheckOrderType === POS_CHECK_ORDER_TYPE_NONE
|
|
1327
|
-
? POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE
|
|
1328
|
-
: nextCheckOrderManagementMode,
|
|
1329
|
-
};
|
|
1330
|
-
|
|
1331
|
-
if (nextPosOperationMode === POS_OPERATION_MODE_COUNTER) {
|
|
1332
|
-
nextOperationConfigs[POS_AUTO_PRINT_ENABLED_CONFIG_KEY] =
|
|
1333
|
-
nextCounterAutoPrintEnabled ? '1' : '0';
|
|
1334
|
-
nextOperationConfigs['print-mode'] = nextCounterPrintMode;
|
|
1335
|
-
nextOperationConfigs[POS_CASH_MANAGEMENT_MODE_CONFIG_KEY] =
|
|
1336
|
-
nextCounterCashManagementMode;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1340
|
-
device: deviceString,
|
|
1341
|
-
configs: JSON.stringify(nextOperationConfigs),
|
|
1342
|
-
people: '/people/' + currentCompany.id,
|
|
1343
|
-
type: deviceType,
|
|
1344
|
-
});
|
|
1345
|
-
await refreshCurrentConfig();
|
|
1346
|
-
} catch (error) {
|
|
1347
|
-
showSystemError(
|
|
1348
|
-
error,
|
|
1349
|
-
'Nao foi possivel salvar a operacao do PDV.',
|
|
1350
|
-
);
|
|
1351
|
-
} finally {
|
|
1352
|
-
setSavingPosOperationMode(false);
|
|
1353
|
-
}
|
|
1354
|
-
}, [
|
|
1355
|
-
currentCompany?.id,
|
|
1356
|
-
checkOrderManagementMode,
|
|
1357
|
-
checkOrderType,
|
|
1358
|
-
counterAutoPrintEnabled,
|
|
1359
|
-
counterCashManagementMode,
|
|
1360
|
-
counterPrintMode,
|
|
1361
|
-
deviceString,
|
|
1362
|
-
deviceType,
|
|
1363
|
-
androidKioskEnabled,
|
|
1364
|
-
isPdvDevice,
|
|
1365
|
-
posOperationMode,
|
|
1366
|
-
refreshCurrentConfig,
|
|
1367
|
-
savingPosOperationMode,
|
|
1368
|
-
showSystemError,
|
|
1369
|
-
]);
|
|
1370
|
-
|
|
1371
|
-
useEffect(() => {
|
|
1372
|
-
if (!isPdvDevice || !currentCompany?.id || !deviceString) {
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
const rawCheckOrderType = resolvePosCheckOrderType(configs);
|
|
1377
|
-
const nextCheckOrderType = resolvePosCheckOrderTypeForShop(
|
|
1378
|
-
configs,
|
|
1379
|
-
runtimeCompanyConfigs,
|
|
1380
|
-
);
|
|
1381
|
-
|
|
1382
|
-
if (
|
|
1383
|
-
rawCheckOrderType !== POS_CHECK_ORDER_TYPE_STAMP ||
|
|
1384
|
-
nextCheckOrderType !== POS_CHECK_ORDER_TYPE_NONE ||
|
|
1385
|
-
savingPosOperationMode
|
|
1386
|
-
) {
|
|
1387
|
-
stampAutoDisableSignatureRef.current = '';
|
|
1388
|
-
return;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
const signature = [
|
|
1392
|
-
currentCompany?.id,
|
|
1393
|
-
deviceString,
|
|
1394
|
-
rawCheckOrderType,
|
|
1395
|
-
loyaltyCouponsEnabled ? '1' : '0',
|
|
1396
|
-
String(configs?.['config-version'] || ''),
|
|
1397
|
-
].join(':');
|
|
1398
|
-
|
|
1399
|
-
if (stampAutoDisableSignatureRef.current === signature) {
|
|
1400
|
-
return;
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
stampAutoDisableSignatureRef.current = signature;
|
|
1404
|
-
|
|
1405
|
-
setCheckOrderType(POS_CHECK_ORDER_TYPE_NONE);
|
|
1406
|
-
setCheckOrderManagementMode(POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE);
|
|
1407
|
-
savePosOperationMode({
|
|
1408
|
-
checkOrderType: POS_CHECK_ORDER_TYPE_NONE,
|
|
1409
|
-
checkOrderManagementMode: POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
1410
|
-
});
|
|
1411
|
-
}, [
|
|
1412
|
-
configs,
|
|
1413
|
-
currentCompany?.id,
|
|
1414
|
-
deviceString,
|
|
1415
|
-
isPdvDevice,
|
|
1416
|
-
loyaltyCouponsEnabled,
|
|
1417
|
-
savePosOperationMode,
|
|
1418
|
-
savingPosOperationMode,
|
|
1419
|
-
runtimeCompanyConfigs,
|
|
1420
|
-
]);
|
|
1421
|
-
|
|
1422
|
-
const saveLauncherMode = useCallback(async (override = {}) => {
|
|
1423
|
-
const nextAndroidLauncherEnabled =
|
|
1424
|
-
override.androidLauncherEnabled ?? androidLauncherEnabled;
|
|
1425
|
-
|
|
1426
|
-
if (
|
|
1427
|
-
!isPdvDevice ||
|
|
1428
|
-
!currentCompany?.id ||
|
|
1429
|
-
!deviceString ||
|
|
1430
|
-
savingLauncherMode
|
|
1431
|
-
) {
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
setSavingLauncherMode(true);
|
|
1436
|
-
try {
|
|
1437
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1438
|
-
device: deviceString,
|
|
1439
|
-
configs: JSON.stringify({
|
|
1440
|
-
[DEVICE_ANDROID_LAUNCHER_ENABLED_CONFIG_KEY]: nextAndroidLauncherEnabled
|
|
1441
|
-
? '1'
|
|
1442
|
-
: '0',
|
|
1443
|
-
'config-version': appVersion,
|
|
1444
|
-
}),
|
|
1445
|
-
people: '/people/' + currentCompany.id,
|
|
1446
|
-
type: deviceType,
|
|
1447
|
-
});
|
|
1448
|
-
await refreshCurrentConfig();
|
|
1449
|
-
} catch (error) {
|
|
1450
|
-
showSystemError(
|
|
1451
|
-
error,
|
|
1452
|
-
'Nao foi possivel salvar o launcher do device.',
|
|
1453
|
-
);
|
|
1454
|
-
} finally {
|
|
1455
|
-
setSavingLauncherMode(false);
|
|
1456
|
-
}
|
|
1457
|
-
}, [
|
|
1458
|
-
androidLauncherEnabled,
|
|
1459
|
-
appVersion,
|
|
1460
|
-
currentCompany?.id,
|
|
1461
|
-
deviceString,
|
|
1462
|
-
deviceType,
|
|
1463
|
-
isPdvDevice,
|
|
1464
|
-
refreshCurrentConfig,
|
|
1465
|
-
savingLauncherMode,
|
|
1466
|
-
showSystemError,
|
|
1467
|
-
]);
|
|
1468
|
-
|
|
1469
|
-
const saveDeviceAlertSoundConfig = useCallback(async (override = {}) => {
|
|
1470
|
-
const nextDeviceAlertSoundEnabled =
|
|
1471
|
-
override.deviceAlertSoundEnabled ?? deviceAlertSoundEnabled;
|
|
1472
|
-
const nextDeviceAlertSoundUrl =
|
|
1473
|
-
override.deviceAlertSoundUrl ?? deviceAlertSoundUrl;
|
|
1474
|
-
|
|
1475
|
-
if (!currentCompany?.id || !deviceString || savingAlertSound) {
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
setSavingAlertSound(true);
|
|
1480
|
-
try {
|
|
1481
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1482
|
-
device: deviceString,
|
|
1483
|
-
configs: JSON.stringify({
|
|
1484
|
-
[DEVICE_ALERT_SOUND_ENABLED_KEY]: nextDeviceAlertSoundEnabled ? '1' : '0',
|
|
1485
|
-
[DEVICE_ALERT_SOUND_URL_KEY]: String(nextDeviceAlertSoundUrl || '').trim(),
|
|
1486
|
-
}),
|
|
1487
|
-
people: '/people/' + currentCompany.id,
|
|
1488
|
-
type: deviceType,
|
|
1489
|
-
});
|
|
1490
|
-
await refreshCurrentConfig();
|
|
1491
|
-
} catch (error) {
|
|
1492
|
-
showSystemError(
|
|
1493
|
-
error,
|
|
1494
|
-
'Nao foi possivel salvar o som de alerta do device.',
|
|
1495
|
-
);
|
|
1496
|
-
} finally {
|
|
1497
|
-
setSavingAlertSound(false);
|
|
1498
|
-
}
|
|
1499
|
-
}, [
|
|
1500
|
-
currentCompany?.id,
|
|
1501
|
-
deviceAlertSoundEnabled,
|
|
1502
|
-
deviceAlertSoundUrl,
|
|
1503
|
-
deviceString,
|
|
1504
|
-
deviceType,
|
|
1505
|
-
refreshCurrentConfig,
|
|
1506
|
-
savingAlertSound,
|
|
1507
|
-
showSystemError,
|
|
1508
|
-
]);
|
|
1509
|
-
|
|
1510
|
-
const saveDeviceOrderVisibility = useCallback(async (override = {}) => {
|
|
1511
|
-
const nextDeviceOrderVisibility =
|
|
1512
|
-
override.deviceOrderVisibility ?? deviceOrderVisibility;
|
|
1513
|
-
|
|
1514
|
-
if (!currentCompany?.id || !deviceString || savingOrderVisibility) {
|
|
1515
|
-
return;
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
setSavingOrderVisibility(true);
|
|
1519
|
-
try {
|
|
1520
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1521
|
-
device: deviceString,
|
|
1522
|
-
configs: JSON.stringify({
|
|
1523
|
-
[DEVICE_ORDER_VISIBILITY_KEY]: nextDeviceOrderVisibility || DEVICE_ORDER_VISIBILITY_DEVICE,
|
|
1524
|
-
}),
|
|
1525
|
-
people: '/people/' + currentCompany.id,
|
|
1526
|
-
type: deviceType,
|
|
1527
|
-
});
|
|
1528
|
-
await refreshCurrentConfig();
|
|
1529
|
-
} catch (error) {
|
|
1530
|
-
showSystemError(
|
|
1531
|
-
error,
|
|
1532
|
-
'Nao foi possivel salvar a visibilidade dos pedidos.',
|
|
1533
|
-
);
|
|
1534
|
-
} finally {
|
|
1535
|
-
setSavingOrderVisibility(false);
|
|
1536
|
-
}
|
|
1537
|
-
}, [
|
|
1538
|
-
currentCompany?.id,
|
|
1539
|
-
deviceOrderVisibility,
|
|
1540
|
-
deviceString,
|
|
1541
|
-
deviceType,
|
|
1542
|
-
refreshCurrentConfig,
|
|
1543
|
-
savingOrderVisibility,
|
|
1544
|
-
showSystemError,
|
|
1545
|
-
]);
|
|
1546
|
-
|
|
1547
|
-
const saveDeviceDeliverySettings = useCallback(async (override = {}) => {
|
|
1548
|
-
const nextDeviceDeliveryEnabled =
|
|
1549
|
-
override.deviceDeliveryEnabled ?? deviceDeliveryEnabled;
|
|
1550
|
-
|
|
1551
|
-
if (
|
|
1552
|
-
!currentCompany?.id ||
|
|
1553
|
-
!deviceString ||
|
|
1554
|
-
savingDeviceDeliverySettings
|
|
1555
|
-
) {
|
|
1556
|
-
return;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
setSavingDeviceDeliverySettings(true);
|
|
1560
|
-
try {
|
|
1561
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1562
|
-
device: deviceString,
|
|
1563
|
-
configs: JSON.stringify({
|
|
1564
|
-
[POS_DELIVERY_ENABLED_CONFIG_KEY]: nextDeviceDeliveryEnabled ? '1' : '0',
|
|
1565
|
-
}),
|
|
1566
|
-
people: '/people/' + currentCompany.id,
|
|
1567
|
-
type: deviceType,
|
|
1568
|
-
});
|
|
1569
|
-
await refreshCurrentConfig();
|
|
1570
|
-
} catch (error) {
|
|
1571
|
-
showSystemError(
|
|
1572
|
-
error,
|
|
1573
|
-
'Nao foi possivel salvar a configuracao de entregas.',
|
|
1574
|
-
);
|
|
1575
|
-
} finally {
|
|
1576
|
-
setSavingDeviceDeliverySettings(false);
|
|
1577
|
-
}
|
|
1578
|
-
}, [
|
|
1579
|
-
currentCompany?.id,
|
|
1580
|
-
deviceDeliveryEnabled,
|
|
1581
|
-
deviceString,
|
|
1582
|
-
deviceType,
|
|
1583
|
-
refreshCurrentConfig,
|
|
1584
|
-
savingDeviceDeliverySettings,
|
|
1585
|
-
showSystemError,
|
|
1586
|
-
]);
|
|
1587
|
-
|
|
1588
|
-
const saveDeviceRuntimeDebugInfo = useCallback(async (override = {}) => {
|
|
1589
|
-
const nextDeviceRuntimeDebugInfoEnabled =
|
|
1590
|
-
override.deviceRuntimeDebugInfoEnabled ?? deviceRuntimeDebugInfoEnabled;
|
|
1591
|
-
|
|
1592
|
-
if (!currentCompany?.id || !deviceString || savingRuntimeDebugInfo) {
|
|
1593
|
-
return;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
setSavingRuntimeDebugInfo(true);
|
|
1597
|
-
try {
|
|
1598
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1599
|
-
device: deviceString,
|
|
1600
|
-
configs: JSON.stringify({
|
|
1601
|
-
[DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY]:
|
|
1602
|
-
nextDeviceRuntimeDebugInfoEnabled ? '1' : '0',
|
|
1603
|
-
}),
|
|
1604
|
-
people: '/people/' + currentCompany.id,
|
|
1605
|
-
type: deviceType,
|
|
1606
|
-
});
|
|
1607
|
-
await refreshCurrentConfig();
|
|
1608
|
-
} catch (error) {
|
|
1609
|
-
showSystemError(
|
|
1610
|
-
error,
|
|
1611
|
-
'Nao foi possivel salvar a exibicao das informacoes tecnicas.',
|
|
1612
|
-
);
|
|
1613
|
-
} finally {
|
|
1614
|
-
setSavingRuntimeDebugInfo(false);
|
|
1615
|
-
}
|
|
1616
|
-
}, [
|
|
1617
|
-
currentCompany?.id,
|
|
1618
|
-
deviceRuntimeDebugInfoEnabled,
|
|
1619
|
-
deviceString,
|
|
1620
|
-
deviceType,
|
|
1621
|
-
refreshCurrentConfig,
|
|
1622
|
-
savingRuntimeDebugInfo,
|
|
1623
|
-
showSystemError,
|
|
1624
|
-
]);
|
|
1625
|
-
|
|
1626
|
-
const saveDisplayPrintingConfig = useCallback(async (override = {}) => {
|
|
1627
|
-
const nextLinkedDisplayId = override.linkedDisplayId ?? linkedDisplayId;
|
|
1628
|
-
const nextDisplayPrinterId = override.displayPrinterId ?? displayPrinterId;
|
|
1629
|
-
const nextDisplayAllowPrinterChange =
|
|
1630
|
-
override.displayAllowPrinterChange ?? displayAllowPrinterChange;
|
|
1631
|
-
const nextDisplayAutoPrintProductEnabled =
|
|
1632
|
-
override.displayAutoPrintProductEnabled ?? displayAutoPrintProductEnabled;
|
|
1633
|
-
|
|
1634
|
-
if (
|
|
1635
|
-
!isDisplayDevice ||
|
|
1636
|
-
!currentCompany?.id ||
|
|
1637
|
-
!deviceString ||
|
|
1638
|
-
savingDisplayPrintingConfig
|
|
1639
|
-
) {
|
|
1640
|
-
return;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
const normalizedDisplayId = String(nextLinkedDisplayId || '').trim();
|
|
1644
|
-
const normalizedPrinterId = normalizeDeviceId(nextDisplayPrinterId);
|
|
1645
|
-
|
|
1646
|
-
if (
|
|
1647
|
-
nextDisplayAutoPrintProductEnabled &&
|
|
1648
|
-
(!normalizedDisplayId || !normalizedPrinterId)
|
|
1649
|
-
) {
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
setSavingDisplayPrintingConfig(true);
|
|
1654
|
-
try {
|
|
1655
|
-
await actionsRef.current.deviceConfigActions.addDeviceConfigs({
|
|
1656
|
-
device: deviceString,
|
|
1657
|
-
configs: JSON.stringify({
|
|
1658
|
-
[DISPLAY_DEVICE_LINK_CONFIG_KEY]: normalizedDisplayId,
|
|
1659
|
-
[DISPLAY_DEVICE_PRINTER_CONFIG_KEY]: normalizedPrinterId,
|
|
1660
|
-
[DISPLAY_ALLOW_PRINTER_CHANGE_CONFIG_KEY]:
|
|
1661
|
-
nextDisplayAllowPrinterChange ? '1' : '0',
|
|
1662
|
-
[DISPLAY_AUTO_PRINT_PRODUCT_CONFIG_KEY]:
|
|
1663
|
-
nextDisplayAutoPrintProductEnabled ? '1' : '0',
|
|
1664
|
-
}),
|
|
1665
|
-
people: '/people/' + currentCompany.id,
|
|
1666
|
-
type: deviceType,
|
|
1667
|
-
});
|
|
1668
|
-
await refreshCurrentConfig();
|
|
1669
|
-
} catch (error) {
|
|
1670
|
-
showSystemError(
|
|
1671
|
-
error,
|
|
1672
|
-
'Nao foi possivel salvar a configuracao de impressao.',
|
|
1673
|
-
);
|
|
1674
|
-
} finally {
|
|
1675
|
-
setSavingDisplayPrintingConfig(false);
|
|
1676
|
-
}
|
|
1677
|
-
}, [
|
|
1678
|
-
currentCompany?.id,
|
|
1679
|
-
deviceString,
|
|
1680
|
-
deviceType,
|
|
1681
|
-
displayAllowPrinterChange,
|
|
1682
|
-
displayAutoPrintProductEnabled,
|
|
1683
|
-
displayPrinterId,
|
|
1684
|
-
isDisplayDevice,
|
|
1685
|
-
linkedDisplayId,
|
|
1686
|
-
refreshCurrentConfig,
|
|
1687
|
-
savingDisplayPrintingConfig,
|
|
1688
|
-
showSystemError,
|
|
1689
|
-
]);
|
|
1690
|
-
|
|
1691
|
-
const sendCatalogRefreshCommand = useCallback(() => {
|
|
1692
|
-
if (!currentCompany?.id || !deviceString || sendingCatalogRefresh) {
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
confirm('Deseja limpar o cache de produtos deste device?', async () => {
|
|
1697
|
-
setSendingCatalogRefresh(true);
|
|
1698
|
-
try {
|
|
1699
|
-
await websocketActions.send({
|
|
1700
|
-
destination: deviceString,
|
|
1701
|
-
store: 'categories',
|
|
1702
|
-
command: 'clear-product-cache',
|
|
1703
|
-
companyId: currentCompany.id,
|
|
1704
|
-
});
|
|
1705
|
-
} catch (error) {
|
|
1706
|
-
showSystemError(
|
|
1707
|
-
error,
|
|
1708
|
-
'Nao foi possivel enviar o comando para limpar o cache de produtos.',
|
|
1709
|
-
);
|
|
1710
|
-
} finally {
|
|
1711
|
-
setSendingCatalogRefresh(false);
|
|
1712
|
-
}
|
|
1713
|
-
});
|
|
1714
|
-
}, [currentCompany?.id, deviceString, sendingCatalogRefresh, showSystemError, websocketActions]);
|
|
1715
|
-
|
|
1716
|
-
// Totais derivados
|
|
1717
|
-
const productTotal = useMemo(
|
|
1718
|
-
() => products.reduce((s, p) => s + Number(p.order_product_total || 0), 0),
|
|
1719
|
-
[products],
|
|
1720
|
-
);
|
|
1721
|
-
|
|
1722
|
-
const inflowTotal = inflowData?.total ?? productTotal;
|
|
1723
|
-
|
|
1724
|
-
const wallets = useMemo(() => {
|
|
1725
|
-
if (!inflowData?.wallet) return [];
|
|
1726
|
-
return Object.values(inflowData.wallet).map(w => ({
|
|
1727
|
-
wallet: w.wallet,
|
|
1728
|
-
total: w.total || 0,
|
|
1729
|
-
payments: Object.values(w.payment || {}).filter(pt => (pt.inflow || 0) > 0),
|
|
1730
|
-
}));
|
|
1731
|
-
}, [inflowData]);
|
|
1732
|
-
|
|
1733
|
-
const filteredProducts = useMemo(() => {
|
|
1734
|
-
const term = search.trim().toLowerCase();
|
|
1735
|
-
if (!term) return products;
|
|
1736
|
-
return products.filter(p =>
|
|
1737
|
-
String(p.product_name || '').toLowerCase().includes(term) ||
|
|
1738
|
-
String(p.product_sku || '').toLowerCase().includes(term),
|
|
1739
|
-
);
|
|
1740
|
-
}, [products, search]);
|
|
1741
|
-
|
|
1742
|
-
const accent = isPdvDevice
|
|
1743
|
-
? (isOpen ? hex.success : hex.danger)
|
|
1744
|
-
: hex.info;
|
|
1745
|
-
const showPdvOperationTab =
|
|
1746
|
-
isPdvDevice && activePdvTab === PDV_TAB_OPERATION;
|
|
1747
|
-
const showPdvOrdersTab = isPdvDevice && activePdvTab === PDV_TAB_ORDERS;
|
|
1748
|
-
const showPdvDeviceTab = isPdvDevice && activePdvTab === PDV_TAB_DEVICE;
|
|
1749
|
-
const showPdvPaymentTypesTab =
|
|
1750
|
-
isPdvDevice && activePdvTab === PDV_TAB_PAYMENT_TYPES;
|
|
1751
|
-
const showPdvMovementTab =
|
|
1752
|
-
isPdvDevice && activePdvTab === PDV_TAB_MOVEMENT;
|
|
1753
|
-
const loadingActiveTabData = isPdvDevice && (
|
|
1754
|
-
(showPdvMovementTab && loadingMovementData) ||
|
|
1755
|
-
(!showPdvMovementTab && loadingConfigData) ||
|
|
1756
|
-
(showPdvOrdersTab && loadingCompanyDeviceConfigs)
|
|
1757
|
-
);
|
|
1758
|
-
const shouldShowOrderVisibility =
|
|
1759
|
-
!isDisplayDevice && (!isPdvDevice || showPdvOrdersTab);
|
|
1760
|
-
const shouldShowRemotePayment =
|
|
1761
|
-
shouldShowOrderVisibility &&
|
|
1762
|
-
(!hasLocalPaymentGateway || pdvGateway !== PAYMENT_GATEWAY_CIELO);
|
|
1763
|
-
const shouldShowDeviceBehavior = !isPdvDevice || showPdvDeviceTab;
|
|
1764
|
-
const shouldShowRemoteCommands =
|
|
1765
|
-
!isDisplayDevice && (!isPdvDevice || showPdvDeviceTab);
|
|
1766
|
-
|
|
1767
|
-
const renderProduct = ({ item, index }) => (
|
|
1768
|
-
<View style={[styles.productRow, index % 2 === 0 && styles.productRowAlt]}>
|
|
1769
|
-
<Text style={[styles.productCell, { flex: 0.5 }]}>{item.quantity}</Text>
|
|
1770
|
-
<View style={inlineStyle_667_12}>
|
|
1771
|
-
<Text style={styles.productName} numberOfLines={1}>{item.product_name}</Text>
|
|
1772
|
-
{!!item.product_sku && (
|
|
1773
|
-
<Text style={styles.productSku}>{item.product_sku}</Text>
|
|
1774
|
-
)}
|
|
1775
|
-
</View>
|
|
1776
|
-
<Text style={[styles.productCell, { flex: 1.2, textAlign: 'right' }]}>
|
|
1777
|
-
{Formatter.formatMoney(item.order_product_price)}
|
|
1778
|
-
</Text>
|
|
1779
|
-
<Text style={[styles.productCell, { flex: 1.3, textAlign: 'right', fontWeight: '700' }]}>
|
|
1780
|
-
{Formatter.formatMoney(item.order_product_total)}
|
|
1781
|
-
</Text>
|
|
1782
|
-
</View>
|
|
1783
|
-
);
|
|
1784
|
-
|
|
1785
|
-
const renderHelpButton = (title, message) => (
|
|
1786
|
-
<DefaultTooltip
|
|
1787
|
-
accentColor={themeColors.buttonIcon}
|
|
1788
|
-
title={title}
|
|
1789
|
-
message={message}
|
|
1790
|
-
style={{
|
|
1791
|
-
backgroundColor: themeColors.buttonBackground,
|
|
1792
|
-
borderColor: themeColors.buttonBackground,
|
|
1793
|
-
borderRadius: 8,
|
|
1794
|
-
height: 34,
|
|
1795
|
-
width: 34,
|
|
1796
|
-
}}
|
|
1797
|
-
textStyle={{
|
|
1798
|
-
color: themeColors.buttonIcon,
|
|
1799
|
-
fontSize: 16,
|
|
1800
|
-
lineHeight: 16,
|
|
1801
|
-
}}
|
|
1802
|
-
/>
|
|
1803
|
-
);
|
|
1804
|
-
|
|
1805
|
-
const renderSwitchRow = ({
|
|
1806
|
-
disabled = false,
|
|
1807
|
-
label,
|
|
1808
|
-
onValueChange,
|
|
1809
|
-
value,
|
|
1810
|
-
valueLabel,
|
|
1811
|
-
}) => {
|
|
1812
|
-
const checked = Boolean(value);
|
|
1813
|
-
|
|
1814
|
-
return (
|
|
1815
|
-
<View
|
|
1816
|
-
style={[
|
|
1817
|
-
styles.toggleRow,
|
|
1818
|
-
{
|
|
1819
|
-
backgroundColor: themeColors.listItemBackground,
|
|
1820
|
-
borderColor: themeColors.listItemBorder,
|
|
1821
|
-
},
|
|
1822
|
-
disabled && styles.toggleRowDisabled,
|
|
1823
|
-
]}>
|
|
1824
|
-
<View style={styles.toggleRowCopy}>
|
|
1825
|
-
<Text
|
|
1826
|
-
style={[
|
|
1827
|
-
styles.toggleRowLabel,
|
|
1828
|
-
{color: themeColors.listItemText},
|
|
1829
|
-
]}>
|
|
1830
|
-
{label}
|
|
1831
|
-
</Text>
|
|
1832
|
-
<Text
|
|
1833
|
-
style={[
|
|
1834
|
-
styles.toggleRowValue,
|
|
1835
|
-
{color: themeColors.listItemSubtitleText},
|
|
1836
|
-
]}>
|
|
1837
|
-
{valueLabel}
|
|
1838
|
-
</Text>
|
|
1839
|
-
</View>
|
|
1840
|
-
<Switch
|
|
1841
|
-
value={checked}
|
|
1842
|
-
disabled={disabled}
|
|
1843
|
-
onValueChange={onValueChange}
|
|
1844
|
-
{...getDeviceSwitchProps({
|
|
1845
|
-
disabled,
|
|
1846
|
-
palette: themeColors,
|
|
1847
|
-
value: checked,
|
|
1848
|
-
})}
|
|
1849
|
-
/>
|
|
1850
|
-
</View>
|
|
1851
|
-
);
|
|
1852
|
-
};
|
|
1853
|
-
|
|
1854
|
-
const renderOptionButtons = ({ options, value, onChange, disabled = false, optionColors = null }) => (
|
|
1855
|
-
<View style={styles.optionRow}>
|
|
1856
|
-
{options.map(option => {
|
|
1857
|
-
const selected = String(option.value) === String(value);
|
|
1858
|
-
const optionDisabled = disabled || option.disabled === true;
|
|
1859
|
-
const optionTitle = String(option.title || '').trim();
|
|
1860
|
-
if (optionDisabled && optionTitle) {
|
|
1861
|
-
return (
|
|
1862
|
-
<OptionButtonChip
|
|
1863
|
-
key={String(option.value)}
|
|
1864
|
-
label={option.label}
|
|
1865
|
-
selected={selected}
|
|
1866
|
-
disabled
|
|
1867
|
-
colors={optionColors}
|
|
1868
|
-
tooltip={optionTitle}
|
|
1869
|
-
onPress={() => onChange(option.value)}
|
|
1870
|
-
/>
|
|
1871
|
-
);
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
return (
|
|
1875
|
-
<OptionButtonChip
|
|
1876
|
-
key={String(option.value)}
|
|
1877
|
-
label={option.label}
|
|
1878
|
-
selected={selected}
|
|
1879
|
-
disabled={optionDisabled}
|
|
1880
|
-
colors={optionColors}
|
|
1881
|
-
tooltip={optionTitle}
|
|
1882
|
-
onPress={() => onChange(option.value)}
|
|
1883
|
-
/>
|
|
1884
|
-
);
|
|
1885
|
-
})}
|
|
1886
|
-
</View>
|
|
1887
|
-
);
|
|
1888
|
-
|
|
1889
|
-
return (
|
|
1890
|
-
<SafeAreaView style={[styles.container, { backgroundColor: brandColors.background }]}>
|
|
1891
|
-
<ScrollView contentContainerStyle={styles.scroll} showsVerticalScrollIndicator={false}>
|
|
1892
|
-
|
|
1893
|
-
{/* Cabeçalho do dispositivo */}
|
|
1894
|
-
<View style={styles.deviceHeader}>
|
|
1895
|
-
<View style={styles.deviceHeaderLeft}>
|
|
1896
|
-
<View style={[styles.deviceIconBox, { backgroundColor: withOpacity(accent, 0.1) }]}>
|
|
1897
|
-
<Icon name="monitor" size={20} color={accent} />
|
|
1898
|
-
</View>
|
|
1899
|
-
|
|
1900
|
-
<View style={styles.aliasBlock}>
|
|
1901
|
-
<View style={styles.aliasRow}>
|
|
1902
|
-
{editingAlias ? (
|
|
1903
|
-
<TextInput
|
|
1904
|
-
ref={aliasInputRef}
|
|
1905
|
-
style={styles.aliasInput}
|
|
1906
|
-
value={aliasInput}
|
|
1907
|
-
onChangeText={setAliasInput}
|
|
1908
|
-
onSubmitEditing={saveAlias}
|
|
1909
|
-
returnKeyType="done"
|
|
1910
|
-
autoCapitalize="words"
|
|
1911
|
-
selectTextOnFocus
|
|
1912
|
-
/>
|
|
1913
|
-
) : (
|
|
1914
|
-
<Text style={styles.deviceAlias} numberOfLines={1} ellipsizeMode="tail">
|
|
1915
|
-
{alias}
|
|
1916
|
-
</Text>
|
|
1917
|
-
)}
|
|
1918
|
-
|
|
1919
|
-
{!!deviceId && (
|
|
1920
|
-
<TouchableOpacity
|
|
1921
|
-
style={[
|
|
1922
|
-
styles.editAliasBtn,
|
|
1923
|
-
{
|
|
1924
|
-
backgroundColor: themeColors.buttonBackground,
|
|
1925
|
-
borderColor: themeColors.buttonBackground,
|
|
1926
|
-
},
|
|
1927
|
-
]}
|
|
1928
|
-
onPress={editingAlias ? saveAlias : startEditAlias}
|
|
1929
|
-
activeOpacity={0.8}
|
|
1930
|
-
disabled={savingAlias || removingDevice}
|
|
1931
|
-
>
|
|
1932
|
-
<Icon
|
|
1933
|
-
name={savingAlias ? 'save' : editingAlias ? 'check' : 'edit-2'}
|
|
1934
|
-
size={16}
|
|
1935
|
-
color={themeColors.buttonIcon}
|
|
1936
|
-
/>
|
|
1937
|
-
</TouchableOpacity>
|
|
1938
|
-
)}
|
|
1939
|
-
{!!deviceId && !editingAlias && (
|
|
1940
|
-
<TouchableOpacity
|
|
1941
|
-
style={[
|
|
1942
|
-
styles.editAliasBtn,
|
|
1943
|
-
{
|
|
1944
|
-
backgroundColor: themeColors.buttonBackground,
|
|
1945
|
-
borderColor: themeColors.buttonBackground,
|
|
1946
|
-
marginLeft: 8,
|
|
1947
|
-
},
|
|
1948
|
-
]}
|
|
1949
|
-
onPress={confirmRemoveDevice}
|
|
1950
|
-
activeOpacity={0.8}
|
|
1951
|
-
disabled={removingDevice || savingAlias}
|
|
1952
|
-
accessibilityLabel="Excluir device"
|
|
1953
|
-
testID="device-detail-delete-btn"
|
|
1954
|
-
>
|
|
1955
|
-
<Icon
|
|
1956
|
-
name={removingDevice ? 'loader' : 'trash-2'}
|
|
1957
|
-
size={16}
|
|
1958
|
-
color={themeColors.buttonIcon}
|
|
1959
|
-
/>
|
|
1960
|
-
</TouchableOpacity>
|
|
1961
|
-
)}
|
|
1962
|
-
</View>
|
|
1963
|
-
|
|
1964
|
-
<Text style={styles.deviceString} numberOfLines={1} ellipsizeMode="middle">
|
|
1965
|
-
{deviceString}
|
|
1966
|
-
</Text>
|
|
1967
|
-
</View>
|
|
1968
|
-
</View>
|
|
1969
|
-
|
|
1970
|
-
</View>
|
|
1971
|
-
|
|
1972
|
-
{loadingActiveTabData && (
|
|
1973
|
-
<StateStore
|
|
1974
|
-
compact
|
|
1975
|
-
loading="Carregando dados do device..."
|
|
1976
|
-
/>
|
|
1977
|
-
)}
|
|
1978
|
-
|
|
1979
|
-
{isPdvDevice && (
|
|
1980
|
-
<View style={styles.tabsBar}>
|
|
1981
|
-
<ScrollView
|
|
1982
|
-
horizontal
|
|
1983
|
-
showsHorizontalScrollIndicator={false}
|
|
1984
|
-
contentContainerStyle={styles.tabsContent}>
|
|
1985
|
-
{PDV_DETAIL_TABS.map(tab => {
|
|
1986
|
-
const active = activePdvTab === tab.key;
|
|
1987
|
-
const tabButtonColors = active
|
|
1988
|
-
? {
|
|
1989
|
-
backgroundColor: themeColors.buttonBackground,
|
|
1990
|
-
borderColor: themeColors.buttonBorder,
|
|
1991
|
-
iconColor: themeColors.buttonIcon,
|
|
1992
|
-
textColor: themeColors.buttonText,
|
|
1993
|
-
}
|
|
1994
|
-
: {
|
|
1995
|
-
backgroundColor: themeColors.buttonBackgroundSecondary,
|
|
1996
|
-
borderColor: themeColors.buttonBorderSecondary,
|
|
1997
|
-
iconColor: themeColors.buttonIconSecondary,
|
|
1998
|
-
textColor: themeColors.buttonTextSecondary,
|
|
1999
|
-
};
|
|
2000
|
-
|
|
2001
|
-
return (
|
|
2002
|
-
<TouchableOpacity
|
|
2003
|
-
key={tab.key}
|
|
2004
|
-
style={[
|
|
2005
|
-
styles.tabButton,
|
|
2006
|
-
{
|
|
2007
|
-
backgroundColor: tabButtonColors.backgroundColor,
|
|
2008
|
-
borderColor: tabButtonColors.borderColor,
|
|
2009
|
-
},
|
|
2010
|
-
]}
|
|
2011
|
-
activeOpacity={0.85}
|
|
2012
|
-
onPress={() => setActivePdvTab(tab.key)}>
|
|
2013
|
-
<Icon
|
|
2014
|
-
name={tab.icon}
|
|
2015
|
-
size={14}
|
|
2016
|
-
color={tabButtonColors.iconColor}
|
|
2017
|
-
/>
|
|
2018
|
-
<Text
|
|
2019
|
-
style={[
|
|
2020
|
-
styles.tabButtonText,
|
|
2021
|
-
{color: tabButtonColors.textColor},
|
|
2022
|
-
]}>
|
|
2023
|
-
{tt('tab', tab.labelKey) ||
|
|
2024
|
-
(tab.key === PDV_TAB_PAYMENT_TYPES
|
|
2025
|
-
? 'Pagamentos'
|
|
2026
|
-
: tab.labelKey)}
|
|
2027
|
-
</Text>
|
|
2028
|
-
</TouchableOpacity>
|
|
2029
|
-
);
|
|
2030
|
-
})}
|
|
2031
|
-
</ScrollView>
|
|
2032
|
-
</View>
|
|
2033
|
-
)}
|
|
2034
|
-
|
|
2035
|
-
{showPdvMovementTab && (
|
|
2036
|
-
<View style={styles.summaryRow}>
|
|
2037
|
-
<View style={styles.summaryCard}>
|
|
2038
|
-
<Icon name="dollar-sign" size={14} color={hex.success} style={styles.summaryIcon} />
|
|
2039
|
-
<Text style={styles.summaryLabel}>Total Geral</Text>
|
|
2040
|
-
<Text style={[styles.summaryValue, { color: hex.success }]}>
|
|
2041
|
-
{Formatter.formatMoney(inflowTotal)}
|
|
2042
|
-
</Text>
|
|
2043
|
-
</View>
|
|
2044
|
-
<View style={styles.summaryCard}>
|
|
2045
|
-
<Icon name="shopping-bag" size={14} color={hex.info} style={styles.summaryIcon} />
|
|
2046
|
-
<Text style={styles.summaryLabel}>Em Produtos</Text>
|
|
2047
|
-
<Text style={[styles.summaryValue, { color: hex.info }]}>
|
|
2048
|
-
{Formatter.formatMoney(productTotal)}
|
|
2049
|
-
</Text>
|
|
2050
|
-
</View>
|
|
2051
|
-
<View style={styles.summaryCard}>
|
|
2052
|
-
<Icon name="package" size={14} color={hex.purple} style={styles.summaryIcon} />
|
|
2053
|
-
<Text style={styles.summaryLabel}>Itens</Text>
|
|
2054
|
-
<Text style={[styles.summaryValue, { color: hex.purple }]}>
|
|
2055
|
-
{products.length}
|
|
2056
|
-
</Text>
|
|
2057
|
-
</View>
|
|
2058
|
-
</View>
|
|
2059
|
-
)}
|
|
2060
|
-
|
|
2061
|
-
{showPdvOperationTab && (
|
|
2062
|
-
<View style={styles.section}>
|
|
2063
|
-
<Text style={styles.sectionTitle}>
|
|
2064
|
-
<Icon name="credit-card" size={13} /> {' '}Configuração do PDV
|
|
2065
|
-
</Text>
|
|
2066
|
-
|
|
2067
|
-
<View style={styles.configCard}>
|
|
2068
|
-
<View style={styles.sectionTitleRow}>
|
|
2069
|
-
<Text style={styles.configTitle}>
|
|
2070
|
-
{tt('title', 'posOperationMode')}
|
|
2071
|
-
</Text>
|
|
2072
|
-
{renderHelpButton(
|
|
2073
|
-
tt('title', 'posOperationMode') || 'Modo de operacao',
|
|
2074
|
-
tt('description', 'posOperationModeDescription') ||
|
|
2075
|
-
'Escolha o modo, a trava kiosk e a politica de ordem/caixa deste device.',
|
|
2076
|
-
)}
|
|
2077
|
-
</View>
|
|
2078
|
-
|
|
2079
|
-
{renderOptionButtons({
|
|
2080
|
-
options: POS_OPERATION_MODE_OPTIONS.map(option => ({
|
|
2081
|
-
label: tt('option', option.translationKey),
|
|
2082
|
-
value: option.value,
|
|
2083
|
-
})),
|
|
2084
|
-
value: posOperationMode,
|
|
2085
|
-
optionColors: {
|
|
2086
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2087
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2088
|
-
buttonText: themeColors.buttonText,
|
|
2089
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2090
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2091
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2092
|
-
},
|
|
2093
|
-
onChange: value => {
|
|
2094
|
-
const nextValue = resolvePosOperationMode({
|
|
2095
|
-
[POS_OPERATION_MODE_CONFIG_KEY]: value,
|
|
2096
|
-
});
|
|
2097
|
-
setPosOperationMode(nextValue);
|
|
2098
|
-
savePosOperationMode({posOperationMode: nextValue});
|
|
2099
|
-
},
|
|
2100
|
-
})}
|
|
2101
|
-
|
|
2102
|
-
<View style={styles.pickerWrap}>
|
|
2103
|
-
<Picker
|
|
2104
|
-
selectedValue={productShowcaseId || ''}
|
|
2105
|
-
mode={pickerMode}
|
|
2106
|
-
enabled={!loadingProductShowcases && !savingProductShowcase}
|
|
2107
|
-
style={styles.picker}
|
|
2108
|
-
dropdownIconColor="#64748B"
|
|
2109
|
-
onValueChange={value => {
|
|
2110
|
-
const nextValue = normalizeEntityId(value);
|
|
2111
|
-
setProductShowcaseId(nextValue);
|
|
2112
|
-
saveProductShowcaseConfig({productShowcaseId: nextValue});
|
|
2113
|
-
}}>
|
|
2114
|
-
<Picker.Item
|
|
2115
|
-
label={
|
|
2116
|
-
loadingProductShowcases
|
|
2117
|
-
? 'Carregando vitrines...'
|
|
2118
|
-
: 'Sem vitrine vinculada'
|
|
2119
|
-
}
|
|
2120
|
-
value=""
|
|
2121
|
-
/>
|
|
2122
|
-
{productShowcases.map(showcase => {
|
|
2123
|
-
const showcaseId = normalizeEntityId(showcase);
|
|
2124
|
-
return (
|
|
2125
|
-
<Picker.Item
|
|
2126
|
-
key={`pos-showcase-${showcaseId}`}
|
|
2127
|
-
label={getProductShowcaseLabel(showcase)}
|
|
2128
|
-
value={showcaseId}
|
|
2129
|
-
/>
|
|
2130
|
-
);
|
|
2131
|
-
})}
|
|
2132
|
-
</Picker>
|
|
2133
|
-
</View>
|
|
2134
|
-
|
|
2135
|
-
{renderSwitchRow({
|
|
2136
|
-
disabled: savingPosOperationMode,
|
|
2137
|
-
label: 'Modo Kiosk',
|
|
2138
|
-
value: androidKioskEnabled,
|
|
2139
|
-
valueLabel: androidKioskEnabled ? 'Ativo' : 'Inativo',
|
|
2140
|
-
onValueChange: nextValue => {
|
|
2141
|
-
setAndroidKioskEnabled(nextValue);
|
|
2142
|
-
savePosOperationMode({androidKioskEnabled: nextValue});
|
|
2143
|
-
},
|
|
2144
|
-
})}
|
|
2145
|
-
|
|
2146
|
-
{renderOptionButtons({
|
|
2147
|
-
options: [
|
|
2148
|
-
{
|
|
2149
|
-
label: global.t?.t('configs', 'option', 'none') || 'None',
|
|
2150
|
-
value: POS_CHECK_ORDER_TYPE_NONE,
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
label: global.t?.t('orders', 'title', 'tab') || 'Tab',
|
|
2154
|
-
value: POS_CHECK_ORDER_TYPE_TAB,
|
|
2155
|
-
},
|
|
2156
|
-
{
|
|
2157
|
-
label: global.t?.t('orders', 'title', 'table') || 'Table',
|
|
2158
|
-
value: POS_CHECK_ORDER_TYPE_TABLE,
|
|
2159
|
-
},
|
|
2160
|
-
{
|
|
2161
|
-
label: global.t?.t('orders', 'title', 'stamp') || 'Stamp',
|
|
2162
|
-
value: POS_CHECK_ORDER_TYPE_STAMP,
|
|
2163
|
-
disabled: !loyaltyCouponsEnabled,
|
|
2164
|
-
title: !loyaltyCouponsEnabled
|
|
2165
|
-
? 'Ative em Shop -> Cupom fidelidade\npara liberar Stamp'
|
|
2166
|
-
: '',
|
|
2167
|
-
},
|
|
2168
|
-
],
|
|
2169
|
-
value: checkOrderType,
|
|
2170
|
-
optionColors: {
|
|
2171
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2172
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2173
|
-
buttonText: themeColors.buttonText,
|
|
2174
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2175
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2176
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2177
|
-
},
|
|
2178
|
-
onChange: value => {
|
|
2179
|
-
const nextCheckOrderType =
|
|
2180
|
-
value === POS_CHECK_ORDER_TYPE_TAB
|
|
2181
|
-
? POS_CHECK_ORDER_TYPE_TAB
|
|
2182
|
-
: value === POS_CHECK_ORDER_TYPE_TABLE
|
|
2183
|
-
? POS_CHECK_ORDER_TYPE_TABLE
|
|
2184
|
-
: value === POS_CHECK_ORDER_TYPE_STAMP
|
|
2185
|
-
? loyaltyCouponsEnabled
|
|
2186
|
-
? POS_CHECK_ORDER_TYPE_STAMP
|
|
2187
|
-
: POS_CHECK_ORDER_TYPE_NONE
|
|
2188
|
-
: POS_CHECK_ORDER_TYPE_NONE;
|
|
2189
|
-
const nextCheckOrderManagementMode =
|
|
2190
|
-
nextCheckOrderType === POS_CHECK_ORDER_TYPE_NONE
|
|
2191
|
-
? POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE
|
|
2192
|
-
: checkOrderManagementMode;
|
|
2193
|
-
setCheckOrderType(nextCheckOrderType);
|
|
2194
|
-
if (nextCheckOrderType === POS_CHECK_ORDER_TYPE_NONE) {
|
|
2195
|
-
setCheckOrderManagementMode(
|
|
2196
|
-
POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
2197
|
-
);
|
|
2198
|
-
}
|
|
2199
|
-
savePosOperationMode({
|
|
2200
|
-
checkOrderType: nextCheckOrderType,
|
|
2201
|
-
checkOrderManagementMode: nextCheckOrderManagementMode,
|
|
2202
|
-
});
|
|
2203
|
-
},
|
|
2204
|
-
})}
|
|
2205
|
-
|
|
2206
|
-
{checkOrderType !== POS_CHECK_ORDER_TYPE_NONE &&
|
|
2207
|
-
renderOptionButtons({
|
|
2208
|
-
options: [
|
|
2209
|
-
{
|
|
2210
|
-
label:
|
|
2211
|
-
global.t?.t(
|
|
2212
|
-
'configs',
|
|
2213
|
-
'option',
|
|
2214
|
-
'manageLinkedOrders',
|
|
2215
|
-
) || 'Open and close tabs/tables/stamps',
|
|
2216
|
-
value: POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE,
|
|
2217
|
-
},
|
|
2218
|
-
{
|
|
2219
|
-
label:
|
|
2220
|
-
global.t?.t(
|
|
2221
|
-
'configs',
|
|
2222
|
-
'option',
|
|
2223
|
-
'existingLinkedOrdersOnly',
|
|
2224
|
-
) || 'Use open tabs/tables/stamps only',
|
|
2225
|
-
value: POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY,
|
|
2226
|
-
},
|
|
2227
|
-
],
|
|
2228
|
-
value: checkOrderManagementMode,
|
|
2229
|
-
onChange: value => {
|
|
2230
|
-
const nextValue =
|
|
2231
|
-
value === POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY
|
|
2232
|
-
? POS_CHECK_ORDER_MANAGEMENT_MODE_EXISTING_ONLY
|
|
2233
|
-
: POS_CHECK_ORDER_MANAGEMENT_MODE_MANAGE;
|
|
2234
|
-
setCheckOrderManagementMode(nextValue);
|
|
2235
|
-
savePosOperationMode({checkOrderManagementMode: nextValue});
|
|
2236
|
-
},
|
|
2237
|
-
})}
|
|
2238
|
-
|
|
2239
|
-
{posOperationMode === POS_OPERATION_MODE_COUNTER && (
|
|
2240
|
-
<>
|
|
2241
|
-
{renderSwitchRow({
|
|
2242
|
-
disabled: savingPosOperationMode,
|
|
2243
|
-
label: 'Impressao automatica',
|
|
2244
|
-
value: counterAutoPrintEnabled,
|
|
2245
|
-
valueLabel: counterAutoPrintEnabled ? 'Sim' : 'Nao',
|
|
2246
|
-
onValueChange: nextValue => {
|
|
2247
|
-
setCounterAutoPrintEnabled(nextValue);
|
|
2248
|
-
savePosOperationMode({counterAutoPrintEnabled: nextValue});
|
|
2249
|
-
},
|
|
2250
|
-
})}
|
|
2251
|
-
|
|
2252
|
-
{counterAutoPrintEnabled &&
|
|
2253
|
-
renderOptionButtons({
|
|
2254
|
-
options: [
|
|
2255
|
-
{label: 'Pedido', value: POS_PRINT_MODE_ORDER},
|
|
2256
|
-
{label: 'Fichas', value: POS_PRINT_MODE_FORM},
|
|
2257
|
-
],
|
|
2258
|
-
value: counterPrintMode,
|
|
2259
|
-
optionColors: {
|
|
2260
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2261
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2262
|
-
buttonText: themeColors.buttonText,
|
|
2263
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2264
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2265
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2266
|
-
},
|
|
2267
|
-
onChange: value => {
|
|
2268
|
-
const nextValue =
|
|
2269
|
-
value === POS_PRINT_MODE_FORM
|
|
2270
|
-
? POS_PRINT_MODE_FORM
|
|
2271
|
-
: POS_PRINT_MODE_ORDER;
|
|
2272
|
-
setCounterPrintMode(nextValue);
|
|
2273
|
-
savePosOperationMode({counterPrintMode: nextValue});
|
|
2274
|
-
},
|
|
2275
|
-
})}
|
|
2276
|
-
|
|
2277
|
-
{renderOptionButtons({
|
|
2278
|
-
options: [
|
|
2279
|
-
{
|
|
2280
|
-
label: 'Abertura e fechamento de caixa',
|
|
2281
|
-
value: POS_CASH_MANAGEMENT_MODE_CASH_REGISTER,
|
|
2282
|
-
},
|
|
2283
|
-
{
|
|
2284
|
-
label: 'Fechamento diario',
|
|
2285
|
-
value: POS_CASH_MANAGEMENT_MODE_DAILY,
|
|
2286
|
-
},
|
|
2287
|
-
],
|
|
2288
|
-
value: counterCashManagementMode,
|
|
2289
|
-
optionColors: {
|
|
2290
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2291
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2292
|
-
buttonText: themeColors.buttonText,
|
|
2293
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2294
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2295
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2296
|
-
},
|
|
2297
|
-
onChange: value => {
|
|
2298
|
-
const nextValue =
|
|
2299
|
-
value === POS_CASH_MANAGEMENT_MODE_DAILY
|
|
2300
|
-
? POS_CASH_MANAGEMENT_MODE_DAILY
|
|
2301
|
-
: POS_CASH_MANAGEMENT_MODE_CASH_REGISTER;
|
|
2302
|
-
setCounterCashManagementMode(nextValue);
|
|
2303
|
-
savePosOperationMode({counterCashManagementMode: nextValue});
|
|
2304
|
-
},
|
|
2305
|
-
})}
|
|
2306
|
-
</>
|
|
2307
|
-
)}
|
|
2308
|
-
</View>
|
|
2309
|
-
|
|
2310
|
-
<View style={styles.configCard}>
|
|
2311
|
-
<View style={styles.sectionTitleRow}>
|
|
2312
|
-
<Text style={[styles.configTitle, {color: brandColors.text}]}>
|
|
2313
|
-
{tt('title', 'androidLauncherMode') || 'Launcher / home app'}
|
|
2314
|
-
</Text>
|
|
2315
|
-
{renderHelpButton(
|
|
2316
|
-
tt('title', 'androidLauncherMode') || 'Launcher / home app',
|
|
2317
|
-
tt('description', 'androidLauncherDescription') ||
|
|
2318
|
-
'Quando ativado, o device volta para a app ao usar home ou apps recentes. O voltar continua seguindo a tela.',
|
|
2319
|
-
)}
|
|
2320
|
-
</View>
|
|
2321
|
-
|
|
2322
|
-
{renderSwitchRow({
|
|
2323
|
-
disabled: savingLauncherMode,
|
|
2324
|
-
label: 'Modo launcher?',
|
|
2325
|
-
value: androidLauncherEnabled,
|
|
2326
|
-
valueLabel: androidLauncherEnabled ? 'Ativo' : 'Inativo',
|
|
2327
|
-
onValueChange: nextValue => {
|
|
2328
|
-
setAndroidLauncherEnabled(nextValue);
|
|
2329
|
-
saveLauncherMode({androidLauncherEnabled: nextValue});
|
|
2330
|
-
},
|
|
2331
|
-
})}
|
|
2332
|
-
<Text style={[styles.deviceString, {color: brandColors.textSecondary}]}>
|
|
2333
|
-
Salva automaticamente
|
|
2334
|
-
</Text>
|
|
2335
|
-
</View>
|
|
2336
|
-
|
|
2337
|
-
<View style={styles.configCard}>
|
|
2338
|
-
<View style={styles.sectionTitleRow}>
|
|
2339
|
-
<Text style={styles.configTitle}>Gateway e impressora</Text>
|
|
2340
|
-
{renderHelpButton(
|
|
2341
|
-
'Gateway e impressora',
|
|
2342
|
-
'Escolha o gateway usado pelo PDV e se ele pode aparecer como destino de impressao.',
|
|
2343
|
-
)}
|
|
2344
|
-
</View>
|
|
2345
|
-
|
|
2346
|
-
{renderOptionButtons({
|
|
2347
|
-
options: [
|
|
2348
|
-
{label: 'Nenhum', value: ''},
|
|
2349
|
-
{label: 'Infinite Pay', value: 'infinite-pay'},
|
|
2350
|
-
{label: 'Cielo', value: 'cielo'},
|
|
2351
|
-
],
|
|
2352
|
-
value: pdvGateway || '',
|
|
2353
|
-
optionColors: {
|
|
2354
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2355
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2356
|
-
buttonText: themeColors.buttonText,
|
|
2357
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2358
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2359
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2360
|
-
},
|
|
2361
|
-
onChange: value => {
|
|
2362
|
-
const nextValue = String(value || '');
|
|
2363
|
-
setPdvGateway(nextValue);
|
|
2364
|
-
savePdvSettings({pdvGateway: nextValue});
|
|
2365
|
-
},
|
|
2366
|
-
})}
|
|
2367
|
-
|
|
2368
|
-
{renderSwitchRow({
|
|
2369
|
-
disabled: savingPdvSettings,
|
|
2370
|
-
label: 'Impressora',
|
|
2371
|
-
value: pdvPrinterEnabled,
|
|
2372
|
-
valueLabel: pdvPrinterEnabled ? 'Sim' : 'Nao',
|
|
2373
|
-
onValueChange: nextValue => {
|
|
2374
|
-
setPdvPrinterEnabled(nextValue);
|
|
2375
|
-
savePdvSettings({pdvPrinterEnabled: nextValue});
|
|
2376
|
-
},
|
|
2377
|
-
})}
|
|
2378
|
-
<Text style={styles.deviceString}>Salva automaticamente</Text>
|
|
2379
|
-
</View>
|
|
2380
|
-
</View>
|
|
2381
|
-
)}
|
|
2382
|
-
|
|
2383
|
-
{shouldShowOrderVisibility && (
|
|
2384
|
-
<View style={styles.section}>
|
|
2385
|
-
<Text style={styles.sectionTitle}>
|
|
2386
|
-
<Icon name="list" size={13} /> {' '}Pedidos do Device
|
|
2387
|
-
</Text>
|
|
2388
|
-
|
|
2389
|
-
<View style={styles.configCard}>
|
|
2390
|
-
<View style={styles.sectionTitleRow}>
|
|
2391
|
-
<Text style={styles.configTitle}>Escopo da listagem no PDV</Text>
|
|
2392
|
-
{renderHelpButton(
|
|
2393
|
-
'Escopo da listagem',
|
|
2394
|
-
'Define se este device mostra apenas os pedidos criados nele ou todos os pedidos da empresa.',
|
|
2395
|
-
)}
|
|
2396
|
-
</View>
|
|
2397
|
-
|
|
2398
|
-
{renderOptionButtons({
|
|
2399
|
-
options: [
|
|
2400
|
-
{
|
|
2401
|
-
label: 'Somente deste device',
|
|
2402
|
-
value: DEVICE_ORDER_VISIBILITY_DEVICE,
|
|
2403
|
-
},
|
|
2404
|
-
{
|
|
2405
|
-
label: 'Todos da empresa',
|
|
2406
|
-
value: DEVICE_ORDER_VISIBILITY_COMPANY,
|
|
2407
|
-
},
|
|
2408
|
-
],
|
|
2409
|
-
value: deviceOrderVisibility,
|
|
2410
|
-
optionColors: {
|
|
2411
|
-
buttonBackground: themeColors.buttonBackground,
|
|
2412
|
-
buttonBorder: themeColors.buttonBorder,
|
|
2413
|
-
buttonText: themeColors.buttonText,
|
|
2414
|
-
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
2415
|
-
buttonBorderSecondary: themeColors.buttonBorderSecondary,
|
|
2416
|
-
buttonTextSecondary: themeColors.buttonTextSecondary,
|
|
2417
|
-
},
|
|
2418
|
-
onChange: value => {
|
|
2419
|
-
const nextValue =
|
|
2420
|
-
value || DEVICE_ORDER_VISIBILITY_DEVICE;
|
|
2421
|
-
setDeviceOrderVisibility(nextValue);
|
|
2422
|
-
saveDeviceOrderVisibility({deviceOrderVisibility: nextValue});
|
|
2423
|
-
},
|
|
2424
|
-
})}
|
|
2425
|
-
</View>
|
|
2426
|
-
|
|
2427
|
-
<View style={styles.configCard}>
|
|
2428
|
-
<View style={styles.sectionTitleRow}>
|
|
2429
|
-
<Text style={styles.configTitle}>
|
|
2430
|
-
{tt('title', 'deliveryOnDevice') || 'Delivery neste equipamento'}
|
|
2431
|
-
</Text>
|
|
2432
|
-
{renderHelpButton(
|
|
2433
|
-
tt('title', 'deliveryOnDevice') || 'Delivery neste equipamento',
|
|
2434
|
-
tt('description', 'deliveryOnDeviceDescription') ||
|
|
2435
|
-
'Ative quando este equipamento precisa operar pedidos com cliente, endereço e observações de entrega.',
|
|
2436
|
-
)}
|
|
2437
|
-
</View>
|
|
2438
|
-
|
|
2439
|
-
{renderSwitchRow({
|
|
2440
|
-
disabled: savingDeviceDeliverySettings,
|
|
2441
|
-
label: tt('label', 'deliveryEnabled') ||
|
|
2442
|
-
'Trabalhar com delivery',
|
|
2443
|
-
value: deviceDeliveryEnabled,
|
|
2444
|
-
valueLabel: deviceDeliveryEnabled ? 'Ativo' : 'Inativo',
|
|
2445
|
-
onValueChange: nextValue => {
|
|
2446
|
-
setDeviceDeliveryEnabled(nextValue);
|
|
2447
|
-
saveDeviceDeliverySettings({
|
|
2448
|
-
deviceDeliveryEnabled: nextValue,
|
|
2449
|
-
});
|
|
2450
|
-
},
|
|
2451
|
-
})}
|
|
2452
|
-
</View>
|
|
2453
|
-
</View>
|
|
2454
|
-
)}
|
|
2455
|
-
|
|
2456
|
-
{isDisplayDevice && (
|
|
2457
|
-
<View style={styles.section}>
|
|
2458
|
-
<Text style={styles.sectionTitle}>
|
|
2459
|
-
<Icon name="printer" size={13} /> {' '}Impressão de Preparo
|
|
2460
|
-
</Text>
|
|
2461
|
-
|
|
2462
|
-
<View style={styles.configCard}>
|
|
2463
|
-
<View style={styles.sectionTitleRow}>
|
|
2464
|
-
<Text style={styles.configTitle}>Display vinculado e impressora da fila</Text>
|
|
2465
|
-
{renderHelpButton(
|
|
2466
|
-
'Display vinculado e impressora da fila',
|
|
2467
|
-
'Este bloco é usado na impressão automática disparada pelo app DISPLAY. O device DISPLAY precisa apontar qual display representa e qual impressora deve receber a cópia separada por fila.',
|
|
2468
|
-
)}
|
|
2469
|
-
</View>
|
|
2470
|
-
|
|
2471
|
-
{(isLoadingDisplays || isLoadingPrinters) ? (
|
|
2472
|
-
<StateStore
|
|
2473
|
-
compact
|
|
2474
|
-
loading="Carregando displays e impressoras..."
|
|
2475
|
-
/>
|
|
2476
|
-
) : (
|
|
2477
|
-
<>
|
|
2478
|
-
<View style={styles.pickerWrap}>
|
|
2479
|
-
<Picker
|
|
2480
|
-
selectedValue={linkedDisplayId || ''}
|
|
2481
|
-
mode={pickerMode}
|
|
2482
|
-
style={styles.picker}
|
|
2483
|
-
dropdownIconColor="#64748B"
|
|
2484
|
-
onValueChange={value => {
|
|
2485
|
-
const nextValue = String(value || '').trim();
|
|
2486
|
-
setLinkedDisplayId(nextValue);
|
|
2487
|
-
saveDisplayPrintingConfig({linkedDisplayId: nextValue});
|
|
2488
|
-
}}>
|
|
2489
|
-
<Picker.Item
|
|
2490
|
-
label="Nenhum display vinculado"
|
|
2491
|
-
value=""
|
|
2492
|
-
/>
|
|
2493
|
-
{displayOptions.map(option => {
|
|
2494
|
-
const optionId = normalizeEntityId(option);
|
|
2495
|
-
return (
|
|
2496
|
-
<Picker.Item
|
|
2497
|
-
key={`display-option-${optionId}`}
|
|
2498
|
-
label={getDisplayLabel(option)}
|
|
2499
|
-
value={optionId}
|
|
2500
|
-
/>
|
|
2501
|
-
);
|
|
2502
|
-
})}
|
|
2503
|
-
</Picker>
|
|
2504
|
-
</View>
|
|
2505
|
-
|
|
2506
|
-
<View style={styles.pickerWrap}>
|
|
2507
|
-
<Picker
|
|
2508
|
-
selectedValue={displayPrinterId || ''}
|
|
2509
|
-
mode={pickerMode}
|
|
2510
|
-
style={styles.picker}
|
|
2511
|
-
dropdownIconColor="#64748B"
|
|
2512
|
-
onValueChange={value => {
|
|
2513
|
-
const nextValue = normalizeDeviceId(value);
|
|
2514
|
-
setDisplayPrinterId(nextValue);
|
|
2515
|
-
saveDisplayPrintingConfig({
|
|
2516
|
-
displayPrinterId: nextValue,
|
|
2517
|
-
});
|
|
2518
|
-
}}>
|
|
2519
|
-
<Picker.Item
|
|
2520
|
-
label="Nenhuma impressora configurada"
|
|
2521
|
-
value=""
|
|
2522
|
-
/>
|
|
2523
|
-
{printerOptions.map(option => {
|
|
2524
|
-
const printerId = normalizeDeviceId(option?.device);
|
|
2525
|
-
const printerValue = getPrinterOptionValue(option);
|
|
2526
|
-
const printerTypeLabel = getDeviceTypeLabel(
|
|
2527
|
-
option?.type,
|
|
2528
|
-
);
|
|
2529
|
-
return (
|
|
2530
|
-
<Picker.Item
|
|
2531
|
-
key={`printer-option-${printerValue || printerId}`}
|
|
2532
|
-
label={`${getPrinterLabel(option)} (${printerTypeLabel} • ${printerId})`}
|
|
2533
|
-
value={printerValue || printerId}
|
|
2534
|
-
/>
|
|
2535
|
-
);
|
|
2536
|
-
})}
|
|
2537
|
-
</Picker>
|
|
2538
|
-
</View>
|
|
2539
|
-
|
|
2540
|
-
{renderSwitchRow({
|
|
2541
|
-
disabled: savingDisplayPrintingConfig,
|
|
2542
|
-
label: 'Pode trocar de impressora?',
|
|
2543
|
-
value: displayAllowPrinterChange,
|
|
2544
|
-
valueLabel: displayAllowPrinterChange ? 'Sim' : 'Nao',
|
|
2545
|
-
onValueChange: nextValue => {
|
|
2546
|
-
setDisplayAllowPrinterChange(nextValue);
|
|
2547
|
-
saveDisplayPrintingConfig({
|
|
2548
|
-
displayAllowPrinterChange: nextValue,
|
|
2549
|
-
});
|
|
2550
|
-
},
|
|
2551
|
-
})}
|
|
2552
|
-
|
|
2553
|
-
{renderSwitchRow({
|
|
2554
|
-
disabled: savingDisplayPrintingConfig,
|
|
2555
|
-
label: 'Imprimir produtos automaticamente',
|
|
2556
|
-
value: displayAutoPrintProductEnabled,
|
|
2557
|
-
valueLabel: displayAutoPrintProductEnabled
|
|
2558
|
-
? 'Ativo'
|
|
2559
|
-
: 'Inativo',
|
|
2560
|
-
onValueChange: nextValue => {
|
|
2561
|
-
setDisplayAutoPrintProductEnabled(nextValue);
|
|
2562
|
-
saveDisplayPrintingConfig({
|
|
2563
|
-
displayAutoPrintProductEnabled: nextValue,
|
|
2564
|
-
});
|
|
2565
|
-
},
|
|
2566
|
-
})}
|
|
2567
|
-
</>
|
|
2568
|
-
)}
|
|
2569
|
-
</View>
|
|
2570
|
-
</View>
|
|
2571
|
-
)}
|
|
2572
|
-
|
|
2573
|
-
{shouldShowDeviceBehavior && (
|
|
2574
|
-
<View style={styles.section}>
|
|
2575
|
-
<Text style={styles.sectionTitle}>
|
|
2576
|
-
<Icon name="volume-2" size={13} /> {' '}Aviso Sonoro
|
|
2577
|
-
</Text>
|
|
2578
|
-
|
|
2579
|
-
<View style={styles.configCard}>
|
|
2580
|
-
<View style={styles.sectionTitleRow}>
|
|
2581
|
-
<Text style={styles.configTitle}>Alerta via websocket</Text>
|
|
2582
|
-
{renderHelpButton(
|
|
2583
|
-
'Alerta via websocket',
|
|
2584
|
-
'Quando habilitado, este device toca o audio configurado ao receber o evento order.created de um novo pedido em preparo.',
|
|
2585
|
-
)}
|
|
2586
|
-
</View>
|
|
2587
|
-
|
|
2588
|
-
{renderSwitchRow({
|
|
2589
|
-
disabled: savingAlertSound,
|
|
2590
|
-
label: 'Aviso sonoro habilitado',
|
|
2591
|
-
value: deviceAlertSoundEnabled,
|
|
2592
|
-
valueLabel: deviceAlertSoundEnabled ? 'Ativo' : 'Inativo',
|
|
2593
|
-
onValueChange: nextValue => {
|
|
2594
|
-
setDeviceAlertSoundEnabled(nextValue);
|
|
2595
|
-
saveDeviceAlertSoundConfig({
|
|
2596
|
-
deviceAlertSoundEnabled: nextValue,
|
|
2597
|
-
});
|
|
2598
|
-
},
|
|
2599
|
-
})}
|
|
2600
|
-
|
|
2601
|
-
<View style={styles.textInputWrap}>
|
|
2602
|
-
<Text style={styles.textInputLabel}>URL do audio</Text>
|
|
2603
|
-
<TextInput
|
|
2604
|
-
style={styles.textInput}
|
|
2605
|
-
value={deviceAlertSoundUrl}
|
|
2606
|
-
onChangeText={setDeviceAlertSoundUrl}
|
|
2607
|
-
placeholder="https://exemplo.com/alerta.mp3"
|
|
2608
|
-
placeholderTextColor="#94A3B8"
|
|
2609
|
-
autoCapitalize="none"
|
|
2610
|
-
autoCorrect={false}
|
|
2611
|
-
keyboardType="url"
|
|
2612
|
-
returnKeyType="done"
|
|
2613
|
-
onSubmitEditing={saveDeviceAlertSoundConfig}
|
|
2614
|
-
onBlur={saveDeviceAlertSoundConfig}
|
|
2615
|
-
/>
|
|
2616
|
-
</View>
|
|
2617
|
-
</View>
|
|
2618
|
-
</View>
|
|
2619
|
-
)}
|
|
2620
|
-
|
|
2621
|
-
{shouldShowDeviceBehavior && (
|
|
2622
|
-
<View style={styles.section}>
|
|
2623
|
-
<Text style={styles.sectionTitle}>
|
|
2624
|
-
<Icon name="activity" size={13} /> {' '}Rodapé do Sistema
|
|
2625
|
-
</Text>
|
|
2626
|
-
|
|
2627
|
-
<View style={styles.configCard}>
|
|
2628
|
-
<View style={styles.sectionTitleRow}>
|
|
2629
|
-
<Text style={styles.configTitle}>Debug do socket no rodapé</Text>
|
|
2630
|
-
{renderHelpButton(
|
|
2631
|
-
'Debug do socket no rodapé',
|
|
2632
|
-
'Quando habilitado, este device troca a bolinha discreta do socket pelos detalhes de debug publicados pelos serviços do runtime no rodapé global do sistema.',
|
|
2633
|
-
)}
|
|
2634
|
-
</View>
|
|
2635
|
-
|
|
2636
|
-
{renderSwitchRow({
|
|
2637
|
-
disabled: savingRuntimeDebugInfo,
|
|
2638
|
-
label: 'Exibir debug detalhado',
|
|
2639
|
-
value: deviceRuntimeDebugInfoEnabled,
|
|
2640
|
-
valueLabel: deviceRuntimeDebugInfoEnabled ? 'Ativo' : 'Inativo',
|
|
2641
|
-
onValueChange: nextValue => {
|
|
2642
|
-
setDeviceRuntimeDebugInfoEnabled(nextValue);
|
|
2643
|
-
saveDeviceRuntimeDebugInfo({
|
|
2644
|
-
deviceRuntimeDebugInfoEnabled: nextValue,
|
|
2645
|
-
});
|
|
2646
|
-
},
|
|
2647
|
-
})}
|
|
2648
|
-
</View>
|
|
2649
|
-
</View>
|
|
2650
|
-
)}
|
|
2651
|
-
|
|
2652
|
-
{shouldShowRemotePayment && (
|
|
2653
|
-
<View style={styles.section}>
|
|
2654
|
-
<Text style={styles.sectionTitle}>
|
|
2655
|
-
<Icon name="credit-card" size={13} /> {' '}Pagamento Remoto
|
|
2656
|
-
</Text>
|
|
2657
|
-
|
|
2658
|
-
<View style={styles.configCard}>
|
|
2659
|
-
<View style={styles.sectionTitleRow}>
|
|
2660
|
-
<Text style={styles.configTitle}>Device preferencial para pagamento</Text>
|
|
2661
|
-
{renderHelpButton(
|
|
2662
|
-
'Device preferencial para pagamento',
|
|
2663
|
-
'Esse destino funciona como fallback desta origem quando a empresa não definiu uma ordem padrão no configurador geral. Quando a empresa tiver devices padrão para pagamento remoto, essa ordem global tem prioridade.',
|
|
2664
|
-
)}
|
|
2665
|
-
</View>
|
|
2666
|
-
|
|
2667
|
-
<View style={styles.pickerWrap}>
|
|
2668
|
-
<Picker
|
|
2669
|
-
selectedValue={devicePaymentTarget || ''}
|
|
2670
|
-
mode={pickerMode}
|
|
2671
|
-
style={styles.picker}
|
|
2672
|
-
dropdownIconColor="#64748B"
|
|
2673
|
-
onValueChange={value => {
|
|
2674
|
-
const nextValue = value || '';
|
|
2675
|
-
setDevicePaymentTarget(nextValue);
|
|
2676
|
-
saveDevicePaymentTarget({
|
|
2677
|
-
devicePaymentTarget: nextValue,
|
|
2678
|
-
});
|
|
2679
|
-
}}>
|
|
2680
|
-
<Picker.Item
|
|
2681
|
-
label="Usar devices padrão da empresa"
|
|
2682
|
-
value=""
|
|
2683
|
-
/>
|
|
2684
|
-
{paymentDeviceOptions.map(option => (
|
|
2685
|
-
<Picker.Item
|
|
2686
|
-
key={option.deviceId}
|
|
2687
|
-
label={`${option.alias} (${option.gatewayLabel})`}
|
|
2688
|
-
value={option.deviceId}
|
|
2689
|
-
/>
|
|
2690
|
-
))}
|
|
2691
|
-
</Picker>
|
|
2692
|
-
</View>
|
|
2693
|
-
</View>
|
|
2694
|
-
</View>
|
|
2695
|
-
)}
|
|
2696
|
-
|
|
2697
|
-
{shouldShowRemoteCommands && (
|
|
2698
|
-
<View style={styles.section}>
|
|
2699
|
-
<Text style={styles.sectionTitle}>
|
|
2700
|
-
<Icon name="refresh-cw" size={13} /> {' '}Comandos Remotos
|
|
2701
|
-
</Text>
|
|
2702
|
-
|
|
2703
|
-
<View style={styles.configCard}>
|
|
2704
|
-
<View style={styles.sectionTitleRow}>
|
|
2705
|
-
<Text style={styles.configTitle}>Catálogo do PDV</Text>
|
|
2706
|
-
{renderHelpButton(
|
|
2707
|
-
'Catálogo do PDV',
|
|
2708
|
-
'Limpa o cache local de produtos e categorias deste device. O recarregamento acontece no próximo uso do PDV.',
|
|
2709
|
-
)}
|
|
2710
|
-
</View>
|
|
2711
|
-
|
|
2712
|
-
<TouchableOpacity
|
|
2713
|
-
style={[
|
|
2714
|
-
styles.configButton,
|
|
2715
|
-
{
|
|
2716
|
-
backgroundColor: themeColors.buttonBackground,
|
|
2717
|
-
borderColor: themeColors.buttonBackground,
|
|
2718
|
-
},
|
|
2719
|
-
sendingCatalogRefresh && {opacity: 0.6},
|
|
2720
|
-
]}
|
|
2721
|
-
activeOpacity={0.85}
|
|
2722
|
-
disabled={sendingCatalogRefresh}
|
|
2723
|
-
onPress={sendCatalogRefreshCommand}>
|
|
2724
|
-
<Icon name="trash-2" size={16} color={themeColors.buttonIcon} />
|
|
2725
|
-
<Text
|
|
2726
|
-
style={[
|
|
2727
|
-
styles.configButtonText,
|
|
2728
|
-
{color: themeColors.buttonText},
|
|
2729
|
-
]}>
|
|
2730
|
-
{sendingCatalogRefresh ? 'Limpando cache...' : 'Limpar cache de produtos'}
|
|
2731
|
-
</Text>
|
|
2732
|
-
</TouchableOpacity>
|
|
2733
|
-
</View>
|
|
2734
|
-
</View>
|
|
2735
|
-
)}
|
|
2736
|
-
|
|
2737
|
-
{showPdvPaymentTypesTab && (
|
|
2738
|
-
<View style={styles.section}>
|
|
2739
|
-
<View style={styles.sectionHeaderRow}>
|
|
2740
|
-
<Text style={styles.sectionTitle}>
|
|
2741
|
-
<Icon name="credit-card" size={13} /> {' '}Pagamentos do device
|
|
2742
|
-
</Text>
|
|
2743
|
-
{renderHelpButton(
|
|
2744
|
-
'Pagamentos do device',
|
|
2745
|
-
'Selecione os meios de pagamento que este device pode exibir e usar nas opções de pagamento. Os wallets entram só para organizar a lista.',
|
|
2746
|
-
)}
|
|
2747
|
-
</View>
|
|
2748
|
-
<PaymentTypesByWalletTab
|
|
2749
|
-
currentCompanyId={currentCompany?.id}
|
|
2750
|
-
configs={configs}
|
|
2751
|
-
disableSelection={savingPaymentTypes}
|
|
2752
|
-
isSaving={savingPaymentTypes}
|
|
2753
|
-
onPersistSelectedPaymentTypeIds={savePaymentTypeConfigs}
|
|
2754
|
-
/>
|
|
2755
|
-
</View>
|
|
2756
|
-
)}
|
|
2757
|
-
|
|
2758
|
-
{showPdvMovementTab && (
|
|
2759
|
-
<View style={styles.section}>
|
|
2760
|
-
<View style={styles.sectionHeaderRow}>
|
|
2761
|
-
<Text style={styles.sectionTitle}>
|
|
2762
|
-
<Icon name="shield" size={13} /> {' '}
|
|
2763
|
-
{global.t?.t('manager', 'title', 'pdvMovement') || 'PDV Movement'}
|
|
2764
|
-
</Text>
|
|
2765
|
-
<TouchableOpacity
|
|
2766
|
-
style={[
|
|
2767
|
-
styles.toggleBtn,
|
|
2768
|
-
{backgroundColor: isOpen ? hex.danger : hex.success},
|
|
2769
|
-
actionLoading && {opacity: 0.6},
|
|
2770
|
-
]}
|
|
2771
|
-
onPress={handleToggle}
|
|
2772
|
-
disabled={actionLoading || loadingConfigData}
|
|
2773
|
-
activeOpacity={0.85}>
|
|
2774
|
-
<Icon
|
|
2775
|
-
name={isOpen ? 'lock' : 'unlock'}
|
|
2776
|
-
size={13}
|
|
2777
|
-
color="#fff"
|
|
2778
|
-
/>
|
|
2779
|
-
<Text style={styles.toggleBtnText}>
|
|
2780
|
-
{actionLoading
|
|
2781
|
-
? isOpen
|
|
2782
|
-
? 'Fechando...'
|
|
2783
|
-
: 'Abrindo...'
|
|
2784
|
-
: isOpen
|
|
2785
|
-
? global.t?.t('orders', 'button', 'closeCashRegister') || 'Close'
|
|
2786
|
-
: global.t?.t('orders', 'button', 'openCashRegister') || 'Open'}
|
|
2787
|
-
</Text>
|
|
2788
|
-
</TouchableOpacity>
|
|
2789
|
-
</View>
|
|
2790
|
-
</View>
|
|
2791
|
-
)}
|
|
2792
|
-
|
|
2793
|
-
{showPdvMovementTab && wallets.length > 0 && (
|
|
2794
|
-
<View style={styles.section}>
|
|
2795
|
-
<Text style={styles.sectionTitle}>
|
|
2796
|
-
<Icon name="credit-card" size={13} /> {' '}Recebimentos por Forma de Pagamento
|
|
2797
|
-
</Text>
|
|
2798
|
-
{wallets.map((wallet, wi) => (
|
|
2799
|
-
<View key={wi} style={styles.walletCard}>
|
|
2800
|
-
<View style={styles.walletHeader}>
|
|
2801
|
-
<Icon name="briefcase" size={13} color="#64748B" />
|
|
2802
|
-
<Text style={styles.walletName}>{wallet.wallet || 'Carteira'}</Text>
|
|
2803
|
-
<Text style={[styles.walletTotal, { color: brandColors.primary }]}>
|
|
2804
|
-
{Formatter.formatMoney(wallet.total)}
|
|
2805
|
-
</Text>
|
|
2806
|
-
</View>
|
|
2807
|
-
{wallet.payments.map((pt, pi) => (
|
|
2808
|
-
<View key={pi} style={styles.paymentRow}>
|
|
2809
|
-
<View style={[styles.paymentIconBox, { backgroundColor: withOpacity(hex.info, 0.1) }]}>
|
|
2810
|
-
<Icon name={paymentIcon(pt.payment)} size={11} color={hex.info} />
|
|
2811
|
-
</View>
|
|
2812
|
-
<Text style={styles.paymentName}>{pt.payment || '-'}</Text>
|
|
2813
|
-
<Text style={styles.paymentValue}>
|
|
2814
|
-
{Formatter.formatMoney(pt.inflow)}
|
|
2815
|
-
</Text>
|
|
2816
|
-
</View>
|
|
2817
|
-
))}
|
|
2818
|
-
</View>
|
|
2819
|
-
))}
|
|
2820
|
-
</View>
|
|
2821
|
-
)}
|
|
2822
|
-
|
|
2823
|
-
{showPdvMovementTab && (
|
|
2824
|
-
<View style={styles.section}>
|
|
2825
|
-
<Text style={styles.sectionTitle}>
|
|
2826
|
-
<Icon name="shopping-bag" size={13} /> {' '}Produtos Vendidos
|
|
2827
|
-
</Text>
|
|
2828
|
-
|
|
2829
|
-
<View style={styles.searchRow}>
|
|
2830
|
-
<Icon name="search" size={14} color="#94A3B8" />
|
|
2831
|
-
<TextInput
|
|
2832
|
-
style={styles.searchInput}
|
|
2833
|
-
value={search}
|
|
2834
|
-
onChangeText={setSearch}
|
|
2835
|
-
placeholder="Buscar produto ou SKU..."
|
|
2836
|
-
placeholderTextColor="#94A3B8"
|
|
2837
|
-
/>
|
|
2838
|
-
{!!search && (
|
|
2839
|
-
<TouchableOpacity onPress={() => setSearch('')}>
|
|
2840
|
-
<Icon name="x" size={14} color="#94A3B8" />
|
|
2841
|
-
</TouchableOpacity>
|
|
2842
|
-
)}
|
|
2843
|
-
</View>
|
|
2844
|
-
|
|
2845
|
-
{filteredProducts.length > 0 ? (
|
|
2846
|
-
<View style={styles.tableContainer}>
|
|
2847
|
-
<View style={styles.tableHeader}>
|
|
2848
|
-
<Text style={[styles.tableHead, { flex: 0.5 }]}>Qtd</Text>
|
|
2849
|
-
<Text style={[styles.tableHead, { flex: 3 }]}>Produto</Text>
|
|
2850
|
-
<Text style={[styles.tableHead, { flex: 1.2, textAlign: 'right' }]}>Unit.</Text>
|
|
2851
|
-
<Text style={[styles.tableHead, { flex: 1.3, textAlign: 'right' }]}>Total</Text>
|
|
2852
|
-
</View>
|
|
2853
|
-
<FlatList
|
|
2854
|
-
data={filteredProducts}
|
|
2855
|
-
keyExtractor={(item, i) => `${item.product_sku || i}`}
|
|
2856
|
-
renderItem={renderProduct}
|
|
2857
|
-
scrollEnabled={false}
|
|
2858
|
-
/>
|
|
2859
|
-
<View style={styles.tableFooter}>
|
|
2860
|
-
<Text style={styles.tableFooterLabel}>Total em produtos</Text>
|
|
2861
|
-
<Text style={[styles.tableFooterValue, { color: brandColors.primary }]}>
|
|
2862
|
-
{Formatter.formatMoney(productTotal)}
|
|
2863
|
-
</Text>
|
|
2864
|
-
</View>
|
|
2865
|
-
</View>
|
|
2866
|
-
) : (
|
|
2867
|
-
<View style={styles.emptyBox}>
|
|
2868
|
-
<Icon name="inbox" size={24} color="#CBD5E1" style={inlineStyle_1301_61} />
|
|
2869
|
-
<Text style={styles.emptyText}>
|
|
2870
|
-
{search ? 'Nenhum produto encontrado para esta busca' : 'Nenhum produto registrado neste equipamento'}
|
|
2871
|
-
</Text>
|
|
2872
|
-
</View>
|
|
2873
|
-
)}
|
|
2874
|
-
</View>
|
|
2875
|
-
)}
|
|
2876
|
-
|
|
2877
|
-
</ScrollView>
|
|
2878
|
-
</SafeAreaView>
|
|
2879
|
-
);
|
|
2880
|
-
};
|
|
2881
|
-
|
|
2882
|
-
export default DeviceDetailPage;
|
|
1
|
+
/**
|
|
2
|
+
* Device detail (Manager) — thin shell.
|
|
3
|
+
* Implementation: ./Devices/detail/DeviceDetailScreen.js (+ helpers).
|
|
4
|
+
* Refs: app-community#382
|
|
5
|
+
*/
|
|
6
|
+
export {default} from './Devices/detail/DeviceDetailScreen';
|