@controleonline/ui-common 1.2.70 → 1.2.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/actions/workers/manager/action.yml +147 -0
- package/.github/actions/workers/qa/action.yml +44 -0
- package/.github/actions/workers/security/action.yml +44 -0
- package/.github/actions/workers/technical-documenter/action.yml +51 -0
- package/.github/workflows/manager-worker.yml +168 -0
- package/.github/workflows/publish-npm.yml +45 -0
- package/.gitmodules +3 -0
- package/AGENTS.md +6 -0
- package/README.md +14 -0
- package/package.json +32 -28
- package/src/api/fetch.js +1 -1
- package/src/api/index.js +328 -58
- package/src/react/components/AddImportModal.js +95 -111
- package/src/react/components/AnimatedModal.js +171 -0
- package/src/react/components/AnimatedModal.styles.js +21 -0
- package/src/react/components/AppTypeSwitcher.js +164 -0
- package/src/react/components/AppTypeSwitcher.styles.js +109 -0
- package/src/react/components/BackgroundRuntimeBridge.js +5 -4
- package/src/react/components/BottomNavigationBar.config.js +211 -231
- package/src/react/components/BottomNavigationBar.js +86 -31
- package/src/react/components/BottomNavigationBar.styles.js +118 -110
- package/src/react/components/CategoryForm.js +52 -35
- package/src/react/components/DefaultProvider.native.js +194 -156
- package/src/react/components/DefaultProvider.web.js +188 -112
- package/src/react/components/DeliveryPushBridge.native.js +2 -2
- package/src/react/components/DeviceAlertSoundService.js +3 -3
- package/src/react/components/KioskModeBridge.js +2 -2
- package/src/react/components/LauncherModeBridge.js +2 -2
- package/src/react/components/ManagerPushBridge.native.js +2 -2
- package/src/react/components/NetworkPrinterPreviewModal.js +249 -0
- package/src/react/components/NetworkPrinterPreviewModal.styles.js +159 -0
- package/src/react/components/RemoteCheckoutService.js +28 -20
- package/src/react/components/RuntimeBottomNavigationBar.js +146 -119
- package/src/react/components/RuntimeInfoFooter.js +137 -45
- package/src/react/components/RuntimeInfoFooter.styles.js +3 -0
- package/src/react/components/StateStore.js +258 -0
- package/src/react/components/UnifiedPaymentBar.js +7 -4
- package/src/react/components/UserAvatar.js +160 -0
- package/src/react/components/WebsocketListener.native.js +11 -11
- package/src/react/components/integrations/IntegrationHero/index.js +48 -0
- package/src/react/components/integrations/IntegrationHero/styles.js +57 -0
- package/src/react/components/integrations/IntegrationTabs/index.js +89 -0
- package/src/react/components/integrations/IntegrationTabs/styles.js +44 -0
- package/src/react/config/deviceConfigBootstrap.js +71 -30
- package/src/react/css/orders.js +72 -0
- package/src/react/pages/Connections.js +229 -0
- package/src/react/pages/Connections.styles.js +222 -0
- package/src/react/pages/DeviceDetailPage.js +2814 -0
- package/src/react/pages/DeviceDetailPage.styles.js +308 -0
- package/src/react/pages/Devices/currentDevice.js +194 -0
- package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +257 -0
- package/src/react/pages/Devices/deviceTypes/all.js +23 -0
- package/src/react/pages/Devices/deviceTypes/device.js +25 -0
- package/src/react/pages/Devices/deviceTypes/deviceListHelpers.js +178 -0
- package/src/react/pages/Devices/deviceTypes/display.js +26 -0
- package/src/react/pages/Devices/deviceTypes/index.js +145 -0
- package/src/react/pages/Devices/deviceTypes/ipCamera.js +35 -0
- package/src/react/pages/Devices/deviceTypes/pdv.js +88 -0
- package/src/react/pages/Devices/deviceTypes/printer.js +37 -0
- package/src/react/pages/Devices/deviceTypes/shared.js +453 -0
- package/src/react/pages/Devices/deviceTypes/useDeviceNetworkConnectivity.js +145 -0
- package/src/react/pages/Devices.js +183 -0
- package/src/react/pages/Devices.styles.js +353 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99ProductCard.js +1 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +181 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -0
- package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -0
- package/src/react/pages/Food99IntegrationPage/index.js +1530 -0
- package/src/react/pages/Food99IntegrationPage/styles.js +792 -0
- package/src/react/pages/Food99IntegrationPage/utils.js +155 -0
- package/src/react/pages/Food99IntegrationPage.js +1 -0
- package/src/react/pages/Food99IntegrationPage.styles.js +1 -0
- package/src/react/pages/GenericLogPage.js +42 -167
- package/src/react/pages/IFoodIntegrationPage/components/IFoodCatalogTab.js +8 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +420 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +103 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodProductCard.js +1 -0
- package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -0
- package/src/react/pages/IFoodIntegrationPage/index.js +1298 -0
- package/src/react/pages/IFoodIntegrationPage/styles.js +764 -0
- package/src/react/pages/IFoodIntegrationPage/utils.js +91 -0
- package/src/react/pages/IFoodIntegrationPage.js +1 -0
- package/src/react/pages/IFoodIntegrationPage.styles.js +1 -0
- package/src/react/pages/Imports.js +214 -166
- package/src/react/pages/IntegrationConfigPage.js +744 -0
- package/src/react/pages/IntegrationConfigPage.styles.js +269 -0
- package/src/react/pages/Integrations.js +299 -0
- package/src/react/pages/Integrations.styles.js +130 -0
- package/src/react/pages/ManagerOrderNotificationsPage.js +642 -0
- package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -0
- package/src/react/pages/MarketplaceIntegrationPage/components/RemoteMarketplaceMenuTab.js +335 -0
- package/src/react/pages/MarketplaceIntegrationPage/index.js +60 -0
- package/src/react/pages/MarketplaceIntegrationPage/utils.js +137 -0
- package/src/react/pages/MercadoLivreIntegrationPage.js +538 -0
- package/src/react/pages/PrinterDeviceDetailPage.js +1916 -0
- package/src/react/pages/PrinterDeviceDetailPage.styles.js +223 -0
- package/src/react/pages/PrinterDeviceFormPage.js +521 -0
- package/src/react/pages/PrinterDeviceFormPage.styles.js +159 -0
- package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +484 -454
- package/src/react/pages/SettingsPage/index.js +1266 -1167
- package/src/react/pages/WhatsAppConnectionPage.js +459 -0
- package/src/react/pages/WhatsAppConnectionPage.styles.js +284 -0
- package/src/react/pages/integrationsCatalog.js +399 -0
- package/src/react/print/providers/local.js +1 -1
- package/src/react/router/publicRoutes.js +25 -0
- package/src/react/services/Cielo/Checkout.js +39 -0
- package/src/react/services/Cielo/Cielo.js +193 -0
- package/src/react/services/Cielo/Print.js +7 -0
- package/src/react/services/InfinitePay/Checkout.js +33 -0
- package/src/react/services/InfinitePay/InfinitePay.js +24 -0
- package/src/react/{utils → services}/paymentGatewayExecution.js +91 -91
- package/src/react/styles/global.js +115 -0
- package/src/react/utils/categoryContexts.js +46 -0
- package/src/react/utils/entityDisplay.js +222 -217
- package/src/react/utils/fileUrl.js +201 -16
- package/src/react/utils/integrationPage.js +16 -0
- package/src/react/utils/menuNavigation.js +31 -0
- package/src/react/utils/orderIdentity.js +277 -0
- package/src/react/utils/remotePayment.js +115 -61
- package/src/react/utils/runtimeFooter.js +40 -22
- package/src/react/utils/runtimeLanguage.js +50 -9
- package/src/react/utils/runtimeMenu.js +190 -98
- package/src/react/utils/runtimeZoom.js +43 -0
- package/src/react/utils/shopConfig.js +72 -34
- package/src/react/utils/shopFranchises.js +182 -23
- package/src/react/utils/socketRuntimePipeline.js +14 -14
- package/src/react/utils/storeColumns.js +23 -4
- package/src/react/utils/userAvatar.js +104 -0
- package/src/store/categories/index.js +48 -20
- package/src/store/configs/index.js +2 -2
- package/src/store/device_config/index.js +62 -21
- package/src/store/entity_log/index.js +22 -1
- package/src/store/imports/customActions.js +51 -0
- package/src/store/imports/index.js +89 -88
- package/src/store/status/index.js +11 -11
- package/src/store/themes/index.js +22 -0
- package/src/store/timezones/index.js +3 -1
- package/src/tests/browser/manager/connections.spec.js +143 -0
- package/src/tests/browser/manager/devices-current.spec.js +343 -0
- package/src/tests/browser/manager/mercado-livre-integration.spec.js +268 -0
- package/src/tests/react/api/deviceHeaders.test.js +114 -0
- package/src/tests/react/api/loadSmokeIndex.test.js +75 -0
- package/src/tests/react/components/AddImportModal.test.js +166 -0
- package/src/tests/react/components/BottomNavigationBar.config.test.js +20 -0
- package/src/tests/react/components/UserAvatar.test.js +52 -0
- package/src/tests/react/config/deviceConfigBootstrap.test.js +47 -0
- package/src/tests/react/pages/DevicePickerStyles.test.js +47 -0
- package/src/tests/react/pages/Devices/deviceListHelpers.test.js +39 -0
- package/src/tests/react/pages/DevicesCurrentDevice.test.js +198 -0
- package/src/tests/react/pages/connectionsHelpers.test.js +34 -0
- package/src/tests/react/pages/mercadoLivreIntegrationPageContract.test.mjs +16 -0
- package/src/tests/react/print/localPrintProvider.test.js +1 -1
- package/src/tests/react/services/Cielo.test.js +190 -0
- package/src/tests/react/store/categoriesOrdering.test.js +26 -0
- package/src/tests/react/utils/appDomain.test.js +62 -0
- package/src/tests/react/utils/entityDisplay.test.js +2 -2
- package/src/tests/react/utils/fileUrl.test.js +62 -0
- package/src/tests/react/utils/formatter.test.mjs +33 -0
- package/src/tests/react/utils/importStatus.test.js +2 -2
- package/src/tests/react/utils/orderIdentity.test.js +139 -0
- package/src/tests/react/utils/remotePayment.test.js +62 -0
- package/src/tests/react/utils/runtimeFooter.test.js +32 -9
- package/src/tests/react/utils/runtimeLanguage.test.js +80 -10
- package/src/tests/react/utils/runtimeMenu.test.js +195 -111
- package/src/tests/react/utils/runtimeZoom.test.js +38 -0
- package/src/tests/react/utils/shopConfig.test.js +75 -0
- package/src/tests/react/utils/shopFranchises.test.js +122 -12
- package/src/tests/react/utils/translate.discovery.test.mjs +170 -0
- package/src/tests/react/utils/translate.test.helpers.mjs +152 -0
- package/src/tests/react/utils/translate.test.mjs +252 -396
- package/src/tests/react/utils/userAvatar.test.js +63 -0
- package/src/utils/appDomain.js +15 -4
- package/src/utils/formatter.js +122 -16
- package/src/utils/integrationConfigs.js +1 -0
- package/src/utils/translate.js +277 -398
- package/src/utils/translateDiscovery.js +96 -0
- package/src/utils/translateNormalize.js +33 -0
- package/src/utils/translatePending.js +92 -0
- package/src/utils/translateStorage.js +142 -0
- package/.github/agents/developer.agent.md +0 -30
- package/.github/agents/devops.agent.md +0 -30
- package/.github/agents/qa.agent.md +0 -30
- package/.github/agents/security.agent.md +0 -30
- package/.github/workflows/npmjs.yml +0 -35
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import React, {useEffect, useMemo, useState} from 'react';
|
|
2
|
-
import {useNavigationState} from '@react-navigation/native';
|
|
3
|
-
import {useStore} from '@store';
|
|
4
|
-
import {api} from '@controleonline/ui-common/src/api';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {resolveThemePalette} from '@controleonline/../../src/styles/branding';
|
|
8
|
-
import BottomNavigationBar from '@controleonline/ui-common/src/react/components/BottomNavigationBar';
|
|
1
|
+
import React, {useEffect, useMemo, useState} from 'react';
|
|
2
|
+
import {useNavigationState} from '@react-navigation/native';
|
|
3
|
+
import {useStore} from '@store';
|
|
4
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
5
|
+
import {app_type} from '@appType';
|
|
6
|
+
import BottomNavigationBar from '@controleonline/ui-common/src/react/components/BottomNavigationBar';
|
|
9
7
|
import {
|
|
10
8
|
getBottomNavigationPreset,
|
|
9
|
+
resolveBottomNavigationItems,
|
|
11
10
|
resolveBottomNavigationRoute,
|
|
12
11
|
} from '@controleonline/ui-common/src/react/components/BottomNavigationBar.config';
|
|
13
|
-
import {
|
|
14
|
-
filterRuntimeMenuModulesByType,
|
|
15
|
-
normalizeAppType,
|
|
16
|
-
normalizeRuntimeMenuResponse,
|
|
17
|
-
resolveRuntimeMenuLabel,
|
|
18
|
-
} from '@controleonline/ui-common/src/react/utils/runtimeMenu';
|
|
19
|
-
|
|
20
|
-
const sortRuntimeMenuItems = (left, right) => {
|
|
21
|
-
const orderDiff = Number(left?.sortOrder || 0) - Number(right?.sortOrder || 0);
|
|
22
|
-
if (orderDiff !== 0) return orderDiff;
|
|
23
|
-
return String(left?.label || '').localeCompare(String(right?.label || ''));
|
|
24
|
-
};
|
|
25
|
-
|
|
12
|
+
import {
|
|
13
|
+
filterRuntimeMenuModulesByType,
|
|
14
|
+
normalizeAppType,
|
|
15
|
+
normalizeRuntimeMenuResponse,
|
|
16
|
+
resolveRuntimeMenuLabel,
|
|
17
|
+
} from '@controleonline/ui-common/src/react/utils/runtimeMenu';
|
|
18
|
+
|
|
19
|
+
const sortRuntimeMenuItems = (left, right) => {
|
|
20
|
+
const orderDiff = Number(left?.sortOrder || 0) - Number(right?.sortOrder || 0);
|
|
21
|
+
if (orderDiff !== 0) return orderDiff;
|
|
22
|
+
return String(left?.label || '').localeCompare(String(right?.label || ''));
|
|
23
|
+
};
|
|
24
|
+
|
|
26
25
|
const RuntimeBottomNavigationBar = ({
|
|
27
26
|
activeRouteName: activeRouteNameProp,
|
|
28
27
|
colors: colorsOverride,
|
|
@@ -31,14 +30,15 @@ const RuntimeBottomNavigationBar = ({
|
|
|
31
30
|
itemMapper,
|
|
32
31
|
menuType = 'toolbar',
|
|
33
32
|
navigation,
|
|
34
|
-
presetKey,
|
|
35
|
-
routeAliases: routeAliasesProp,
|
|
36
|
-
testID = 'bottom-navigation',
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
presetKey,
|
|
34
|
+
routeAliases: routeAliasesProp,
|
|
35
|
+
testID = 'bottom-navigation',
|
|
36
|
+
useModernWebChromeProps = false,
|
|
37
|
+
}) => {
|
|
38
|
+
const state = useNavigationState(current => current);
|
|
39
|
+
const activeRouteName =
|
|
40
|
+
activeRouteNameProp || state?.routes?.[state.index]?.name || 'HomePage';
|
|
41
|
+
|
|
42
42
|
const themeStore = useStore('theme');
|
|
43
43
|
const peopleStore = useStore('people');
|
|
44
44
|
const themeGetters = themeStore?.getters || {};
|
|
@@ -48,7 +48,7 @@ const RuntimeBottomNavigationBar = ({
|
|
|
48
48
|
const [runtimeMenus, setRuntimeMenus] = useState([]);
|
|
49
49
|
const preset = presetKey ? getBottomNavigationPreset(presetKey) : null;
|
|
50
50
|
const routeAliases = routeAliasesProp || preset?.routeAliases || {};
|
|
51
|
-
const appType = normalizeAppType(
|
|
51
|
+
const appType = normalizeAppType(app_type);
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
54
|
if (!currentCompany?.id || !menuType) {
|
|
@@ -56,96 +56,123 @@ const RuntimeBottomNavigationBar = ({
|
|
|
56
56
|
return undefined;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (preset) {
|
|
60
|
+
const presetMenus = Array.isArray(preset?.items)
|
|
61
|
+
? resolveBottomNavigationItems(
|
|
62
|
+
preset.items.map((item, index) => ({
|
|
63
|
+
...item,
|
|
64
|
+
menuType,
|
|
65
|
+
sortOrder: Number(item?.sortOrder || (index + 1) * 10),
|
|
66
|
+
})),
|
|
67
|
+
global.t?.t,
|
|
68
|
+
)
|
|
69
|
+
: [];
|
|
61
70
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
setRuntimeMenus([
|
|
72
|
+
{
|
|
73
|
+
id: presetKey || 'runtime-bottom-navigation',
|
|
74
|
+
label: preset?.label || presetKey || '',
|
|
75
|
+
icon: preset?.icon || '',
|
|
76
|
+
menus: presetMenus,
|
|
68
77
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!cancelled) {
|
|
72
|
-
setRuntimeMenus(
|
|
73
|
-
normalizeRuntimeMenuResponse(result, {
|
|
74
|
-
appType,
|
|
75
|
-
allowFallback: false,
|
|
76
|
-
}),
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
.catch(() => {
|
|
81
|
-
if (!cancelled) {
|
|
82
|
-
setRuntimeMenus([]);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return () => {
|
|
87
|
-
cancelled = true;
|
|
88
|
-
};
|
|
89
|
-
}, [appType, currentCompany?.id, menuType]);
|
|
90
|
-
|
|
91
|
-
const colors = useMemo(() => {
|
|
92
|
-
if (colorsOverride) {
|
|
93
|
-
return colorsOverride;
|
|
78
|
+
]);
|
|
79
|
+
return undefined;
|
|
94
80
|
}
|
|
95
81
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
82
|
+
let cancelled = false;
|
|
83
|
+
setRuntimeMenus([]);
|
|
84
|
+
|
|
85
|
+
api
|
|
86
|
+
.fetch('menus-people', {
|
|
87
|
+
params: {
|
|
88
|
+
myCompany: currentCompany.id,
|
|
89
|
+
appType,
|
|
90
|
+
menuType,
|
|
91
|
+
},
|
|
92
|
+
})
|
|
93
|
+
.then(result => {
|
|
94
|
+
if (!cancelled) {
|
|
95
|
+
setRuntimeMenus(
|
|
96
|
+
normalizeRuntimeMenuResponse(result, {
|
|
97
|
+
appType,
|
|
98
|
+
allowFallback: false,
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.catch(() => {
|
|
104
|
+
if (!cancelled) {
|
|
105
|
+
setRuntimeMenus([]);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return () => {
|
|
110
|
+
cancelled = true;
|
|
111
|
+
};
|
|
112
|
+
}, [
|
|
113
|
+
appType,
|
|
114
|
+
currentCompany?.id,
|
|
115
|
+
menuType,
|
|
116
|
+
preset,
|
|
117
|
+
presetKey,
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
const colors = useMemo(() => {
|
|
121
|
+
if (colorsOverride) {
|
|
122
|
+
return colorsOverride;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
...themeColors,
|
|
127
|
+
...(currentCompany?.theme?.colors || {}),
|
|
128
|
+
};
|
|
129
|
+
}, [colorsOverride, currentCompany?.theme?.colors, themeColors]);
|
|
130
|
+
|
|
131
|
+
const navItems = useMemo(() => {
|
|
132
|
+
const mapper = typeof itemMapper === 'function' ? itemMapper : item => item;
|
|
133
|
+
const filter = typeof itemFilter === 'function' ? itemFilter : () => true;
|
|
134
|
+
|
|
135
|
+
return filterRuntimeMenuModulesByType(runtimeMenus, menuType)
|
|
136
|
+
.flatMap(module => (Array.isArray(module?.menus) ? module.menus : []))
|
|
137
|
+
.map(item => mapper({...item}))
|
|
138
|
+
.filter(Boolean)
|
|
139
|
+
.filter(filter)
|
|
140
|
+
.sort(sortRuntimeMenuItems)
|
|
141
|
+
.map(item => ({
|
|
142
|
+
route: item.route,
|
|
143
|
+
icon: item.icon || 'circle',
|
|
144
|
+
label: resolveRuntimeMenuLabel(item, global.t?.t),
|
|
145
|
+
routeParams: item.routeParams,
|
|
146
|
+
menuType: item.menuType,
|
|
147
|
+
}))
|
|
148
|
+
.filter(item => Boolean(item.route));
|
|
149
|
+
}, [itemFilter, itemMapper, menuType, runtimeMenus]);
|
|
150
|
+
|
|
151
|
+
const resolvedActiveRoute = resolveBottomNavigationRoute(
|
|
152
|
+
routeAliases,
|
|
153
|
+
activeRouteName,
|
|
154
|
+
);
|
|
155
|
+
const knownRoute = navItems.some(item => item.route === resolvedActiveRoute);
|
|
156
|
+
const effectiveActiveRoute = knownRoute
|
|
157
|
+
? resolvedActiveRoute
|
|
158
|
+
: navItems[0]?.route || activeRouteName;
|
|
159
|
+
|
|
160
|
+
const isDisabled =
|
|
161
|
+
typeof disabledOverride === 'boolean'
|
|
162
|
+
? disabledOverride
|
|
163
|
+
: !currentCompany || Object.keys(currentCompany).length === 0;
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<BottomNavigationBar
|
|
167
|
+
activeRouteName={effectiveActiveRoute}
|
|
168
|
+
colors={colors}
|
|
169
|
+
disabled={isDisabled}
|
|
170
|
+
items={navItems}
|
|
171
|
+
navigation={navigation}
|
|
172
|
+
testID={testID}
|
|
173
|
+
useModernWebChromeProps={useModernWebChromeProps}
|
|
174
|
+
/>
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default RuntimeBottomNavigationBar;
|
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
import React, {useEffect, useMemo, useState} from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, {useEffect, useMemo, useRef, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
Animated,
|
|
5
|
+
Text,
|
|
6
|
+
View,
|
|
7
|
+
useWindowDimensions,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
import {useStore, useStores} from '@store';
|
|
4
10
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
5
|
-
import {colors as runtimeColors} from '@controleonline/../../src/styles/colors';
|
|
6
11
|
import {
|
|
7
12
|
DEVICE_RUNTIME_DEBUG_INFO_ENABLED_KEY,
|
|
8
13
|
isTruthyValue,
|
|
9
14
|
parseConfigsObject,
|
|
10
15
|
} from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
|
|
11
16
|
import {
|
|
12
|
-
getRuntimeFooterDebugInfo,
|
|
13
|
-
getRuntimeFooterPrimaryText,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
17
|
+
getRuntimeFooterDebugInfo,
|
|
18
|
+
getRuntimeFooterPrimaryText,
|
|
19
|
+
getRuntimeFooterRotationEntries,
|
|
20
|
+
getRuntimeFooterText,
|
|
21
|
+
getRuntimeFooterTextLines,
|
|
22
|
+
} from '@controleonline/ui-common/src/react/utils/runtimeFooter';
|
|
23
|
+
import styles from './RuntimeInfoFooter.styles';
|
|
24
|
+
|
|
25
|
+
const ROTATION_INTERVAL_MS = 6000;
|
|
26
|
+
const FADE_DURATION_MS = 260;
|
|
27
|
+
const COMPACT_BREAKPOINT = 720;
|
|
28
|
+
const MAX_INLINE_TEXT_LENGTH = 84;
|
|
21
29
|
|
|
22
|
-
const RuntimeInfoFooter = ({
|
|
30
|
+
const RuntimeInfoFooter = ({
|
|
31
|
+
appVersion,
|
|
32
|
+
defaultCompany,
|
|
33
|
+
device,
|
|
34
|
+
colors,
|
|
35
|
+
useModernWebChromeProps = false,
|
|
36
|
+
}) => {
|
|
23
37
|
const {width} = useWindowDimensions();
|
|
24
38
|
const insets = useSafeAreaInsets();
|
|
25
39
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
40
|
+
const fadeOpacity = useRef(new Animated.Value(1)).current;
|
|
26
41
|
const allStores = useStores(state => state);
|
|
27
42
|
const deviceConfigStore = useStore('device_config');
|
|
28
43
|
const runtimeDebugStore = useStore('runtime_debug');
|
|
@@ -48,10 +63,14 @@ const RuntimeInfoFooter = ({appVersion, defaultCompany, device, colors}) => {
|
|
|
48
63
|
}),
|
|
49
64
|
[appVersion, device, deviceConfigItem, footerDebugInfo.primaryText],
|
|
50
65
|
);
|
|
51
|
-
const companyFooterText = useMemo(
|
|
52
|
-
() => getRuntimeFooterText(defaultCompany),
|
|
53
|
-
[defaultCompany?.configs],
|
|
54
|
-
);
|
|
66
|
+
const companyFooterText = useMemo(
|
|
67
|
+
() => getRuntimeFooterText(defaultCompany),
|
|
68
|
+
[defaultCompany?.configs],
|
|
69
|
+
);
|
|
70
|
+
const footerTextLines = useMemo(
|
|
71
|
+
() => getRuntimeFooterTextLines(companyFooterText),
|
|
72
|
+
[companyFooterText],
|
|
73
|
+
);
|
|
55
74
|
const deviceConfigs = useMemo(
|
|
56
75
|
() => parseConfigsObject(deviceConfigItem?.configs),
|
|
57
76
|
[deviceConfigItem?.configs],
|
|
@@ -64,15 +83,26 @@ const RuntimeInfoFooter = ({appVersion, defaultCompany, device, colors}) => {
|
|
|
64
83
|
[deviceConfigs],
|
|
65
84
|
);
|
|
66
85
|
|
|
67
|
-
const
|
|
68
|
-
() =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
86
|
+
const rotationEntries = useMemo(
|
|
87
|
+
() =>
|
|
88
|
+
getRuntimeFooterRotationEntries({
|
|
89
|
+
companyFooterText,
|
|
90
|
+
primaryText,
|
|
91
|
+
}),
|
|
92
|
+
[companyFooterText, primaryText],
|
|
93
|
+
);
|
|
94
|
+
const inlineText = useMemo(
|
|
95
|
+
() => [primaryText, ...footerTextLines].filter(Boolean).join(' • '),
|
|
96
|
+
[footerTextLines, primaryText],
|
|
97
|
+
);
|
|
98
|
+
const shouldRotate =
|
|
99
|
+
!showDebugInfo &&
|
|
100
|
+
rotationEntries.length > 1 &&
|
|
101
|
+
(
|
|
102
|
+
footerTextLines.length > 1 ||
|
|
103
|
+
width < COMPACT_BREAKPOINT ||
|
|
104
|
+
inlineText.length > MAX_INLINE_TEXT_LENGTH
|
|
105
|
+
);
|
|
76
106
|
const footerEntries = useMemo(
|
|
77
107
|
() =>
|
|
78
108
|
Object.values(runtimeDebugSummary?.entries || {})
|
|
@@ -110,7 +140,26 @@ const RuntimeInfoFooter = ({appVersion, defaultCompany, device, colors}) => {
|
|
|
110
140
|
() => footerEntries.flatMap(entry => entry?.lines || []),
|
|
111
141
|
[footerEntries],
|
|
112
142
|
);
|
|
113
|
-
const socketIndicatorColor =
|
|
143
|
+
const socketIndicatorColor = useMemo(() => {
|
|
144
|
+
const indicatorTone = String(socketEntry?.indicatorTone || '').trim();
|
|
145
|
+
if (!indicatorTone) {
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (indicatorTone === 'success') {
|
|
150
|
+
return colors?.success;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (indicatorTone === 'warning') {
|
|
154
|
+
return colors?.warning;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (indicatorTone === 'error') {
|
|
158
|
+
return colors?.error;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return undefined;
|
|
162
|
+
}, [colors?.error, colors?.success, colors?.warning, socketEntry?.indicatorTone]);
|
|
114
163
|
const hasStoreLoading = useMemo(
|
|
115
164
|
() =>
|
|
116
165
|
Object.values(allStores || {}).some(
|
|
@@ -123,32 +172,72 @@ const RuntimeInfoFooter = ({appVersion, defaultCompany, device, colors}) => {
|
|
|
123
172
|
const bottomInset = Math.max(Number(insets.bottom) || 0, 16);
|
|
124
173
|
|
|
125
174
|
useEffect(() => {
|
|
126
|
-
if (!shouldRotate ||
|
|
175
|
+
if (!shouldRotate || rotationEntries.length <= 1) {
|
|
127
176
|
setActiveIndex(0);
|
|
177
|
+
fadeOpacity.stopAnimation();
|
|
178
|
+
fadeOpacity.setValue(1);
|
|
128
179
|
return;
|
|
129
180
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
181
|
+
|
|
182
|
+
let timeoutId;
|
|
183
|
+
let cancelled = false;
|
|
184
|
+
|
|
185
|
+
const scheduleTransition = () => {
|
|
186
|
+
timeoutId = setTimeout(() => {
|
|
187
|
+
Animated.timing(fadeOpacity, {
|
|
188
|
+
toValue: 0,
|
|
189
|
+
duration: FADE_DURATION_MS,
|
|
190
|
+
useNativeDriver: true,
|
|
191
|
+
}).start(({finished}) => {
|
|
192
|
+
if (!finished || cancelled) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
setActiveIndex(current => (current + 1) % rotationEntries.length);
|
|
197
|
+
|
|
198
|
+
Animated.timing(fadeOpacity, {
|
|
199
|
+
toValue: 1,
|
|
200
|
+
duration: FADE_DURATION_MS,
|
|
201
|
+
useNativeDriver: true,
|
|
202
|
+
}).start(({finished: fadeInFinished}) => {
|
|
203
|
+
if (fadeInFinished && !cancelled) {
|
|
204
|
+
scheduleTransition();
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}, ROTATION_INTERVAL_MS);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
fadeOpacity.setValue(1);
|
|
212
|
+
scheduleTransition();
|
|
213
|
+
|
|
135
214
|
return () => {
|
|
136
|
-
|
|
215
|
+
cancelled = true;
|
|
216
|
+
if (timeoutId) {
|
|
217
|
+
clearTimeout(timeoutId);
|
|
218
|
+
}
|
|
219
|
+
fadeOpacity.stopAnimation();
|
|
137
220
|
};
|
|
138
|
-
}, [
|
|
221
|
+
}, [fadeOpacity, rotationEntries.length, shouldRotate]);
|
|
139
222
|
|
|
140
|
-
if (
|
|
223
|
+
if (rotationEntries.length === 0 && !showDebugInfo) {
|
|
141
224
|
return null;
|
|
142
225
|
}
|
|
143
|
-
|
|
144
|
-
const displayedText = shouldRotate
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
const
|
|
226
|
+
|
|
227
|
+
const displayedText = shouldRotate
|
|
228
|
+
? rotationEntries[activeIndex]
|
|
229
|
+
: inlineText;
|
|
230
|
+
const backgroundColor = colors?.footerBackground;
|
|
231
|
+
const borderColor = colors?.footerBorder;
|
|
232
|
+
const textColor = colors?.footerText;
|
|
233
|
+
const loadingColor = colors?.footerLink;
|
|
234
|
+
const shellProps = useModernWebChromeProps ? {} : {pointerEvents: 'none'};
|
|
235
|
+
const shellStyle = useModernWebChromeProps
|
|
236
|
+
? [styles.shell, {pointerEvents: 'none'}]
|
|
237
|
+
: styles.shell;
|
|
149
238
|
|
|
150
239
|
return (
|
|
151
|
-
<View
|
|
240
|
+
<View {...shellProps} style={shellStyle}>
|
|
152
241
|
<View
|
|
153
242
|
testID="runtime-info-footer"
|
|
154
243
|
style={[
|
|
@@ -171,18 +260,21 @@ const RuntimeInfoFooter = ({appVersion, defaultCompany, device, colors}) => {
|
|
|
171
260
|
]}
|
|
172
261
|
/>
|
|
173
262
|
</View>
|
|
174
|
-
<Text
|
|
263
|
+
<Animated.Text
|
|
175
264
|
numberOfLines={1}
|
|
176
265
|
ellipsizeMode="tail"
|
|
177
266
|
minimumFontScale={0.85}
|
|
178
267
|
style={[
|
|
179
268
|
styles.primaryText,
|
|
269
|
+
{
|
|
270
|
+
opacity: showDebugInfo ? 1 : fadeOpacity,
|
|
271
|
+
},
|
|
180
272
|
{
|
|
181
273
|
color: textColor,
|
|
182
274
|
},
|
|
183
275
|
]}>
|
|
184
276
|
{showDebugInfo ? inlineText || primaryText || device?.id || '--' : displayedText}
|
|
185
|
-
</Text>
|
|
277
|
+
</Animated.Text>
|
|
186
278
|
<View style={styles.loadingWrap}>
|
|
187
279
|
{hasStoreLoading && (
|
|
188
280
|
<ActivityIndicator color={loadingColor} size="small" />
|
|
@@ -18,15 +18,18 @@ const styles = StyleSheet.create({
|
|
|
18
18
|
flexDirection: 'row',
|
|
19
19
|
alignItems: 'center',
|
|
20
20
|
justifyContent: 'center',
|
|
21
|
+
minHeight: 20,
|
|
21
22
|
},
|
|
22
23
|
statusDotWrap: {
|
|
23
24
|
minWidth: 22,
|
|
25
|
+
minHeight: 20,
|
|
24
26
|
marginRight: 8,
|
|
25
27
|
alignItems: 'center',
|
|
26
28
|
justifyContent: 'center',
|
|
27
29
|
},
|
|
28
30
|
loadingWrap: {
|
|
29
31
|
minWidth: 22,
|
|
32
|
+
minHeight: 20,
|
|
30
33
|
marginLeft: 8,
|
|
31
34
|
alignItems: 'center',
|
|
32
35
|
justifyContent: 'center',
|