@controleonline/ui-crm 1.0.44 → 1.0.46

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 (44) hide show
  1. package/.github/workflows/integration-source-gate.yml +1 -15
  2. package/.github/workflows/manager-worker.yml +155 -7
  3. package/.github/workflows/publish-npm.yml +22 -73
  4. package/.release/rc-manifest.json +13 -0
  5. package/AGENTS.md +0 -2
  6. package/package.json +2 -2
  7. package/src/react/pages/crm/hooks/useCrmData.js +17 -23
  8. package/src/react/pages/mcp/McpPage.js +301 -0
  9. package/src/react/pages/mcp/McpPage.styles.js +116 -0
  10. package/src/react/pages/proposals/CreateProposalsModal.js +0 -1
  11. package/src/react/pages/proposals/index.js +33 -14
  12. package/src/react/pages/settings/GeneralSettings.js +17 -9
  13. package/src/react/pages/settings/GeneralSettings.shared.js +20 -20
  14. package/src/react/pages/settings/GeneralSettings.styles.js +0 -2
  15. package/src/react/pages/settings/sections/AiProvidersSection.js +263 -0
  16. package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +11 -11
  17. package/src/react/pages/settings/sections/IntegrationsSection.js +17 -17
  18. package/src/react/pages/settings/sections/LogSection.js +10 -10
  19. package/src/react/pages/settings/sections/LoginSection.js +13 -13
  20. package/src/react/pages/settings/sections/LoyaltyProductPicker.js +145 -58
  21. package/src/react/pages/settings/sections/LoyaltySection.js +9 -35
  22. package/src/react/pages/settings/sections/MaintenanceSection.js +16 -16
  23. package/src/react/pages/settings/sections/MapsSection.js +257 -81
  24. package/src/react/pages/settings/sections/ShopSection.js +2 -2
  25. package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +28 -7
  26. package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +8 -54
  27. package/src/react/pages/settings/sections/shop/shopSettingsShared.js +11 -32
  28. package/src/react/router/routes.js +14 -0
  29. package/src/react/utils/proposalProductSelection.js +13 -103
  30. package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +0 -25
  31. package/src/tests/browser/manager/general-settings-maps.spec.js +347 -173
  32. package/src/tests/react/utils/proposalProductSelection.test.js +1 -57
  33. package/src/react/pages/settings/sections/MapsFranchisePreview.js +0 -102
  34. package/src/react/pages/settings/sections/MapsMapasControls.js +0 -262
  35. package/src/react/pages/settings/sections/loyaltyProductCompany.js +0 -57
  36. package/src/react/pages/settings/sections/mapsSectionHelpers.js +0 -137
  37. package/src/react/utils/clientDetailsNavigation.js +0 -56
  38. package/src/react/utils/clientSellerVisibility.js +0 -60
  39. package/src/react/utils/proposalStatus.js +0 -160
  40. package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +0 -41
  41. package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +0 -38
  42. package/src/tests/react/utils/clientDetailsNavigation.test.js +0 -98
  43. package/src/tests/react/utils/clientSellerVisibility.test.js +0 -74
  44. package/src/tests/react/utils/proposalStatus.test.mjs +0 -77
@@ -1,13 +1,14 @@
1
1
  /*
2
+ * fluxo: outros | etapa: general-settings-maps
3
+ * wikiPage: https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows
4
+ *
2
5
  * @agents This section controls map keys, shop primary entry (mapa vs vitrine),
3
6
  * franchise-locator enablement, franchise address categories, franchise list
4
7
  * with visibility checkboxes and preview map pins for app_type=shop.
5
8
  */
6
- import React, {createElement, useCallback, useEffect, useMemo, useState} from 'react';
9
+ import React, {useCallback, useEffect, useMemo, useState} from 'react';
7
10
  import {
8
11
  ActivityIndicator,
9
- Image,
10
- Platform,
11
12
  Text,
12
13
  TextInput,
13
14
  TouchableOpacity,
@@ -47,23 +48,18 @@ import {
47
48
  } from '@controleonline/ui-common/src/react/utils/shopConfig';
48
49
  import {fetchAllShopFranchiseDirectory} from '@controleonline/ui-common/src/react/utils/shopFranchises';
49
50
  import ShopFranchiseLocatorSection from './shop/ShopFranchiseLocatorSection';
50
- import {
51
- buildFranchiseAddressesById,
52
- normalizeVisibleFranchiseIds,
53
- } from './shop/shopFranchiseVisibility';
51
+ import {normalizeVisibleFranchiseIds} from './shop/shopFranchiseVisibility';
54
52
  import {
55
53
  resolveAddressLabel,
56
54
  resolveCompanyLabel,
57
55
  } from './shop/shopSettingsShared';
58
- import {
59
- PRIMARY_ENTRY_LABELS,
60
- resolveAddressCoords,
61
- buildStaticMapUrl,
62
- buildOsmStaticMapUrl,
63
- buildLeafletMapHtml,
64
- } from './mapsSectionHelpers';
65
- import MapsMapasControls from './MapsMapasControls';
66
- import MapsFranchisePreview from './MapsFranchisePreview';
56
+ import {resolveAddressCoords} from './shop/mapsFranchiseMapHelpers';
57
+ import FranchiseMapPreview from './shop/FranchiseMapPreview';
58
+
59
+ const PRIMARY_ENTRY_LABELS = {
60
+ [SHOP_HOME_OPTION_SALES]: 'Vitrine do shop',
61
+ [SHOP_HOME_OPTION_FRANCHISE_LOCATOR]: 'Mapa das franquias',
62
+ };
67
63
 
68
64
  const MapsSection = () => {
69
65
  const {globalStyles} = css();
@@ -73,16 +69,15 @@ const MapsSection = () => {
73
69
  const categoryActions = categoriesStore.actions;
74
70
  const {
75
71
  currentCompany,
76
- mainCompany,
72
+ defaultCompany,
77
73
  effectiveCompanyConfigs,
78
74
  saveConfig,
79
75
  saveConfigs,
80
- saveMainCompanyConfigs,
76
+ saveDefaultCompanyConfigs,
81
77
  } = useGeneralSettingsConfig();
82
78
 
83
79
  const [webGoogleMapsApiKey, setWebGoogleMapsApiKey] = useState('');
84
80
  const [androidGoogleMapsApiKey, setAndroidGoogleMapsApiKey] = useState('');
85
- const [mapBoxWidth, setMapBoxWidth] = useState(0);
86
81
  const [franchiseAddressCategories, setFranchiseAddressCategories] =
87
82
  useState([]);
88
83
  const [franchiseAddressCategoryIds, setFranchiseAddressCategoryIds] =
@@ -101,9 +96,9 @@ const MapsSection = () => {
101
96
  [],
102
97
  );
103
98
 
104
- const mainCompanyId = mainCompany?.id || mainCompany?.['@id'];
105
- const mainCompanyIri = mainCompanyId
106
- ? '/people/' + mainCompanyId
99
+ const defaultCompanyId = defaultCompany?.id || defaultCompany?.['@id'];
100
+ const defaultCompanyIri = defaultCompanyId
101
+ ? '/people/' + defaultCompanyId
107
102
  : '';
108
103
  const currentCompanyId = normalizeShopEntityId(
109
104
  currentCompany?.id || currentCompany?.['@id'],
@@ -152,7 +147,7 @@ const MapsSection = () => {
152
147
  }, [effectiveCompanyConfigs, shopSettings.franchiseAddressCategoryIds]);
153
148
 
154
149
  useEffect(() => {
155
- if (!mainCompanyIri || !categoryActions?.getItems) {
150
+ if (!defaultCompanyIri || !categoryActions?.getItems) {
156
151
  setFranchiseAddressCategories([]);
157
152
  return undefined;
158
153
  }
@@ -163,7 +158,7 @@ const MapsSection = () => {
163
158
  categoryActions
164
159
  .getItems({
165
160
  context: SHOP_FRANCHISE_ADDRESS_CATEGORY_CONTEXT,
166
- people: mainCompanyIri,
161
+ people: defaultCompanyIri,
167
162
  itemsPerPage: 100,
168
163
  })
169
164
  .then(result => {
@@ -192,7 +187,7 @@ const MapsSection = () => {
192
187
  return () => {
193
188
  isMounted = false;
194
189
  };
195
- }, [categoryActions, categoriesStore.getters, mainCompanyIri]);
190
+ }, [categoryActions, categoriesStore.getters, defaultCompanyIri]);
196
191
 
197
192
  useEffect(() => {
198
193
  if (!franchiseLocatorEnabled || !currentCompanyId) {
@@ -248,11 +243,6 @@ const MapsSection = () => {
248
243
  [enabledHomeOptions],
249
244
  );
250
245
 
251
- const franchiseAddressesById = useMemo(
252
- () => buildFranchiseAddressesById(franchiseDirectory),
253
- [franchiseDirectory],
254
- );
255
-
256
246
  const mapMarkers = useMemo(() => {
257
247
  // Exactly one pin per checked franchise (primary address with coordinates).
258
248
  const selectedCompanyIds = new Set(
@@ -304,28 +294,6 @@ const MapsSection = () => {
304
294
  return markers;
305
295
  }, [franchiseDirectory, visibleFranchiseCompanyIds]);
306
296
 
307
- const staticMapUrl = useMemo(
308
- () =>
309
- buildStaticMapUrl({
310
- apiKey: webGoogleMapsApiKey,
311
- markers: mapMarkers,
312
- size: '1280x480',
313
- }),
314
- [mapMarkers, webGoogleMapsApiKey],
315
- );
316
-
317
- const osmStaticMapUrl = useMemo(
318
- () => buildOsmStaticMapUrl(mapMarkers, '1280x480'),
319
- [mapMarkers],
320
- );
321
-
322
- const leafletMapHtml = useMemo(
323
- () => buildLeafletMapHtml(mapMarkers),
324
- [mapMarkers],
325
- );
326
-
327
- const previewMapUrl = staticMapUrl || osmStaticMapUrl;
328
-
329
297
  const saveMapsSettings = useCallback(async () => {
330
298
  await saveConfigs({
331
299
  [GOOGLE_MAPS_WEB_API_KEY_CONFIG_KEY]: String(
@@ -349,14 +317,14 @@ const MapsSection = () => {
349
317
  ? franchiseAddressCategoryIds.filter(id => id !== categoryId)
350
318
  : [...franchiseAddressCategoryIds, categoryId];
351
319
  setFranchiseAddressCategoryIds(nextIds);
352
- const saved = saveMainCompanyConfigs?.({
320
+ const saved = saveDefaultCompanyConfigs?.({
353
321
  [SHOP_FRANCHISE_ADDRESS_CATEGORY_IDS_CONFIG_KEY]: nextIds,
354
322
  });
355
323
  if (!saved) {
356
324
  setFranchiseAddressCategoryIds(franchiseAddressCategoryIds);
357
325
  }
358
326
  },
359
- [franchiseAddressCategoryIds, saveMainCompanyConfigs],
327
+ [franchiseAddressCategoryIds, saveDefaultCompanyConfigs],
360
328
  );
361
329
 
362
330
  const toggleSalesPage = useCallback(() => {
@@ -401,26 +369,229 @@ const MapsSection = () => {
401
369
  iconBackgroundColor={themePalette.cardIconBackground}
402
370
  iconColor={themePalette.cardIconColor}
403
371
  title="Mapas">
404
- <MapsMapasControls
405
- androidGoogleMapsApiKey={androidGoogleMapsApiKey}
406
- franchiseAddressCategories={franchiseAddressCategories}
407
- franchiseAddressCategoryIds={franchiseAddressCategoryIds}
408
- franchiseLocatorEnabled={franchiseLocatorEnabled}
409
- isLoadingCategories={isLoadingCategories}
410
- localStyles={localStyles}
411
- primaryEntry={primaryEntry}
412
- primaryEntryOptions={primaryEntryOptions}
413
- salesPageEnabled={salesPageEnabled}
414
- saveMapsSettings={saveMapsSettings}
415
- selectPrimaryEntry={selectPrimaryEntry}
416
- setAndroidGoogleMapsApiKey={setAndroidGoogleMapsApiKey}
417
- setWebGoogleMapsApiKey={setWebGoogleMapsApiKey}
418
- themePalette={themePalette}
419
- toggleFranchiseAddressCategory={toggleFranchiseAddressCategory}
420
- toggleFranchiseLocator={toggleFranchiseLocator}
421
- toggleSalesPage={toggleSalesPage}
422
- webGoogleMapsApiKey={webGoogleMapsApiKey}
423
- />
372
+ <View style={localStyles.fieldBlock} testID="maps-primary-entry-options">
373
+ <Text style={localStyles.fieldLabel}>Chave do Google Maps Web</Text>
374
+ <Text style={localStyles.helperText}>
375
+ Usada no display web e no mapa de franquias do shop.
376
+ </Text>
377
+ <TextInput
378
+ value={webGoogleMapsApiKey}
379
+ onChangeText={setWebGoogleMapsApiKey}
380
+ onBlur={saveMapsSettings}
381
+ autoCapitalize="none"
382
+ autoCorrect={false}
383
+ placeholder="Cole a chave do Google Maps para web"
384
+ placeholderTextColor={themePalette.inputPlaceholderText}
385
+ style={localStyles.input}
386
+ />
387
+ </View>
388
+
389
+ <View style={localStyles.fieldBlock}>
390
+ <Text style={localStyles.fieldLabel}>Chave do Google Maps Android</Text>
391
+ <Text style={localStyles.helperText}>
392
+ Reserve para fluxos nativos. O display de entregas no Android usa a
393
+ chave web (WebView).
394
+ </Text>
395
+ <TextInput
396
+ value={androidGoogleMapsApiKey}
397
+ onChangeText={setAndroidGoogleMapsApiKey}
398
+ onBlur={saveMapsSettings}
399
+ autoCapitalize="none"
400
+ autoCorrect={false}
401
+ placeholder="Cole a chave do Google Maps para Android"
402
+ placeholderTextColor={themePalette.inputPlaceholderText}
403
+ style={localStyles.input}
404
+ />
405
+ </View>
406
+
407
+ <View style={localStyles.settingRow}>
408
+ <View style={localStyles.settingCopy}>
409
+ <Text style={localStyles.statusLabel}>Vitrine do shop</Text>
410
+ <Text style={localStyles.settingDescription}>
411
+ Ativa a vitrine principal (categorias/produtos) como entrada do
412
+ app_type=shop.
413
+ </Text>
414
+ </View>
415
+ <TouchableOpacity
416
+ style={[
417
+ localStyles.statusChip,
418
+ salesPageEnabled
419
+ ? localStyles.statusChipEnabled
420
+ : localStyles.statusChipDisabled,
421
+ ]}
422
+ activeOpacity={0.85}
423
+ onPress={toggleSalesPage}>
424
+ <Icon
425
+ name={salesPageEnabled ? 'check-circle' : 'block'}
426
+ size={16}
427
+ color={
428
+ salesPageEnabled
429
+ ? themePalette.badgeSelectedText
430
+ : themePalette.badgeDisabledText
431
+ }
432
+ />
433
+ <Text
434
+ style={[
435
+ localStyles.statusChipText,
436
+ {
437
+ color: salesPageEnabled
438
+ ? themePalette.badgeSelectedText
439
+ : themePalette.badgeDisabledText,
440
+ },
441
+ ]}>
442
+ {salesPageEnabled ? 'Ativado' : 'Desativado'}
443
+ </Text>
444
+ </TouchableOpacity>
445
+ </View>
446
+
447
+ <View style={localStyles.settingRow}>
448
+ <View style={localStyles.settingCopy}>
449
+ <Text style={localStyles.statusLabel}>Localizador de franquias</Text>
450
+ <Text style={localStyles.settingDescription}>
451
+ Ativa o mapa das franquias como entrada do app_type=shop.
452
+ </Text>
453
+ </View>
454
+ <TouchableOpacity
455
+ testID="maps-franchise-locator-toggle"
456
+ style={[
457
+ localStyles.statusChip,
458
+ franchiseLocatorEnabled
459
+ ? localStyles.statusChipEnabled
460
+ : localStyles.statusChipDisabled,
461
+ ]}
462
+ activeOpacity={0.85}
463
+ onPress={toggleFranchiseLocator}>
464
+ <Icon
465
+ name={franchiseLocatorEnabled ? 'check-circle' : 'block'}
466
+ size={16}
467
+ color={
468
+ franchiseLocatorEnabled
469
+ ? themePalette.badgeSelectedText
470
+ : themePalette.badgeDisabledText
471
+ }
472
+ />
473
+ <Text
474
+ style={[
475
+ localStyles.statusChipText,
476
+ {
477
+ color: franchiseLocatorEnabled
478
+ ? themePalette.badgeSelectedText
479
+ : themePalette.badgeDisabledText,
480
+ },
481
+ ]}>
482
+ {franchiseLocatorEnabled ? 'Ativado' : 'Desativado'}
483
+ </Text>
484
+ </TouchableOpacity>
485
+ </View>
486
+
487
+ <View style={localStyles.fieldBlock}>
488
+ <Text style={localStyles.fieldLabel}>Tela principal do shop</Text>
489
+ <Text style={localStyles.helperText}>
490
+ {primaryEntryOptions.length === 0
491
+ ? 'Ative a vitrine e/ou o localizador acima para escolher a entrada principal.'
492
+ : primaryEntryOptions.length === 1
493
+ ? 'Apenas uma entrada está ativa — ela é usada automaticamente.'
494
+ : 'Escolha qual entrada o app_type=shop abre primeiro: mapa das franquias ou vitrine.'}
495
+ </Text>
496
+ {primaryEntryOptions.length > 0 && (
497
+ <View
498
+ style={{
499
+ flexDirection: 'row',
500
+ flexWrap: 'wrap',
501
+ gap: 8,
502
+ marginTop: 8,
503
+ }}>
504
+ {primaryEntryOptions.map(option => {
505
+ const selected = primaryEntry === option.value;
506
+ const locked = primaryEntryOptions.length === 1;
507
+ return (
508
+ <TouchableOpacity
509
+ key={option.value}
510
+ style={[
511
+ localStyles.statusChip,
512
+ selected
513
+ ? localStyles.statusChipEnabled
514
+ : localStyles.statusChipDisabled,
515
+ ]}
516
+ activeOpacity={locked ? 1 : 0.85}
517
+ onPress={() => selectPrimaryEntry(option.value)}
518
+ disabled={locked}>
519
+ <Icon
520
+ name={
521
+ option.value === SHOP_HOME_OPTION_FRANCHISE_LOCATOR
522
+ ? 'map'
523
+ : 'storefront'
524
+ }
525
+ size={16}
526
+ color={
527
+ selected
528
+ ? themePalette.badgeSelectedText
529
+ : themePalette.badgeDisabledText
530
+ }
531
+ />
532
+ <Text
533
+ style={[
534
+ localStyles.statusChipText,
535
+ {
536
+ color: selected
537
+ ? themePalette.badgeSelectedText
538
+ : themePalette.badgeDisabledText,
539
+ },
540
+ ]}>
541
+ {option.label}
542
+ </Text>
543
+ </TouchableOpacity>
544
+ );
545
+ })}
546
+ </View>
547
+ )}
548
+ </View>
549
+
550
+ <View style={localStyles.fieldBlock}>
551
+ <Text style={localStyles.fieldLabel}>
552
+ Categorias de endereços no mapa de franquias
553
+ </Text>
554
+ {isLoadingCategories ? (
555
+ <ActivityIndicator size={22} color={themePalette.primary} />
556
+ ) : franchiseAddressCategories.length === 0 ? (
557
+ <Text style={localStyles.helperText}>
558
+ Nenhuma categoria de endereço encontrada.
559
+ </Text>
560
+ ) : (
561
+ <View>
562
+ {franchiseAddressCategories.map(category => {
563
+ const categoryId = String(category?.id || category?.['@id'] || '')
564
+ .replace(/\D+/g, '')
565
+ .trim();
566
+ const selected = franchiseAddressCategoryIds.includes(categoryId);
567
+
568
+ return (
569
+ <TouchableOpacity
570
+ activeOpacity={0.85}
571
+ key={category?.['@id'] || category?.id}
572
+ onPress={() => toggleFranchiseAddressCategory(category)}
573
+ style={[
574
+ localStyles.franchiseAddressOption,
575
+ selected && localStyles.franchiseAddressOptionActive,
576
+ ]}>
577
+ <View style={localStyles.franchiseAddressOptionCopy}>
578
+ <Text style={localStyles.franchiseAddressName}>
579
+ {category?.name || `Categoria #${categoryId}`}
580
+ </Text>
581
+ </View>
582
+ <Icon
583
+ name={selected ? 'check-box' : 'check-box-outline-blank'}
584
+ size={22}
585
+ color={
586
+ selected ? themePalette.primary : themePalette.textMuted
587
+ }
588
+ />
589
+ </TouchableOpacity>
590
+ );
591
+ })}
592
+ </View>
593
+ )}
594
+ </View>
424
595
 
425
596
  {franchiseLocatorEnabled ? (
426
597
  <>
@@ -431,16 +602,21 @@ const MapsSection = () => {
431
602
  saveConfigs={saveConfigs}
432
603
  themePalette={themePalette}
433
604
  globalStyles={globalStyles}
605
+ onVisibilityChange={(nextCompanyIds, nextAddressIds) => {
606
+ setVisibleFranchiseCompanyIds(
607
+ Array.isArray(nextCompanyIds) ? nextCompanyIds : [],
608
+ );
609
+ setVisibleFranchiseAddressIds(
610
+ Array.isArray(nextAddressIds) ? nextAddressIds : [],
611
+ );
612
+ }}
434
613
  />
435
614
 
436
- <MapsFranchisePreview
437
- isLoadingFranchiseDirectory={isLoadingFranchiseDirectory}
438
- leafletMapHtml={leafletMapHtml}
439
- localStyles={localStyles}
440
- mapBoxWidth={mapBoxWidth}
615
+ <FranchiseMapPreview
616
+ isLoading={isLoadingFranchiseDirectory}
441
617
  mapMarkers={mapMarkers}
442
- previewMapUrl={previewMapUrl}
443
- setMapBoxWidth={setMapBoxWidth}
618
+ webGoogleMapsApiKey={webGoogleMapsApiKey}
619
+ localStyles={localStyles}
444
620
  themePalette={themePalette}
445
621
  visibleFranchiseCompanyIds={visibleFranchiseCompanyIds}
446
622
  />
@@ -88,7 +88,7 @@ const ShopSection = () => {
88
88
  const localStyles = useGeneralSettingsStyles();
89
89
  const {
90
90
  currentCompany,
91
- mainCompanyLabel,
91
+ defaultCompanyLabel,
92
92
  effectiveCompanyConfigs,
93
93
  isMainCompanySelected,
94
94
  saveConfig,
@@ -232,7 +232,7 @@ const ShopSection = () => {
232
232
  <View style={localStyles.emptyBox}>
233
233
  <Text style={localStyles.emptyTitle}>Disponivel na empresa principal</Text>
234
234
  <Text style={localStyles.emptyText}>
235
- Selecione a empresa principal ({mainCompanyLabel}) para configurar o shop.
235
+ Selecione a empresa principal ({defaultCompanyLabel}) para configurar o shop.
236
236
  </Text>
237
237
  </View>
238
238
  </GeneralSettingsSection>
@@ -1,9 +1,26 @@
1
+ /*
2
+ * @agents Franchise locator visibility (companies + addresses) for shop general settings.
3
+ * Persist only on explicit user toggles — never auto-save prunes after refresh.
4
+ */
1
5
  import React, {useCallback, useEffect, useMemo, useState} from 'react';
2
6
  import {useNavigation} from '@react-navigation/native';
3
- import {ActivityIndicator, Text, TextInput, TouchableOpacity, View} from 'react-native';
7
+ import {
8
+ ActivityIndicator,
9
+ Text,
10
+ TextInput,
11
+ TouchableOpacity,
12
+ View,
13
+ } from 'react-native';
4
14
  import Icon from 'react-native-vector-icons/MaterialIcons';
5
- import {fetchAllShopFranchiseDirectory, resolveFranchiseAddressCoords} from '@controleonline/ui-common/src/react/utils/shopFranchises';
6
- import {normalizeShopEntityId, SHOP_FRANCHISE_VISIBLE_ADDRESS_IDS_CONFIG_KEY, SHOP_FRANCHISE_VISIBLE_COMPANY_IDS_CONFIG_KEY} from '@controleonline/ui-common/src/react/utils/shopConfig';
15
+ import {
16
+ fetchAllShopFranchiseDirectory,
17
+ resolveFranchiseAddressCoords,
18
+ } from '@controleonline/ui-common/src/react/utils/shopFranchises';
19
+ import {
20
+ normalizeShopEntityId,
21
+ SHOP_FRANCHISE_VISIBLE_ADDRESS_IDS_CONFIG_KEY,
22
+ SHOP_FRANCHISE_VISIBLE_COMPANY_IDS_CONFIG_KEY,
23
+ } from '@controleonline/ui-common/src/react/utils/shopConfig';
7
24
  import {
8
25
  buildFranchiseAddressesById,
9
26
  buildFranchiseCompaniesById,
@@ -30,6 +47,7 @@ const ShopFranchiseLocatorSection = ({
30
47
  saveConfigs,
31
48
  themePalette,
32
49
  globalStyles,
50
+ onVisibilityChange,
33
51
  }) => {
34
52
  const navigation = useNavigation();
35
53
  const [visibleFranchiseCompanyIds, setVisibleFranchiseCompanyIds] = useState([]);
@@ -176,12 +194,15 @@ const ShopFranchiseLocatorSection = ({
176
194
  (nextCompanyIds, nextAddressIds) => {
177
195
  setVisibleFranchiseCompanyIds(nextCompanyIds);
178
196
  setVisibleFranchiseAddressIds(nextAddressIds);
197
+ if (typeof onVisibilityChange === 'function') {
198
+ onVisibilityChange(nextCompanyIds, nextAddressIds);
199
+ }
179
200
  return saveConfigs({
180
201
  [SHOP_FRANCHISE_VISIBLE_COMPANY_IDS_CONFIG_KEY]: nextCompanyIds,
181
202
  [SHOP_FRANCHISE_VISIBLE_ADDRESS_IDS_CONFIG_KEY]: nextAddressIds,
182
203
  });
183
204
  },
184
- [saveConfigs],
205
+ [onVisibilityChange, saveConfigs],
185
206
  );
186
207
 
187
208
  const companyHasMapCoords = useCallback(company => {
@@ -288,8 +309,8 @@ const ShopFranchiseLocatorSection = ({
288
309
  );
289
310
 
290
311
  return (
291
- <View testID="maps-franchise-locator">
292
- <View style={localStyles.fieldBlock}>
312
+ <>
313
+ <View style={localStyles.fieldBlock} testID="maps-franchise-locator">
293
314
  <Text style={localStyles.fieldLabel}>Franquias exibidas no localizador</Text>
294
315
  <Text style={localStyles.helperText}>
295
316
  Selecione quais empresas vinculadas como franquia podem aparecer no mapa do shop.
@@ -498,7 +519,7 @@ const ShopFranchiseLocatorSection = ({
498
519
  selectionMeta={() => 'Franquia liberada para o localizador'}
499
520
  styles={localStyles}
500
521
  />
501
- </View>
522
+ </>
502
523
  );
503
524
  };
504
525
 
@@ -29,7 +29,6 @@ import {
29
29
  SelectionModal,
30
30
  resolveProductLabel,
31
31
  resolveProductMeta,
32
- resolveProductMetaParts,
33
32
  useShopProductBrowser,
34
33
  useShopProductSearch,
35
34
  } from './shopSettingsShared';
@@ -293,26 +292,11 @@ const ShopLoyaltySection = ({
293
292
  onPress={() => toggleLoyaltyProduct(product)}>
294
293
  <Icon name="remove-circle-outline" size={20} color={themePalette.iconDanger} />
295
294
  <View style={localStyles.printerCopy}>
296
- <Text style={localStyles.printerName} numberOfLines={2}>
297
- {resolveProductLabel(product)}
298
- </Text>
299
- <Text style={localStyles.printerDevice} numberOfLines={1}>
300
- {resolveProductMetaParts(product).metaLine ||
301
- resolveProductMetaParts(product).sku ||
302
- 'Toque para remover'}
295
+ <Text style={localStyles.printerName}>{resolveProductLabel(product)}</Text>
296
+ <Text style={localStyles.printerDevice}>
297
+ {resolveProductMeta(product) || 'Toque para remover'}
303
298
  </Text>
304
299
  </View>
305
- {!!resolveProductMetaParts(product).priceLabel && (
306
- <Text
307
- style={{
308
- fontSize: 13,
309
- fontWeight: '700',
310
- color: themePalette.iconSuccess || themePalette.success,
311
- marginLeft: 8,
312
- }}>
313
- {resolveProductMetaParts(product).priceLabel}
314
- </Text>
315
- )}
316
300
  </TouchableOpacity>
317
301
  );
318
302
  })}
@@ -326,26 +310,11 @@ const ShopLoyaltySection = ({
326
310
  onPress={() => toggleLoyaltyProduct(product)}>
327
311
  <Icon name="inventory-2" size={20} color={themePalette.cardIconColor} />
328
312
  <View style={localStyles.printerCopy}>
329
- <Text style={localStyles.printerName} numberOfLines={2}>
330
- {resolveProductLabel(product)}
331
- </Text>
332
- <Text style={localStyles.printerDevice} numberOfLines={1}>
333
- {resolveProductMetaParts(product).metaLine ||
334
- resolveProductMetaParts(product).sku ||
335
- 'Toque para incluir'}
313
+ <Text style={localStyles.printerName}>{resolveProductLabel(product)}</Text>
314
+ <Text style={localStyles.printerDevice}>
315
+ {resolveProductMeta(product) || 'Toque para incluir'}
336
316
  </Text>
337
317
  </View>
338
- {!!resolveProductMetaParts(product).priceLabel && (
339
- <Text
340
- style={{
341
- fontSize: 13,
342
- fontWeight: '700',
343
- color: themePalette.iconSuccess || themePalette.success,
344
- marginLeft: 8,
345
- }}>
346
- {resolveProductMetaParts(product).priceLabel}
347
- </Text>
348
- )}
349
318
  </TouchableOpacity>
350
319
  );
351
320
  })}
@@ -382,26 +351,11 @@ const ShopLoyaltySection = ({
382
351
  onPress={clearGiftProduct}>
383
352
  <Icon name="remove-circle-outline" size={20} color={themePalette.iconDanger} />
384
353
  <View style={localStyles.printerCopy}>
385
- <Text style={localStyles.printerName} numberOfLines={2}>
354
+ <Text style={localStyles.printerName}>
386
355
  {resolveProductLabel(selectedGiftProduct)}
387
356
  </Text>
388
- <Text style={localStyles.printerDevice} numberOfLines={1}>
389
- {resolveProductMetaParts(selectedGiftProduct).metaLine ||
390
- resolveProductMetaParts(selectedGiftProduct).sku ||
391
- 'Toque para limpar'}
392
- </Text>
357
+ <Text style={localStyles.printerDevice}>Toque para limpar</Text>
393
358
  </View>
394
- {!!resolveProductMetaParts(selectedGiftProduct).priceLabel && (
395
- <Text
396
- style={{
397
- fontSize: 13,
398
- fontWeight: '700',
399
- color: themePalette.iconSuccess || themePalette.success,
400
- marginLeft: 8,
401
- }}>
402
- {resolveProductMetaParts(selectedGiftProduct).priceLabel}
403
- </Text>
404
- )}
405
359
  </TouchableOpacity>
406
360
  ) : null}
407
361
  <View style={localStyles.printerList}>