@controleonline/ui-crm 1.0.42 → 1.0.44
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/workflows/integration-source-gate.yml +82 -0
- package/.github/workflows/manager-worker.yml +7 -155
- package/.github/workflows/publish-npm.yml +73 -22
- package/AGENTS.md +2 -0
- package/package.json +2 -2
- package/src/react/pages/crm/hooks/useCrmData.js +23 -17
- package/src/react/pages/proposals/CreateProposalsModal.js +1 -0
- package/src/react/pages/proposals/index.js +14 -33
- package/src/react/pages/settings/GeneralSettings.styles.js +2 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +58 -145
- package/src/react/pages/settings/sections/LoyaltySection.js +35 -9
- package/src/react/pages/settings/sections/MapsFranchisePreview.js +102 -0
- package/src/react/pages/settings/sections/MapsMapasControls.js +262 -0
- package/src/react/pages/settings/sections/MapsSection.js +71 -247
- package/src/react/pages/settings/sections/loyaltyProductCompany.js +57 -0
- package/src/react/pages/settings/sections/mapsSectionHelpers.js +137 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +7 -28
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +54 -8
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +32 -11
- package/src/react/utils/clientDetailsNavigation.js +56 -0
- package/src/react/utils/clientSellerVisibility.js +60 -0
- package/src/react/utils/proposalProductSelection.js +103 -13
- package/src/react/utils/proposalStatus.js +160 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +25 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +173 -347
- package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +41 -0
- package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +38 -0
- package/src/tests/react/utils/clientDetailsNavigation.test.js +98 -0
- package/src/tests/react/utils/clientSellerVisibility.test.js +74 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +57 -1
- package/src/tests/react/utils/proposalStatus.test.mjs +77 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents Mapas controls: API keys, shop home toggles, primary entry, address categories (#360).
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import {
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
Text,
|
|
8
|
+
TextInput,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
View,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
13
|
+
import {SHOP_HOME_OPTION_FRANCHISE_LOCATOR} from '@controleonline/ui-common/src/react/utils/shopConfig';
|
|
14
|
+
|
|
15
|
+
const MapsMapasControls = ({
|
|
16
|
+
androidGoogleMapsApiKey,
|
|
17
|
+
franchiseAddressCategories,
|
|
18
|
+
franchiseAddressCategoryIds,
|
|
19
|
+
franchiseLocatorEnabled,
|
|
20
|
+
isLoadingCategories,
|
|
21
|
+
localStyles,
|
|
22
|
+
primaryEntry,
|
|
23
|
+
primaryEntryOptions,
|
|
24
|
+
salesPageEnabled,
|
|
25
|
+
saveMapsSettings,
|
|
26
|
+
selectPrimaryEntry,
|
|
27
|
+
setAndroidGoogleMapsApiKey,
|
|
28
|
+
setWebGoogleMapsApiKey,
|
|
29
|
+
themePalette,
|
|
30
|
+
toggleFranchiseAddressCategory,
|
|
31
|
+
toggleFranchiseLocator,
|
|
32
|
+
toggleSalesPage,
|
|
33
|
+
webGoogleMapsApiKey,
|
|
34
|
+
}) => (
|
|
35
|
+
<>
|
|
36
|
+
<View style={localStyles.fieldBlock}>
|
|
37
|
+
<Text style={localStyles.fieldLabel}>Chave do Google Maps Web</Text>
|
|
38
|
+
<Text style={localStyles.helperText}>
|
|
39
|
+
Usada no display web e no mapa de franquias do shop.
|
|
40
|
+
</Text>
|
|
41
|
+
<TextInput
|
|
42
|
+
value={webGoogleMapsApiKey}
|
|
43
|
+
onChangeText={setWebGoogleMapsApiKey}
|
|
44
|
+
onBlur={saveMapsSettings}
|
|
45
|
+
autoCapitalize="none"
|
|
46
|
+
autoCorrect={false}
|
|
47
|
+
placeholder="Cole a chave do Google Maps para web"
|
|
48
|
+
placeholderTextColor={themePalette.inputPlaceholderText}
|
|
49
|
+
style={localStyles.input}
|
|
50
|
+
/>
|
|
51
|
+
</View>
|
|
52
|
+
|
|
53
|
+
<View style={localStyles.fieldBlock}>
|
|
54
|
+
<Text style={localStyles.fieldLabel}>Chave do Google Maps Android</Text>
|
|
55
|
+
<Text style={localStyles.helperText}>
|
|
56
|
+
Reserve para fluxos nativos. O display de entregas no Android usa a
|
|
57
|
+
chave web (WebView).
|
|
58
|
+
</Text>
|
|
59
|
+
<TextInput
|
|
60
|
+
value={androidGoogleMapsApiKey}
|
|
61
|
+
onChangeText={setAndroidGoogleMapsApiKey}
|
|
62
|
+
onBlur={saveMapsSettings}
|
|
63
|
+
autoCapitalize="none"
|
|
64
|
+
autoCorrect={false}
|
|
65
|
+
placeholder="Cole a chave do Google Maps para Android"
|
|
66
|
+
placeholderTextColor={themePalette.inputPlaceholderText}
|
|
67
|
+
style={localStyles.input}
|
|
68
|
+
/>
|
|
69
|
+
</View>
|
|
70
|
+
|
|
71
|
+
<View style={localStyles.settingRow}>
|
|
72
|
+
<View style={localStyles.settingCopy}>
|
|
73
|
+
<Text style={localStyles.statusLabel}>Vitrine do shop</Text>
|
|
74
|
+
<Text style={localStyles.settingDescription}>
|
|
75
|
+
Ativa a vitrine principal (categorias/produtos) como entrada do
|
|
76
|
+
app_type=shop.
|
|
77
|
+
</Text>
|
|
78
|
+
</View>
|
|
79
|
+
<TouchableOpacity
|
|
80
|
+
style={[
|
|
81
|
+
localStyles.statusChip,
|
|
82
|
+
salesPageEnabled
|
|
83
|
+
? localStyles.statusChipEnabled
|
|
84
|
+
: localStyles.statusChipDisabled,
|
|
85
|
+
]}
|
|
86
|
+
activeOpacity={0.85}
|
|
87
|
+
onPress={toggleSalesPage}>
|
|
88
|
+
<Icon
|
|
89
|
+
name={salesPageEnabled ? 'check-circle' : 'block'}
|
|
90
|
+
size={16}
|
|
91
|
+
color={
|
|
92
|
+
salesPageEnabled
|
|
93
|
+
? themePalette.badgeSelectedText
|
|
94
|
+
: themePalette.badgeDisabledText
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
<Text
|
|
98
|
+
style={[
|
|
99
|
+
localStyles.statusChipText,
|
|
100
|
+
{
|
|
101
|
+
color: salesPageEnabled
|
|
102
|
+
? themePalette.badgeSelectedText
|
|
103
|
+
: themePalette.badgeDisabledText,
|
|
104
|
+
},
|
|
105
|
+
]}>
|
|
106
|
+
{salesPageEnabled ? 'Ativado' : 'Desativado'}
|
|
107
|
+
</Text>
|
|
108
|
+
</TouchableOpacity>
|
|
109
|
+
</View>
|
|
110
|
+
|
|
111
|
+
<View style={localStyles.settingRow}>
|
|
112
|
+
<View style={localStyles.settingCopy}>
|
|
113
|
+
<Text style={localStyles.statusLabel}>Localizador de franquias</Text>
|
|
114
|
+
<Text style={localStyles.settingDescription}>
|
|
115
|
+
Ativa o mapa das franquias como entrada do app_type=shop.
|
|
116
|
+
</Text>
|
|
117
|
+
</View>
|
|
118
|
+
<TouchableOpacity
|
|
119
|
+
style={[
|
|
120
|
+
localStyles.statusChip,
|
|
121
|
+
franchiseLocatorEnabled
|
|
122
|
+
? localStyles.statusChipEnabled
|
|
123
|
+
: localStyles.statusChipDisabled,
|
|
124
|
+
]}
|
|
125
|
+
activeOpacity={0.85}
|
|
126
|
+
onPress={toggleFranchiseLocator}>
|
|
127
|
+
<Icon
|
|
128
|
+
name={franchiseLocatorEnabled ? 'check-circle' : 'block'}
|
|
129
|
+
size={16}
|
|
130
|
+
color={
|
|
131
|
+
franchiseLocatorEnabled
|
|
132
|
+
? themePalette.badgeSelectedText
|
|
133
|
+
: themePalette.badgeDisabledText
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
136
|
+
<Text
|
|
137
|
+
style={[
|
|
138
|
+
localStyles.statusChipText,
|
|
139
|
+
{
|
|
140
|
+
color: franchiseLocatorEnabled
|
|
141
|
+
? themePalette.badgeSelectedText
|
|
142
|
+
: themePalette.badgeDisabledText,
|
|
143
|
+
},
|
|
144
|
+
]}>
|
|
145
|
+
{franchiseLocatorEnabled ? 'Ativado' : 'Desativado'}
|
|
146
|
+
</Text>
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
</View>
|
|
149
|
+
|
|
150
|
+
<View style={localStyles.fieldBlock}>
|
|
151
|
+
<Text style={localStyles.fieldLabel}>Tela principal do shop</Text>
|
|
152
|
+
<Text style={localStyles.helperText}>
|
|
153
|
+
{primaryEntryOptions.length === 0
|
|
154
|
+
? 'Ative a vitrine e/ou o localizador acima para escolher a entrada principal.'
|
|
155
|
+
: primaryEntryOptions.length === 1
|
|
156
|
+
? 'Apenas uma entrada está ativa — ela é usada automaticamente.'
|
|
157
|
+
: 'Escolha qual entrada o app_type=shop abre primeiro: mapa das franquias ou vitrine.'}
|
|
158
|
+
</Text>
|
|
159
|
+
{primaryEntryOptions.length > 0 && (
|
|
160
|
+
<View
|
|
161
|
+
testID="maps-primary-entry-options"
|
|
162
|
+
style={{
|
|
163
|
+
flexDirection: 'row',
|
|
164
|
+
flexWrap: 'wrap',
|
|
165
|
+
gap: 8,
|
|
166
|
+
marginTop: 8,
|
|
167
|
+
}}>
|
|
168
|
+
{primaryEntryOptions.map(option => {
|
|
169
|
+
const selected = primaryEntry === option.value;
|
|
170
|
+
const locked = primaryEntryOptions.length === 1;
|
|
171
|
+
return (
|
|
172
|
+
<TouchableOpacity
|
|
173
|
+
key={option.value}
|
|
174
|
+
style={[
|
|
175
|
+
localStyles.statusChip,
|
|
176
|
+
selected
|
|
177
|
+
? localStyles.statusChipEnabled
|
|
178
|
+
: localStyles.statusChipDisabled,
|
|
179
|
+
]}
|
|
180
|
+
activeOpacity={locked ? 1 : 0.85}
|
|
181
|
+
onPress={() => selectPrimaryEntry(option.value)}
|
|
182
|
+
disabled={locked}>
|
|
183
|
+
<Icon
|
|
184
|
+
name={
|
|
185
|
+
option.value === SHOP_HOME_OPTION_FRANCHISE_LOCATOR
|
|
186
|
+
? 'map'
|
|
187
|
+
: 'storefront'
|
|
188
|
+
}
|
|
189
|
+
size={16}
|
|
190
|
+
color={
|
|
191
|
+
selected
|
|
192
|
+
? themePalette.badgeSelectedText
|
|
193
|
+
: themePalette.badgeDisabledText
|
|
194
|
+
}
|
|
195
|
+
/>
|
|
196
|
+
<Text
|
|
197
|
+
style={[
|
|
198
|
+
localStyles.statusChipText,
|
|
199
|
+
{
|
|
200
|
+
color: selected
|
|
201
|
+
? themePalette.badgeSelectedText
|
|
202
|
+
: themePalette.badgeDisabledText,
|
|
203
|
+
},
|
|
204
|
+
]}>
|
|
205
|
+
{option.label}
|
|
206
|
+
</Text>
|
|
207
|
+
</TouchableOpacity>
|
|
208
|
+
);
|
|
209
|
+
})}
|
|
210
|
+
</View>
|
|
211
|
+
)}
|
|
212
|
+
</View>
|
|
213
|
+
|
|
214
|
+
<View style={localStyles.fieldBlock}>
|
|
215
|
+
<Text style={localStyles.fieldLabel}>
|
|
216
|
+
Categorias de endereços no mapa de franquias
|
|
217
|
+
</Text>
|
|
218
|
+
{isLoadingCategories ? (
|
|
219
|
+
<ActivityIndicator size={22} color={themePalette.primary} />
|
|
220
|
+
) : franchiseAddressCategories.length === 0 ? (
|
|
221
|
+
<Text style={localStyles.helperText}>
|
|
222
|
+
Nenhuma categoria de endereço encontrada.
|
|
223
|
+
</Text>
|
|
224
|
+
) : (
|
|
225
|
+
<View>
|
|
226
|
+
{franchiseAddressCategories.map(category => {
|
|
227
|
+
const categoryId = String(category?.id || category?.['@id'] || '')
|
|
228
|
+
.replace(/\D+/g, '')
|
|
229
|
+
.trim();
|
|
230
|
+
const selected = franchiseAddressCategoryIds.includes(categoryId);
|
|
231
|
+
|
|
232
|
+
return (
|
|
233
|
+
<TouchableOpacity
|
|
234
|
+
activeOpacity={0.85}
|
|
235
|
+
key={category?.['@id'] || category?.id}
|
|
236
|
+
onPress={() => toggleFranchiseAddressCategory(category)}
|
|
237
|
+
style={[
|
|
238
|
+
localStyles.franchiseAddressOption,
|
|
239
|
+
selected && localStyles.franchiseAddressOptionActive,
|
|
240
|
+
]}>
|
|
241
|
+
<View style={localStyles.franchiseAddressOptionCopy}>
|
|
242
|
+
<Text style={localStyles.franchiseAddressName}>
|
|
243
|
+
{category?.name || `Categoria #${categoryId}`}
|
|
244
|
+
</Text>
|
|
245
|
+
</View>
|
|
246
|
+
<Icon
|
|
247
|
+
name={selected ? 'check-box' : 'check-box-outline-blank'}
|
|
248
|
+
size={22}
|
|
249
|
+
color={
|
|
250
|
+
selected ? themePalette.primary : themePalette.textMuted
|
|
251
|
+
}
|
|
252
|
+
/>
|
|
253
|
+
</TouchableOpacity>
|
|
254
|
+
);
|
|
255
|
+
})}
|
|
256
|
+
</View>
|
|
257
|
+
)}
|
|
258
|
+
</View>
|
|
259
|
+
</>
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
export default MapsMapasControls;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* fluxo: outros | etapa: general-settings-maps
|
|
3
|
-
* wikiPage: https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows
|
|
4
|
-
*
|
|
5
2
|
* @agents This section controls map keys, shop primary entry (mapa vs vitrine),
|
|
6
3
|
* franchise-locator enablement, franchise address categories, franchise list
|
|
7
4
|
* with visibility checkboxes and preview map pins for app_type=shop.
|
|
8
5
|
*/
|
|
9
|
-
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
|
6
|
+
import React, {createElement, useCallback, useEffect, useMemo, useState} from 'react';
|
|
10
7
|
import {
|
|
11
8
|
ActivityIndicator,
|
|
9
|
+
Image,
|
|
10
|
+
Platform,
|
|
12
11
|
Text,
|
|
13
12
|
TextInput,
|
|
14
13
|
TouchableOpacity,
|
|
@@ -48,18 +47,23 @@ import {
|
|
|
48
47
|
} from '@controleonline/ui-common/src/react/utils/shopConfig';
|
|
49
48
|
import {fetchAllShopFranchiseDirectory} from '@controleonline/ui-common/src/react/utils/shopFranchises';
|
|
50
49
|
import ShopFranchiseLocatorSection from './shop/ShopFranchiseLocatorSection';
|
|
51
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
buildFranchiseAddressesById,
|
|
52
|
+
normalizeVisibleFranchiseIds,
|
|
53
|
+
} from './shop/shopFranchiseVisibility';
|
|
52
54
|
import {
|
|
53
55
|
resolveAddressLabel,
|
|
54
56
|
resolveCompanyLabel,
|
|
55
57
|
} from './shop/shopSettingsShared';
|
|
56
|
-
import {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
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';
|
|
63
67
|
|
|
64
68
|
const MapsSection = () => {
|
|
65
69
|
const {globalStyles} = css();
|
|
@@ -78,6 +82,7 @@ const MapsSection = () => {
|
|
|
78
82
|
|
|
79
83
|
const [webGoogleMapsApiKey, setWebGoogleMapsApiKey] = useState('');
|
|
80
84
|
const [androidGoogleMapsApiKey, setAndroidGoogleMapsApiKey] = useState('');
|
|
85
|
+
const [mapBoxWidth, setMapBoxWidth] = useState(0);
|
|
81
86
|
const [franchiseAddressCategories, setFranchiseAddressCategories] =
|
|
82
87
|
useState([]);
|
|
83
88
|
const [franchiseAddressCategoryIds, setFranchiseAddressCategoryIds] =
|
|
@@ -243,6 +248,11 @@ const MapsSection = () => {
|
|
|
243
248
|
[enabledHomeOptions],
|
|
244
249
|
);
|
|
245
250
|
|
|
251
|
+
const franchiseAddressesById = useMemo(
|
|
252
|
+
() => buildFranchiseAddressesById(franchiseDirectory),
|
|
253
|
+
[franchiseDirectory],
|
|
254
|
+
);
|
|
255
|
+
|
|
246
256
|
const mapMarkers = useMemo(() => {
|
|
247
257
|
// Exactly one pin per checked franchise (primary address with coordinates).
|
|
248
258
|
const selectedCompanyIds = new Set(
|
|
@@ -294,6 +304,28 @@ const MapsSection = () => {
|
|
|
294
304
|
return markers;
|
|
295
305
|
}, [franchiseDirectory, visibleFranchiseCompanyIds]);
|
|
296
306
|
|
|
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
|
+
|
|
297
329
|
const saveMapsSettings = useCallback(async () => {
|
|
298
330
|
await saveConfigs({
|
|
299
331
|
[GOOGLE_MAPS_WEB_API_KEY_CONFIG_KEY]: String(
|
|
@@ -369,229 +401,26 @@ const MapsSection = () => {
|
|
|
369
401
|
iconBackgroundColor={themePalette.cardIconBackground}
|
|
370
402
|
iconColor={themePalette.cardIconColor}
|
|
371
403
|
title="Mapas">
|
|
372
|
-
<
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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>
|
|
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
|
+
/>
|
|
595
424
|
|
|
596
425
|
{franchiseLocatorEnabled ? (
|
|
597
426
|
<>
|
|
@@ -602,21 +431,16 @@ const MapsSection = () => {
|
|
|
602
431
|
saveConfigs={saveConfigs}
|
|
603
432
|
themePalette={themePalette}
|
|
604
433
|
globalStyles={globalStyles}
|
|
605
|
-
onVisibilityChange={(nextCompanyIds, nextAddressIds) => {
|
|
606
|
-
setVisibleFranchiseCompanyIds(
|
|
607
|
-
Array.isArray(nextCompanyIds) ? nextCompanyIds : [],
|
|
608
|
-
);
|
|
609
|
-
setVisibleFranchiseAddressIds(
|
|
610
|
-
Array.isArray(nextAddressIds) ? nextAddressIds : [],
|
|
611
|
-
);
|
|
612
|
-
}}
|
|
613
434
|
/>
|
|
614
435
|
|
|
615
|
-
<
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
webGoogleMapsApiKey={webGoogleMapsApiKey}
|
|
436
|
+
<MapsFranchisePreview
|
|
437
|
+
isLoadingFranchiseDirectory={isLoadingFranchiseDirectory}
|
|
438
|
+
leafletMapHtml={leafletMapHtml}
|
|
619
439
|
localStyles={localStyles}
|
|
440
|
+
mapBoxWidth={mapBoxWidth}
|
|
441
|
+
mapMarkers={mapMarkers}
|
|
442
|
+
previewMapUrl={previewMapUrl}
|
|
443
|
+
setMapBoxWidth={setMapBoxWidth}
|
|
620
444
|
themePalette={themePalette}
|
|
621
445
|
visibleFranchiseCompanyIds={visibleFranchiseCompanyIds}
|
|
622
446
|
/>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents Company-scope helpers for Fidelidade product pickers (task-666).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const normalizeLoyaltyCompanyId = value => {
|
|
6
|
+
if (value === null || value === undefined || value === '') {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof value === 'object') {
|
|
11
|
+
return normalizeLoyaltyCompanyId(
|
|
12
|
+
value.id || value['@id'] || value.company || value.people,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return String(value).replace(/\D+/g, '').trim();
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const productBelongsToCompany = (product, companyId) => {
|
|
20
|
+
const expected = normalizeLoyaltyCompanyId(companyId);
|
|
21
|
+
if (!expected) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const candidates = [
|
|
26
|
+
product?.company,
|
|
27
|
+
product?.companyId,
|
|
28
|
+
product?.people,
|
|
29
|
+
product?.peopleId,
|
|
30
|
+
product?.owner,
|
|
31
|
+
product?.provider,
|
|
32
|
+
].map(normalizeLoyaltyCompanyId).filter(Boolean);
|
|
33
|
+
|
|
34
|
+
if (candidates.length === 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return candidates.includes(expected);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const filterProductsByCompany = (items, companyId) => {
|
|
42
|
+
const list = Array.isArray(items) ? items : [];
|
|
43
|
+
const expected = normalizeLoyaltyCompanyId(companyId);
|
|
44
|
+
if (!expected) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return list.filter(item => productBelongsToCompany(item, expected));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
52
|
+
module.exports = {
|
|
53
|
+
normalizeLoyaltyCompanyId,
|
|
54
|
+
productBelongsToCompany,
|
|
55
|
+
filterProductsByCompany,
|
|
56
|
+
};
|
|
57
|
+
}
|