@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.
Files changed (188) hide show
  1. package/.github/actions/workers/manager/action.yml +147 -0
  2. package/.github/actions/workers/qa/action.yml +44 -0
  3. package/.github/actions/workers/security/action.yml +44 -0
  4. package/.github/actions/workers/technical-documenter/action.yml +51 -0
  5. package/.github/workflows/manager-worker.yml +168 -0
  6. package/.github/workflows/publish-npm.yml +45 -0
  7. package/.gitmodules +3 -0
  8. package/AGENTS.md +6 -0
  9. package/README.md +14 -0
  10. package/package.json +32 -28
  11. package/src/api/fetch.js +1 -1
  12. package/src/api/index.js +328 -58
  13. package/src/react/components/AddImportModal.js +95 -111
  14. package/src/react/components/AnimatedModal.js +171 -0
  15. package/src/react/components/AnimatedModal.styles.js +21 -0
  16. package/src/react/components/AppTypeSwitcher.js +164 -0
  17. package/src/react/components/AppTypeSwitcher.styles.js +109 -0
  18. package/src/react/components/BackgroundRuntimeBridge.js +5 -4
  19. package/src/react/components/BottomNavigationBar.config.js +211 -231
  20. package/src/react/components/BottomNavigationBar.js +86 -31
  21. package/src/react/components/BottomNavigationBar.styles.js +118 -110
  22. package/src/react/components/CategoryForm.js +52 -35
  23. package/src/react/components/DefaultProvider.native.js +194 -156
  24. package/src/react/components/DefaultProvider.web.js +188 -112
  25. package/src/react/components/DeliveryPushBridge.native.js +2 -2
  26. package/src/react/components/DeviceAlertSoundService.js +3 -3
  27. package/src/react/components/KioskModeBridge.js +2 -2
  28. package/src/react/components/LauncherModeBridge.js +2 -2
  29. package/src/react/components/ManagerPushBridge.native.js +2 -2
  30. package/src/react/components/NetworkPrinterPreviewModal.js +249 -0
  31. package/src/react/components/NetworkPrinterPreviewModal.styles.js +159 -0
  32. package/src/react/components/RemoteCheckoutService.js +28 -20
  33. package/src/react/components/RuntimeBottomNavigationBar.js +146 -119
  34. package/src/react/components/RuntimeInfoFooter.js +137 -45
  35. package/src/react/components/RuntimeInfoFooter.styles.js +3 -0
  36. package/src/react/components/StateStore.js +258 -0
  37. package/src/react/components/UnifiedPaymentBar.js +7 -4
  38. package/src/react/components/UserAvatar.js +160 -0
  39. package/src/react/components/WebsocketListener.native.js +11 -11
  40. package/src/react/components/integrations/IntegrationHero/index.js +48 -0
  41. package/src/react/components/integrations/IntegrationHero/styles.js +57 -0
  42. package/src/react/components/integrations/IntegrationTabs/index.js +89 -0
  43. package/src/react/components/integrations/IntegrationTabs/styles.js +44 -0
  44. package/src/react/config/deviceConfigBootstrap.js +71 -30
  45. package/src/react/css/orders.js +72 -0
  46. package/src/react/pages/Connections.js +229 -0
  47. package/src/react/pages/Connections.styles.js +222 -0
  48. package/src/react/pages/DeviceDetailPage.js +2814 -0
  49. package/src/react/pages/DeviceDetailPage.styles.js +308 -0
  50. package/src/react/pages/Devices/currentDevice.js +194 -0
  51. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +257 -0
  52. package/src/react/pages/Devices/deviceTypes/all.js +23 -0
  53. package/src/react/pages/Devices/deviceTypes/device.js +25 -0
  54. package/src/react/pages/Devices/deviceTypes/deviceListHelpers.js +178 -0
  55. package/src/react/pages/Devices/deviceTypes/display.js +26 -0
  56. package/src/react/pages/Devices/deviceTypes/index.js +145 -0
  57. package/src/react/pages/Devices/deviceTypes/ipCamera.js +35 -0
  58. package/src/react/pages/Devices/deviceTypes/pdv.js +88 -0
  59. package/src/react/pages/Devices/deviceTypes/printer.js +37 -0
  60. package/src/react/pages/Devices/deviceTypes/shared.js +453 -0
  61. package/src/react/pages/Devices/deviceTypes/useDeviceNetworkConnectivity.js +145 -0
  62. package/src/react/pages/Devices.js +183 -0
  63. package/src/react/pages/Devices.styles.js +353 -0
  64. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -0
  65. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -0
  66. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -0
  67. package/src/react/pages/Food99IntegrationPage/components/Food99ProductCard.js +1 -0
  68. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +181 -0
  69. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -0
  70. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -0
  71. package/src/react/pages/Food99IntegrationPage/index.js +1530 -0
  72. package/src/react/pages/Food99IntegrationPage/styles.js +792 -0
  73. package/src/react/pages/Food99IntegrationPage/utils.js +155 -0
  74. package/src/react/pages/Food99IntegrationPage.js +1 -0
  75. package/src/react/pages/Food99IntegrationPage.styles.js +1 -0
  76. package/src/react/pages/GenericLogPage.js +42 -167
  77. package/src/react/pages/IFoodIntegrationPage/components/IFoodCatalogTab.js +8 -0
  78. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +420 -0
  79. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -0
  80. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +103 -0
  81. package/src/react/pages/IFoodIntegrationPage/components/IFoodProductCard.js +1 -0
  82. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -0
  83. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -0
  84. package/src/react/pages/IFoodIntegrationPage/styles.js +764 -0
  85. package/src/react/pages/IFoodIntegrationPage/utils.js +91 -0
  86. package/src/react/pages/IFoodIntegrationPage.js +1 -0
  87. package/src/react/pages/IFoodIntegrationPage.styles.js +1 -0
  88. package/src/react/pages/Imports.js +214 -166
  89. package/src/react/pages/IntegrationConfigPage.js +744 -0
  90. package/src/react/pages/IntegrationConfigPage.styles.js +269 -0
  91. package/src/react/pages/Integrations.js +299 -0
  92. package/src/react/pages/Integrations.styles.js +130 -0
  93. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -0
  94. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -0
  95. package/src/react/pages/MarketplaceIntegrationPage/components/RemoteMarketplaceMenuTab.js +335 -0
  96. package/src/react/pages/MarketplaceIntegrationPage/index.js +60 -0
  97. package/src/react/pages/MarketplaceIntegrationPage/utils.js +137 -0
  98. package/src/react/pages/MercadoLivreIntegrationPage.js +538 -0
  99. package/src/react/pages/PrinterDeviceDetailPage.js +1916 -0
  100. package/src/react/pages/PrinterDeviceDetailPage.styles.js +223 -0
  101. package/src/react/pages/PrinterDeviceFormPage.js +521 -0
  102. package/src/react/pages/PrinterDeviceFormPage.styles.js +159 -0
  103. package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +484 -454
  104. package/src/react/pages/SettingsPage/index.js +1266 -1167
  105. package/src/react/pages/WhatsAppConnectionPage.js +459 -0
  106. package/src/react/pages/WhatsAppConnectionPage.styles.js +284 -0
  107. package/src/react/pages/integrationsCatalog.js +399 -0
  108. package/src/react/print/providers/local.js +1 -1
  109. package/src/react/router/publicRoutes.js +25 -0
  110. package/src/react/services/Cielo/Checkout.js +39 -0
  111. package/src/react/services/Cielo/Cielo.js +193 -0
  112. package/src/react/services/Cielo/Print.js +7 -0
  113. package/src/react/services/InfinitePay/Checkout.js +33 -0
  114. package/src/react/services/InfinitePay/InfinitePay.js +24 -0
  115. package/src/react/{utils → services}/paymentGatewayExecution.js +91 -91
  116. package/src/react/styles/global.js +115 -0
  117. package/src/react/utils/categoryContexts.js +46 -0
  118. package/src/react/utils/entityDisplay.js +222 -217
  119. package/src/react/utils/fileUrl.js +201 -16
  120. package/src/react/utils/integrationPage.js +16 -0
  121. package/src/react/utils/menuNavigation.js +31 -0
  122. package/src/react/utils/orderIdentity.js +277 -0
  123. package/src/react/utils/remotePayment.js +115 -61
  124. package/src/react/utils/runtimeFooter.js +40 -22
  125. package/src/react/utils/runtimeLanguage.js +50 -9
  126. package/src/react/utils/runtimeMenu.js +190 -98
  127. package/src/react/utils/runtimeZoom.js +43 -0
  128. package/src/react/utils/shopConfig.js +72 -34
  129. package/src/react/utils/shopFranchises.js +182 -23
  130. package/src/react/utils/socketRuntimePipeline.js +14 -14
  131. package/src/react/utils/storeColumns.js +23 -4
  132. package/src/react/utils/userAvatar.js +104 -0
  133. package/src/store/categories/index.js +48 -20
  134. package/src/store/configs/index.js +2 -2
  135. package/src/store/device_config/index.js +62 -21
  136. package/src/store/entity_log/index.js +22 -1
  137. package/src/store/imports/customActions.js +51 -0
  138. package/src/store/imports/index.js +89 -88
  139. package/src/store/status/index.js +11 -11
  140. package/src/store/themes/index.js +22 -0
  141. package/src/store/timezones/index.js +3 -1
  142. package/src/tests/browser/manager/connections.spec.js +143 -0
  143. package/src/tests/browser/manager/devices-current.spec.js +343 -0
  144. package/src/tests/browser/manager/mercado-livre-integration.spec.js +268 -0
  145. package/src/tests/react/api/deviceHeaders.test.js +114 -0
  146. package/src/tests/react/api/loadSmokeIndex.test.js +75 -0
  147. package/src/tests/react/components/AddImportModal.test.js +166 -0
  148. package/src/tests/react/components/BottomNavigationBar.config.test.js +20 -0
  149. package/src/tests/react/components/UserAvatar.test.js +52 -0
  150. package/src/tests/react/config/deviceConfigBootstrap.test.js +47 -0
  151. package/src/tests/react/pages/DevicePickerStyles.test.js +47 -0
  152. package/src/tests/react/pages/Devices/deviceListHelpers.test.js +39 -0
  153. package/src/tests/react/pages/DevicesCurrentDevice.test.js +198 -0
  154. package/src/tests/react/pages/connectionsHelpers.test.js +34 -0
  155. package/src/tests/react/pages/mercadoLivreIntegrationPageContract.test.mjs +16 -0
  156. package/src/tests/react/print/localPrintProvider.test.js +1 -1
  157. package/src/tests/react/services/Cielo.test.js +190 -0
  158. package/src/tests/react/store/categoriesOrdering.test.js +26 -0
  159. package/src/tests/react/utils/appDomain.test.js +62 -0
  160. package/src/tests/react/utils/entityDisplay.test.js +2 -2
  161. package/src/tests/react/utils/fileUrl.test.js +62 -0
  162. package/src/tests/react/utils/formatter.test.mjs +33 -0
  163. package/src/tests/react/utils/importStatus.test.js +2 -2
  164. package/src/tests/react/utils/orderIdentity.test.js +139 -0
  165. package/src/tests/react/utils/remotePayment.test.js +62 -0
  166. package/src/tests/react/utils/runtimeFooter.test.js +32 -9
  167. package/src/tests/react/utils/runtimeLanguage.test.js +80 -10
  168. package/src/tests/react/utils/runtimeMenu.test.js +195 -111
  169. package/src/tests/react/utils/runtimeZoom.test.js +38 -0
  170. package/src/tests/react/utils/shopConfig.test.js +75 -0
  171. package/src/tests/react/utils/shopFranchises.test.js +122 -12
  172. package/src/tests/react/utils/translate.discovery.test.mjs +170 -0
  173. package/src/tests/react/utils/translate.test.helpers.mjs +152 -0
  174. package/src/tests/react/utils/translate.test.mjs +252 -396
  175. package/src/tests/react/utils/userAvatar.test.js +63 -0
  176. package/src/utils/appDomain.js +15 -4
  177. package/src/utils/formatter.js +122 -16
  178. package/src/utils/integrationConfigs.js +1 -0
  179. package/src/utils/translate.js +277 -398
  180. package/src/utils/translateDiscovery.js +96 -0
  181. package/src/utils/translateNormalize.js +33 -0
  182. package/src/utils/translatePending.js +92 -0
  183. package/src/utils/translateStorage.js +142 -0
  184. package/.github/agents/developer.agent.md +0 -30
  185. package/.github/agents/devops.agent.md +0 -30
  186. package/.github/agents/qa.agent.md +0 -30
  187. package/.github/agents/security.agent.md +0 -30
  188. package/.github/workflows/npmjs.yml +0 -35
@@ -17,15 +17,19 @@ import ProductCatalogCacheService from '@controleonline/ui-common/src/react/comp
17
17
  import RuntimeInfoFooter from '@controleonline/ui-common/src/react/components/RuntimeInfoFooter';
18
18
  import { useStore } from '@store';
19
19
  import { api } from '@controleonline/ui-common/src/api';
20
- import { env as APP_ENV } from '@env';
21
- import { isPublicRoute } from '@controleonline/ui-login/src/react/router/publicRoutes';
22
- const { resolveConfiguredLanguage } = require('../utils/runtimeLanguage');
20
+ import {app_type} from '@appType';
21
+ import {env as APP_ENV} from '@env';
22
+ import { isPublicRoute } from '../router/publicRoutes';
23
+ const {
24
+ buildTranslationBootstrapKey,
25
+ isTranslationBootstrapReady,
26
+ resolveConfiguredLanguage,
27
+ } = require('../utils/runtimeLanguage');
23
28
  import {
24
29
  applyPaletteToRuntimeColors,
25
30
  applyThemeCssVariables,
26
31
  resolveThemePalette,
27
32
  } from '@controleonline/../../src/styles/branding';
28
- import { resolveAppDomain } from '@controleonline/ui-common/src/utils/appDomain';
29
33
  import { colors as runtimeColors } from '@controleonline/../../src/styles/colors';
30
34
  import {
31
35
  buildProviderManagedDeviceConfigs,
@@ -42,7 +46,12 @@ import {
42
46
  filterWalletPaymentTypesByAllowedIds,
43
47
  resolveDevicePaymentTypeIds,
44
48
  } from '@controleonline/ui-common/src/react/utils/paymentDevices';
45
- import {normalizeRuntimeMenuResponse} from '@controleonline/ui-common/src/react/utils/runtimeMenu';
49
+ import {
50
+ normalizeRuntimeMenuResponse,
51
+ } from '@controleonline/ui-common/src/react/utils/runtimeMenu';
52
+ import {
53
+ buildRuntimeZoomStyle,
54
+ } from '@controleonline/ui-common/src/react/utils/runtimeZoom';
46
55
  import stores from '@stores';
47
56
  import packageJson from '@package';
48
57
  import providerStyles from './DefaultProvider.styles';
@@ -140,9 +149,13 @@ const selectRuntimeDeviceConfig = ({
140
149
  })
141
150
  .sort((left, right) => Number(right?.id || 0) - Number(left?.id || 0))[0] || null;
142
151
  };
143
-
144
- export const DefaultProvider = ({ children, onBootstrapReady }) => {
145
- const appType = String(APP_ENV.APP_TYPE || '').toUpperCase();
152
+
153
+ export const DefaultProvider = ({
154
+ children,
155
+ currentRouteName = '',
156
+ onBootstrapReady,
157
+ }) => {
158
+ const appType = String(app_type || '').toUpperCase();
146
159
  const isShopClientApp = appType === 'SHOP';
147
160
  const themeStore = useStore('theme');
148
161
  const getters = themeStore.getters;
@@ -183,17 +196,20 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
183
196
  const hasCurrentCompany =
184
197
  !!currentCompany && Object.entries(currentCompany).length > 0;
185
198
 
186
- const [translateReady, setTranslateReady] = useState(true);
199
+ const [translateReady, setTranslateReady] = useState(false);
200
+ const [activeTranslateBootstrapKey, setActiveTranslateBootstrapKey] =
201
+ useState('');
187
202
  const [deviceConfigFetched, setDeviceConfigFetched] = useState(false);
188
203
  const [mainConfigsDiscovered, setMainConfigsDiscovered] = useState(false);
189
204
  const [deviceRuntimeConfigSynced, setDeviceRuntimeConfigSynced] =
190
205
  useState(false);
191
- const [currentRouteName, setCurrentRouteName] = useState('');
192
206
  const [, setTranslateVersion] = useState(0);
193
207
  const [baseThemeColors, setBaseThemeColors] = useState({});
194
208
  const [bottomNavigationCount, setBottomNavigationCount] = useState(0);
195
209
  const translateBootstrapKeyRef = useRef('');
196
210
  const lastDeviceConfigPeopleIriRef = useRef('');
211
+ const walletPaymentTypeRequestRef = useRef({key: '', promise: null});
212
+ const walletPaymentTypeLoadedKeyRef = useRef('');
197
213
  const [device, setDevice] = useState(
198
214
  JSON.parse(localStorage.getItem('device') || '{}'),
199
215
  );
@@ -205,15 +221,51 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
205
221
  const packageVersion = packageJson?.version || packageJson?.default?.version;
206
222
  const appVersion = packageVersion || device?.appVersion;
207
223
  const runtimeDeviceType = resolveOperationalDeviceType({
208
- appType: APP_ENV.APP_TYPE,
224
+ appType: app_type,
209
225
  deviceInfo: device || {},
210
226
  });
227
+ const runtimeUiScaleStyle = useMemo(
228
+ () => buildRuntimeZoomStyle(APP_ENV?.ZOOM, {isWeb: true}),
229
+ [],
230
+ );
211
231
  const deviceConfigPeopleIri = resolveDeviceConfigPeopleIri({
212
232
  appType,
213
233
  currentCompany,
214
234
  user,
215
235
  });
216
236
  const isPublicRouteActive = isPublicRoute(currentRouteName);
237
+ const currentTranslationConfig = JSON.parse(
238
+ localStorage.getItem('config') || '{}',
239
+ );
240
+ const currentTranslationSession = JSON.parse(
241
+ localStorage.getItem('session') || '{}',
242
+ );
243
+ const configuredTranslationLanguage = resolveConfiguredLanguage({
244
+ currentCompany,
245
+ defaultCompany,
246
+ currentConfig: currentTranslationConfig,
247
+ sessionData: currentTranslationSession,
248
+ });
249
+ const expectedTranslateBootstrapKey = isLogged && hasCurrentCompany
250
+ ? buildTranslationBootstrapKey({
251
+ language: configuredTranslationLanguage,
252
+ currentCompanyId: normalizeEntityId(currentCompany?.id),
253
+ defaultCompanyId: normalizeEntityId(defaultCompany?.id),
254
+ })
255
+ : '';
256
+ const requiresTranslateBootstrap = Boolean(
257
+ isLogged &&
258
+ hasCurrentCompany &&
259
+ currentRouteName &&
260
+ !isPublicRouteActive,
261
+ );
262
+ const isTranslateBootstrapReady = isTranslationBootstrapReady({
263
+ activeKey: activeTranslateBootstrapKey,
264
+ expectedKey: expectedTranslateBootstrapKey,
265
+ required: requiresTranslateBootstrap,
266
+ ready: translateReady,
267
+ translator: global.t,
268
+ });
217
269
 
218
270
  const registerBottomNavigation = useCallback(() => {
219
271
  setBottomNavigationCount(current => current + 1);
@@ -271,30 +323,13 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
271
323
  };
272
324
  }, []);
273
325
 
274
- useEffect(() => {
275
- global.setRuntimeRouteName = routeName => {
276
- const normalizedRouteName = String(routeName || '').trim();
277
-
278
- setCurrentRouteName(previousRouteName =>
279
- previousRouteName === normalizedRouteName
280
- ? previousRouteName
281
- : normalizedRouteName,
282
- );
283
- };
284
-
285
- return () => {
286
- if (global.setRuntimeRouteName) {
287
- delete global.setRuntimeRouteName;
288
- }
289
- };
290
- }, []);
291
-
292
326
  useEffect(() => {
293
327
  if (isLogged && !isPublicRouteActive) {
294
328
  return;
295
329
  }
296
330
 
297
331
  setTranslateReady(true);
332
+ setActiveTranslateBootstrapKey('');
298
333
  translateBootstrapKeyRef.current = '';
299
334
  translateActions.setMessages({});
300
335
  translateActions.setPendingMessages?.({});
@@ -302,7 +337,7 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
302
337
  if (global.t) {
303
338
  delete global.t;
304
339
  }
305
- }, [isLogged, isPublicRouteActive]);
340
+ }, [isLogged, isPublicRouteActive, translateActions]);
306
341
 
307
342
  useEffect(() => {
308
343
  if (
@@ -360,7 +395,7 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
360
395
  'Web App';
361
396
 
362
397
  return buildLocalRuntimeDevice({
363
- appType: APP_ENV.APP_TYPE,
398
+ appType: app_type,
364
399
  deviceInfo: {
365
400
  id: webDeviceId,
366
401
  appName: nextAppName,
@@ -437,7 +472,7 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
437
472
  Array.isArray(items) && items.length > 0 ? items[0] : null;
438
473
  const nextDevice = buildDeviceRegistrationPayload({
439
474
  deviceInfo: device,
440
- appType: APP_ENV.APP_TYPE,
475
+ appType: app_type,
441
476
  existingDevice,
442
477
  });
443
478
 
@@ -523,18 +558,45 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
523
558
  : device_config?.configs;
524
559
 
525
560
  if (!currentCompany?.id || !paymentConfigSource) {
561
+ walletPaymentTypeRequestRef.current = {key: '', promise: null};
562
+ walletPaymentTypeLoadedKeyRef.current = '';
526
563
  paymentTypeActions.setItems([]);
527
564
  return;
528
565
  }
529
566
 
567
+ const paymentTypeSignature = resolveDevicePaymentTypeIds(paymentConfigSource)
568
+ .sort()
569
+ .join(',');
570
+ const requestKey = `${currentCompany.id}:${paymentTypeSignature}`;
571
+
572
+ if (walletPaymentTypeLoadedKeyRef.current === requestKey) {
573
+ return;
574
+ }
575
+
576
+ const existingRequestPromise =
577
+ walletPaymentTypeRequestRef.current.key === requestKey &&
578
+ walletPaymentTypeRequestRef.current.promise
579
+ ? walletPaymentTypeRequestRef.current.promise
580
+ : null;
581
+
530
582
  let isMounted = true;
531
583
 
532
- api
533
- .fetch('wallet_payment_types', {
534
- params: {
535
- people: `/people/${currentCompany.id}`,
536
- },
537
- })
584
+ const requestPromise =
585
+ existingRequestPromise ||
586
+ api.fetch('wallet_payment_types', {
587
+ params: {
588
+ people: `/people/${currentCompany.id}`,
589
+ },
590
+ });
591
+
592
+ if (!existingRequestPromise) {
593
+ walletPaymentTypeRequestRef.current = {
594
+ key: requestKey,
595
+ promise: requestPromise,
596
+ };
597
+ }
598
+
599
+ requestPromise
538
600
  .then(response => {
539
601
  if (!isMounted) {
540
602
  return;
@@ -558,11 +620,20 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
558
620
  allowedPaymentTypeIds,
559
621
  ),
560
622
  );
623
+ walletPaymentTypeLoadedKeyRef.current = requestKey;
561
624
  })
562
625
  .catch(() => {
563
626
  if (isMounted) {
564
627
  paymentTypeActions.setItems([]);
565
628
  }
629
+ })
630
+ .finally(() => {
631
+ if (
632
+ walletPaymentTypeRequestRef.current.key === requestKey &&
633
+ walletPaymentTypeRequestRef.current.promise === requestPromise
634
+ ) {
635
+ walletPaymentTypeRequestRef.current = {key: '', promise: null};
636
+ }
566
637
  });
567
638
 
568
639
  return () => {
@@ -710,56 +781,48 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
710
781
  }, [currentCompany, isLogged, mainConfigsDiscovered]);
711
782
 
712
783
  useEffect(() => {
713
- if (
714
- !currentRouteName ||
715
- isPublicRouteActive
716
- ) {
784
+ if (!currentRouteName || isPublicRouteActive) {
717
785
  return;
718
786
  }
719
787
 
720
788
  if (
721
789
  !isLogged ||
722
- Object.entries(currentCompany).length === 0 ||
723
- !deviceConfigFetched
790
+ !hasCurrentCompany ||
791
+ !deviceConfigFetched ||
792
+ !expectedTranslateBootstrapKey
724
793
  ) {
725
794
  return;
726
795
  }
727
796
 
728
797
  const currentConfig = JSON.parse(localStorage.getItem('config') || '{}');
729
- const sessionData = JSON.parse(localStorage.getItem('session') || '{}');
730
- const currentCompanyId = normalizeEntityId(currentCompany?.id);
731
- const defaultCompanyId = normalizeEntityId(defaultCompany?.id);
732
- const configuredLanguage = resolveConfiguredLanguage({
733
- currentCompany,
734
- defaultCompany,
735
- currentConfig,
736
- sessionData,
737
- });
738
- const nextTranslateBootstrapKey = [
739
- configuredLanguage,
740
- currentCompanyId,
741
- defaultCompanyId,
742
- ].join('::');
743
-
744
- if (translateBootstrapKeyRef.current === nextTranslateBootstrapKey) {
745
- if (global.t) {
746
- global.t.companies = companies;
747
- global.t.currentCompany = currentCompany;
748
- global.t.defaultCompany = defaultCompany;
749
- }
798
+
799
+ if (
800
+ translateBootstrapKeyRef.current === expectedTranslateBootstrapKey &&
801
+ global.t
802
+ ) {
803
+ global.t.companies = companies;
804
+ global.t.currentCompany = currentCompany;
805
+ global.t.defaultCompany = defaultCompany;
806
+ setActiveTranslateBootstrapKey(expectedTranslateBootstrapKey);
807
+ setTranslateReady(true);
750
808
 
751
809
  return;
752
810
  }
753
811
 
754
- if (currentConfig.language !== configuredLanguage) {
755
- const nextConfig = { ...currentConfig, language: configuredLanguage };
812
+ setTranslateReady(false);
813
+
814
+ if (currentConfig.language !== configuredTranslationLanguage) {
815
+ const nextConfig = {
816
+ ...currentConfig,
817
+ language: configuredTranslationLanguage,
818
+ };
756
819
  localStorage.setItem(
757
820
  'config',
758
821
  JSON.stringify(nextConfig),
759
822
  );
760
823
  }
761
824
 
762
- translateBootstrapKeyRef.current = nextTranslateBootstrapKey;
825
+ translateBootstrapKeyRef.current = expectedTranslateBootstrapKey;
763
826
  global.t = new Translate(
764
827
  companies,
765
828
  defaultCompany,
@@ -767,57 +830,49 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
767
830
  Object.keys(stores),
768
831
  translateStore,
769
832
  );
833
+ setActiveTranslateBootstrapKey(expectedTranslateBootstrapKey);
770
834
  setTranslateReady(true);
771
835
  global.refreshTranslationsUI?.();
772
- global.t.discoveryAll().catch(() => {});
773
836
  }, [
774
837
  companies,
838
+ configuredTranslationLanguage,
775
839
  currentCompany,
776
840
  currentRouteName,
777
841
  defaultCompany,
778
842
  deviceConfigFetched,
843
+ expectedTranslateBootstrapKey,
844
+ hasCurrentCompany,
779
845
  isLogged,
780
846
  isPublicRouteActive,
781
- translateActions,
847
+ translateStore,
848
+ ]);
849
+
850
+ useEffect(() => {
851
+ if (
852
+ !isLogged ||
853
+ !hasCurrentCompany ||
854
+ (currentRouteName && isTranslateBootstrapReady)
855
+ ) {
856
+ onBootstrapReady?.();
857
+ }
858
+ }, [
859
+ currentRouteName,
860
+ hasCurrentCompany,
861
+ isLogged,
862
+ isTranslateBootstrapReady,
863
+ onBootstrapReady,
782
864
  ]);
783
-
784
- useEffect(() => {
785
- if (!isLogged || translateReady || !hasCurrentCompany) {
786
- onBootstrapReady?.();
787
- }
788
- }, [isLogged, translateReady, hasCurrentCompany, onBootstrapReady]);
789
-
790
- useEffect(() => {
791
- if (device && device.id && isLogged) {
792
- peopleActions.myCompanies();
793
- }
794
- }, [isLogged, device?.id]);
795
865
 
796
866
  useEffect(() => {
797
- const fetchColors = async () => {
798
- const appDomain = resolveAppDomain(APP_ENV.DOMAIN);
799
- const params = appDomain ? { 'app-domain': appDomain } : undefined;
800
-
801
- try {
802
- const cssText = await api.fetch('themes-colors.css', {
803
- responseType: 'text',
804
- params,
805
- });
806
- const parsedColors = parseThemeCss(cssText);
807
- setBaseThemeColors(parsedColors);
808
- actions.setColors(parsedColors);
809
- } catch {
810
- setBaseThemeColors({});
811
- }
812
- };
813
-
814
- fetchColors();
815
- }, [actions, currentCompany?.id, defaultCompany?.id, device?.id]);
867
+ if (device && device.id && isLogged) {
868
+ peopleActions.myCompanies();
869
+ }
870
+ }, [isLogged, device?.id]);
816
871
 
817
872
  useEffect(() => {
818
- if (!isLogged || !currentCompany?.id || !appType) {
873
+ if (!isLogged || !currentCompany?.id) {
819
874
  actions.setMenus([]);
820
- return;
875
+ return undefined;
821
876
  }
822
877
 
823
878
  let cancelled = false;
@@ -846,6 +901,23 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
846
901
  };
847
902
  }, [actions, appType, currentCompany?.id, isLogged]);
848
903
 
904
+ useEffect(() => {
905
+ const fetchColors = async () => {
906
+ try {
907
+ const cssText = await api.fetch('themes-colors.css', {
908
+ responseType: 'text',
909
+ });
910
+ const parsedColors = parseThemeCss(cssText);
911
+ setBaseThemeColors(parsedColors);
912
+ actions.setColors(parsedColors);
913
+ } catch {
914
+ setBaseThemeColors({});
915
+ }
916
+ };
917
+
918
+ fetchColors();
919
+ }, [actions, currentCompany?.id, defaultCompany?.id, device?.id]);
920
+
849
921
  useEffect(() => {
850
922
  const companyThemeColors = isShopClientApp
851
923
  ? defaultCompany?.theme?.colors || {}
@@ -873,6 +945,10 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
873
945
  isShopClientApp,
874
946
  ]);
875
947
 
948
+ if (requiresTranslateBootstrap && !isTranslateBootstrapReady) {
949
+ return <View style={providerStyles.loadingContainer} />;
950
+ }
951
+
876
952
  return (
877
953
  <ThemeContext.Provider value={themeContextValue}>
878
954
  <View
@@ -882,15 +958,15 @@ export const DefaultProvider = ({ children, onBootstrapReady }) => {
882
958
  backgroundColor: colors?.background || runtimeColors.background,
883
959
  },
884
960
  ]}>
885
- <View style={providerStyles.content}>{children}</View>
886
- {!isShopClientApp && bottomNavigationCount === 0 && (
887
- <RuntimeInfoFooter
888
- appVersion={appVersion}
889
- defaultCompany={defaultCompany}
890
- device={device}
891
- colors={colors}
892
- />
893
- )}
961
+ <View style={[providerStyles.content, runtimeUiScaleStyle]}>{children}</View>
962
+ {!isShopClientApp && bottomNavigationCount === 0 && (
963
+ <RuntimeInfoFooter
964
+ appVersion={appVersion}
965
+ defaultCompany={defaultCompany}
966
+ device={device}
967
+ colors={colors}
968
+ />
969
+ )}
894
970
  </View>
895
971
  {!isShopClientApp && device?.id && isLogged && (
896
972
  <>
@@ -1,7 +1,7 @@
1
1
  import React, {useCallback, useEffect, useRef} from 'react';
2
2
  import {Platform} from 'react-native';
3
3
  import * as Notifications from 'expo-notifications';
4
- import {env as APP_ENV} from '@env';
4
+ import {app_type} from '@appType';
5
5
  import {useStore} from '@store';
6
6
  import {ensureManagerOrderNotificationPermission} from '@controleonline/ui-common/src/react/utils/managerOrderNotifications';
7
7
  import {queueNotificationNavigation} from '@controleonline/ui-common/src/react/utils/notificationNavigation';
@@ -86,7 +86,7 @@ const DeliveryPushBridge = ({device, setDevice}) => {
86
86
  const deviceActions = deviceStore.actions;
87
87
 
88
88
  const {isLogged, sessionChecked} = authGetters;
89
- const isDeliveryRuntime = isDeliveryRuntimeAppType(APP_ENV?.APP_TYPE);
89
+ const isDeliveryRuntime = isDeliveryRuntimeAppType(app_type);
90
90
 
91
91
  const currentDeviceRef = useRef(device || {});
92
92
  const pushTokenListenerRef = useRef(null);
@@ -9,7 +9,7 @@ import React, {useCallback, useEffect, useMemo, useRef} from 'react';
9
9
  import {createAudioPlayer} from 'expo-audio';
10
10
  import {NativeModules, Platform} from 'react-native';
11
11
  import {useStore, useStores} from '@store';
12
- import {env as APP_ENV} from '@env';
12
+ import {app_type} from '@appType';
13
13
  import {api} from '@controleonline/ui-common/src/api';
14
14
  import Formatter from '@controleonline/ui-common/src/utils/formatter';
15
15
  import {
@@ -18,7 +18,7 @@ import {
18
18
  isTruthyValue,
19
19
  parseConfigsObject,
20
20
  } from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
21
- import {resolveOrderIdentity} from '@controleonline/ui-orders/src/react/utils/orderIdentity';
21
+ import {resolveOrderIdentity} from '../utils/orderIdentity';
22
22
  import {
23
23
  isManagerAppType,
24
24
  resolveManagerFinancialNotificationPreferences,
@@ -188,7 +188,7 @@ const DeviceAlertSoundService = () => {
188
188
  [user],
189
189
  );
190
190
 
191
- const isManagerRuntime = isManagerAppType(APP_ENV?.APP_TYPE);
191
+ const isManagerRuntime = isManagerAppType(app_type);
192
192
  const currentCompanyId = normalizeEntityId(currentCompany?.id);
193
193
  const managerPushEnabled =
194
194
  isManagerRuntime && managerOrderNotificationPreferences.pushEnabled;
@@ -1,6 +1,6 @@
1
1
  import React, {useEffect, useMemo, useRef} from 'react';
2
2
  import {AppState, BackHandler, NativeModules, Platform} from 'react-native';
3
- import {env as APP_ENV} from '@env';
3
+ import {app_type} from '@appType';
4
4
  import {useStore} from '@store';
5
5
  import {shouldEnableAndroidKioskMode} from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
6
6
 
@@ -11,7 +11,7 @@ const KioskModeBridge = ({appState = AppState.currentState || 'active'}) => {
11
11
  const {item: runtimeDeviceConfig} = deviceConfigStore.getters;
12
12
  const lastRequestedStateRef = useRef(null);
13
13
  const lastActiveAppStateRef = useRef(appState);
14
- const appType = String(APP_ENV.APP_TYPE || '').trim().toUpperCase();
14
+ const appType = String(app_type || '').trim().toUpperCase();
15
15
  const kioskEnabled = useMemo(
16
16
  () =>
17
17
  shouldEnableAndroidKioskMode({
@@ -1,6 +1,6 @@
1
1
  import React, {useEffect, useMemo, useRef} from 'react';
2
2
  import {AppState, NativeModules, Platform} from 'react-native';
3
- import {env as APP_ENV} from '@env';
3
+ import {app_type} from '@appType';
4
4
  import {useStore} from '@store';
5
5
  import {shouldEnableAndroidLauncherMode} from '@controleonline/ui-common/src/react/config/deviceConfigBootstrap';
6
6
 
@@ -11,7 +11,7 @@ const LauncherModeBridge = ({appState = AppState.currentState || 'active'}) => {
11
11
  const {item: runtimeDeviceConfig} = deviceConfigStore.getters;
12
12
  const lastRequestedStateRef = useRef(null);
13
13
  const lastActiveAppStateRef = useRef(appState);
14
- const appType = String(APP_ENV.APP_TYPE || '').trim().toUpperCase();
14
+ const appType = String(app_type || '').trim().toUpperCase();
15
15
  const launcherEnabled = useMemo(
16
16
  () =>
17
17
  shouldEnableAndroidLauncherMode({
@@ -1,7 +1,7 @@
1
1
  import React, {useCallback, useEffect, useMemo, useRef} from 'react';
2
2
  import {Platform} from 'react-native';
3
3
  import * as Notifications from 'expo-notifications';
4
- import {env as APP_ENV} from '@env';
4
+ import {app_type} from '@appType';
5
5
  import {useStore} from '@store';
6
6
  import {
7
7
  ensureManagerOrderNotificationPermission,
@@ -93,7 +93,7 @@ const ManagerPushBridge = ({device, setDevice}) => {
93
93
  const deviceActions = deviceStore.actions;
94
94
 
95
95
  const {isLogged, sessionChecked, user} = authGetters;
96
- const isManagerRuntime = isManagerAppType(APP_ENV?.APP_TYPE);
96
+ const isManagerRuntime = isManagerAppType(app_type);
97
97
  const pushPreferences = useMemo(
98
98
  () => resolveManagerOrderNotificationPreferences(user),
99
99
  [user],