@controleonline/ui-crm 1.0.44 → 1.0.45
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 +1 -15
- package/.github/workflows/manager-worker.yml +155 -7
- package/.github/workflows/publish-npm.yml +22 -73
- package/AGENTS.md +0 -2
- package/package.json +2 -2
- package/src/react/pages/crm/hooks/useCrmData.js +17 -23
- package/src/react/pages/mcp/McpPage.js +301 -0
- package/src/react/pages/mcp/McpPage.styles.js +116 -0
- package/src/react/pages/proposals/CreateProposalsModal.js +0 -1
- package/src/react/pages/proposals/index.js +33 -14
- package/src/react/pages/settings/GeneralSettings.js +17 -9
- package/src/react/pages/settings/GeneralSettings.shared.js +20 -20
- package/src/react/pages/settings/GeneralSettings.styles.js +0 -2
- package/src/react/pages/settings/sections/AiProvidersSection.js +263 -0
- package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +11 -11
- package/src/react/pages/settings/sections/IntegrationsSection.js +17 -17
- package/src/react/pages/settings/sections/LogSection.js +10 -10
- package/src/react/pages/settings/sections/LoginSection.js +13 -13
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +145 -58
- package/src/react/pages/settings/sections/LoyaltySection.js +9 -35
- package/src/react/pages/settings/sections/MaintenanceSection.js +16 -16
- package/src/react/pages/settings/sections/MapsSection.js +257 -81
- package/src/react/pages/settings/sections/ShopSection.js +2 -2
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +28 -7
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +8 -54
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +11 -32
- package/src/react/router/routes.js +14 -0
- package/src/react/utils/proposalProductSelection.js +13 -103
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +0 -25
- package/src/tests/browser/manager/general-settings-maps.spec.js +347 -173
- package/src/tests/react/utils/proposalProductSelection.test.js +1 -57
- package/src/react/pages/settings/sections/MapsFranchisePreview.js +0 -102
- package/src/react/pages/settings/sections/MapsMapasControls.js +0 -262
- package/src/react/pages/settings/sections/loyaltyProductCompany.js +0 -57
- package/src/react/pages/settings/sections/mapsSectionHelpers.js +0 -137
- package/src/react/utils/clientDetailsNavigation.js +0 -56
- package/src/react/utils/clientSellerVisibility.js +0 -60
- package/src/react/utils/proposalStatus.js +0 -160
- package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +0 -41
- package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +0 -38
- package/src/tests/react/utils/clientDetailsNavigation.test.js +0 -98
- package/src/tests/react/utils/clientSellerVisibility.test.js +0 -74
- package/src/tests/react/utils/proposalStatus.test.mjs +0 -77
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @agents Preview map for selected franchise pins on Mapas (#360).
|
|
3
|
-
*/
|
|
4
|
-
import React, {createElement} from 'react';
|
|
5
|
-
import {ActivityIndicator, Image, Platform, Text, View} from 'react-native';
|
|
6
|
-
|
|
7
|
-
const MapsFranchisePreview = ({
|
|
8
|
-
isLoadingFranchiseDirectory,
|
|
9
|
-
leafletMapHtml,
|
|
10
|
-
localStyles,
|
|
11
|
-
mapBoxWidth,
|
|
12
|
-
mapMarkers,
|
|
13
|
-
previewMapUrl,
|
|
14
|
-
setMapBoxWidth,
|
|
15
|
-
themePalette,
|
|
16
|
-
visibleFranchiseCompanyIds,
|
|
17
|
-
}) => (
|
|
18
|
-
<View
|
|
19
|
-
style={[localStyles.fieldBlock, {alignSelf: 'stretch', width: '100%'}]}
|
|
20
|
-
testID="maps-franchise-map">
|
|
21
|
-
<Text style={localStyles.fieldLabel}>Mapa das franquias</Text>
|
|
22
|
-
<Text style={localStyles.helperText}>
|
|
23
|
-
Pins das franquias marcadas acima (com latitude/longitude).
|
|
24
|
-
</Text>
|
|
25
|
-
{isLoadingFranchiseDirectory ? (
|
|
26
|
-
<ActivityIndicator
|
|
27
|
-
size="small"
|
|
28
|
-
color={themePalette.loadingSpinner || themePalette.primary}
|
|
29
|
-
style={localStyles.sectionLoader}
|
|
30
|
-
/>
|
|
31
|
-
) : mapMarkers.length === 0 ? (
|
|
32
|
-
<View style={localStyles.emptyBox}>
|
|
33
|
-
<Text style={localStyles.emptyTitle}>
|
|
34
|
-
Nenhum pin para exibir
|
|
35
|
-
</Text>
|
|
36
|
-
<Text style={localStyles.emptyText}>
|
|
37
|
-
Marque franquias com latitude/longitude na lista acima para
|
|
38
|
-
aparecerem no mapa.
|
|
39
|
-
</Text>
|
|
40
|
-
</View>
|
|
41
|
-
) : (
|
|
42
|
-
<View style={{alignSelf: 'stretch', width: '100%'}}>
|
|
43
|
-
<View
|
|
44
|
-
onLayout={event => {
|
|
45
|
-
const nextWidth = Math.round(
|
|
46
|
-
event?.nativeEvent?.layout?.width || 0,
|
|
47
|
-
);
|
|
48
|
-
if (nextWidth > 0 && nextWidth !== mapBoxWidth) {
|
|
49
|
-
setMapBoxWidth(nextWidth);
|
|
50
|
-
}
|
|
51
|
-
}}
|
|
52
|
-
style={{
|
|
53
|
-
alignSelf: 'stretch',
|
|
54
|
-
width: '100%',
|
|
55
|
-
height: 360,
|
|
56
|
-
borderRadius: 8,
|
|
57
|
-
overflow: 'hidden',
|
|
58
|
-
backgroundColor: themePalette.inputBackground || '#eee',
|
|
59
|
-
}}>
|
|
60
|
-
{Platform.OS === 'web' && leafletMapHtml && mapBoxWidth > 0
|
|
61
|
-
? createElement('iframe', {
|
|
62
|
-
key: `franchise-map-${mapBoxWidth}-${mapMarkers.length}`,
|
|
63
|
-
title: 'Mapa das franquias',
|
|
64
|
-
srcDoc: leafletMapHtml,
|
|
65
|
-
width: mapBoxWidth,
|
|
66
|
-
height: 360,
|
|
67
|
-
style: {
|
|
68
|
-
width: mapBoxWidth,
|
|
69
|
-
height: 360,
|
|
70
|
-
border: 'none',
|
|
71
|
-
display: 'block',
|
|
72
|
-
margin: 0,
|
|
73
|
-
padding: 0,
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
: previewMapUrl
|
|
77
|
-
? (
|
|
78
|
-
<Image
|
|
79
|
-
source={{uri: previewMapUrl}}
|
|
80
|
-
style={{
|
|
81
|
-
width: '100%',
|
|
82
|
-
height: 360,
|
|
83
|
-
}}
|
|
84
|
-
resizeMode="cover"
|
|
85
|
-
accessibilityLabel="Mapa das franquias com pins"
|
|
86
|
-
/>
|
|
87
|
-
)
|
|
88
|
-
: null}
|
|
89
|
-
</View>
|
|
90
|
-
<Text style={localStyles.helperText}>
|
|
91
|
-
{mapMarkers.length} pin(s) no mapa
|
|
92
|
-
{visibleFranchiseCompanyIds.length > 0
|
|
93
|
-
? ` · ${visibleFranchiseCompanyIds.length} franquia(s) selecionada(s)`
|
|
94
|
-
: ''}
|
|
95
|
-
</Text>
|
|
96
|
-
</View>
|
|
97
|
-
)}
|
|
98
|
-
</View>
|
|
99
|
-
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
export default MapsFranchisePreview;
|
|
@@ -1,262 +0,0 @@
|
|
|
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,57 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @agents Pure helpers for General Settings → Mapas (#360).
|
|
3
|
-
* Coordinate parsing, static map URLs and shop primary-entry labels.
|
|
4
|
-
*/
|
|
5
|
-
import {
|
|
6
|
-
SHOP_HOME_OPTION_FRANCHISE_LOCATOR,
|
|
7
|
-
SHOP_HOME_OPTION_SALES,
|
|
8
|
-
} from '@controleonline/ui-common/src/react/utils/shopConfig';
|
|
9
|
-
|
|
10
|
-
export const PRIMARY_ENTRY_LABELS = {
|
|
11
|
-
[SHOP_HOME_OPTION_SALES]: 'Vitrine do shop',
|
|
12
|
-
[SHOP_HOME_OPTION_FRANCHISE_LOCATOR]: 'Mapa das franquias',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const parseCoord = value => {
|
|
16
|
-
if (value === null || value === undefined || value === '') {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
const n = Number(value);
|
|
20
|
-
if (!Number.isFinite(n) || Math.abs(n) < 0.000001) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
return n;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const resolveAddressCoords = address => {
|
|
27
|
-
const lat = parseCoord(
|
|
28
|
-
address?.latitude ??
|
|
29
|
-
address?.lat ??
|
|
30
|
-
address?.map?.latitude ??
|
|
31
|
-
address?.map?.lat ??
|
|
32
|
-
address?.geo?.latitude,
|
|
33
|
-
);
|
|
34
|
-
const lng = parseCoord(
|
|
35
|
-
address?.longitude ??
|
|
36
|
-
address?.lng ??
|
|
37
|
-
address?.lon ??
|
|
38
|
-
address?.map?.longitude ??
|
|
39
|
-
address?.map?.lng ??
|
|
40
|
-
address?.map?.lon ??
|
|
41
|
-
address?.geo?.longitude,
|
|
42
|
-
);
|
|
43
|
-
if (lat === null || lng === null) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return {lat, lng};
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const buildStaticMapUrl = ({apiKey, markers, size = '640x320'}) => {
|
|
50
|
-
if (!apiKey || !Array.isArray(markers) || markers.length === 0) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const markerParams = markers
|
|
54
|
-
.slice(0, 40)
|
|
55
|
-
.map(
|
|
56
|
-
m =>
|
|
57
|
-
`markers=color:red%7C${encodeURIComponent(`${m.lat},${m.lng}`)}`,
|
|
58
|
-
)
|
|
59
|
-
.join('&');
|
|
60
|
-
const center = markers[0];
|
|
61
|
-
return `https://maps.googleapis.com/maps/api/staticmap?size=${size}&maptype=roadmap¢er=${center.lat},${center.lng}&zoom=${markers.length === 1 ? 14 : 11}&${markerParams}&key=${encodeURIComponent(apiKey)}`;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/** Fallback without Google key — OpenStreetMap static (multi-marker). */
|
|
65
|
-
export const buildOsmStaticMapUrl = (markers, size = '640x320') => {
|
|
66
|
-
if (!Array.isArray(markers) || markers.length === 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
const center = markers[0];
|
|
70
|
-
const zoom = markers.length === 1 ? 14 : 11;
|
|
71
|
-
const markerParams = markers
|
|
72
|
-
.slice(0, 40)
|
|
73
|
-
.map(m => `markers=${m.lat},${m.lng},red-pushpin`)
|
|
74
|
-
.join('&');
|
|
75
|
-
return `https://staticmap.openstreetmap.de/staticmap.php?center=${center.lat},${center.lng}&zoom=${zoom}&size=${size}&maptype=mapnik&${markerParams}`;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/** Interactive Leaflet map HTML for web iframe (no API key). */
|
|
79
|
-
export const buildLeafletMapHtml = markers => {
|
|
80
|
-
if (!Array.isArray(markers) || markers.length === 0) {
|
|
81
|
-
return '';
|
|
82
|
-
}
|
|
83
|
-
const points = markers.slice(0, 40).map(m => ({
|
|
84
|
-
lat: Number(m.lat),
|
|
85
|
-
lng: Number(m.lng),
|
|
86
|
-
label: String(m.companyLabel || m.label || 'Franquia'),
|
|
87
|
-
}));
|
|
88
|
-
const center = points[0];
|
|
89
|
-
const markersJs = points
|
|
90
|
-
.map(
|
|
91
|
-
p =>
|
|
92
|
-
`L.marker([${p.lat}, ${p.lng}]).addTo(map).bindPopup(${JSON.stringify(
|
|
93
|
-
p.label,
|
|
94
|
-
)});`,
|
|
95
|
-
)
|
|
96
|
-
.join('\n');
|
|
97
|
-
const fitJs =
|
|
98
|
-
points.length > 1
|
|
99
|
-
? `map.fitBounds([${points
|
|
100
|
-
.map(p => `[${p.lat}, ${p.lng}]`)
|
|
101
|
-
.join(', ')}], {padding: [28, 28]});`
|
|
102
|
-
: '';
|
|
103
|
-
return `<!DOCTYPE html>
|
|
104
|
-
<html>
|
|
105
|
-
<head>
|
|
106
|
-
<meta charset="utf-8"/>
|
|
107
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
108
|
-
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"/>
|
|
109
|
-
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
|
110
|
-
<style>
|
|
111
|
-
html,body{margin:0;padding:0;height:100%;width:100%;overflow:hidden;}
|
|
112
|
-
#map{position:absolute;inset:0;width:100%;height:100%;}
|
|
113
|
-
.leaflet-container{width:100%!important;height:100%!important;font:12px/1.4 system-ui,sans-serif;}
|
|
114
|
-
</style>
|
|
115
|
-
</head>
|
|
116
|
-
<body style="position:relative;width:100%;height:100%;">
|
|
117
|
-
<div id="map"></div>
|
|
118
|
-
<script>
|
|
119
|
-
var map = L.map('map').setView([${center.lat}, ${center.lng}], ${points.length === 1 ? 14 : 11});
|
|
120
|
-
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
121
|
-
maxZoom: 19,
|
|
122
|
-
attribution: '© OpenStreetMap'
|
|
123
|
-
}).addTo(map);
|
|
124
|
-
${markersJs}
|
|
125
|
-
${fitJs}
|
|
126
|
-
function resizeMap(){ map.invalidateSize(true); }
|
|
127
|
-
setTimeout(resizeMap, 0);
|
|
128
|
-
setTimeout(resizeMap, 100);
|
|
129
|
-
setTimeout(resizeMap, 400);
|
|
130
|
-
window.addEventListener('resize', resizeMap);
|
|
131
|
-
if (typeof ResizeObserver !== 'undefined') {
|
|
132
|
-
new ResizeObserver(resizeMap).observe(document.getElementById('map'));
|
|
133
|
-
}
|
|
134
|
-
</script>
|
|
135
|
-
</body>
|
|
136
|
-
</html>`;
|
|
137
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure helper: resolves safe CRM → ClientDetails navigation.
|
|
3
|
-
* Ensures clientId is present, sets contextKey=client, and opens
|
|
4
|
-
* sellers tab for legal entities (PJ / peopleType J).
|
|
5
|
-
*/
|
|
6
|
-
const extractId = value => String(value || '').replace(/\D/g, '');
|
|
7
|
-
|
|
8
|
-
const resolveClientDetailsNavigation = ({
|
|
9
|
-
reference,
|
|
10
|
-
matchedPerson,
|
|
11
|
-
opportunityClient,
|
|
12
|
-
fallbackName,
|
|
13
|
-
} = {}) => {
|
|
14
|
-
const normalizedReference = String(reference || '').trim();
|
|
15
|
-
if (!normalizedReference) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const selectedClient =
|
|
20
|
-
matchedPerson ||
|
|
21
|
-
(typeof opportunityClient === 'object' && opportunityClient
|
|
22
|
-
? opportunityClient
|
|
23
|
-
: null) || {
|
|
24
|
-
id: extractId(normalizedReference),
|
|
25
|
-
'@id': normalizedReference,
|
|
26
|
-
name: fallbackName,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const clientId = extractId(normalizedReference);
|
|
30
|
-
if (!clientId) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const peopleType = String(
|
|
35
|
-
selectedClient?.peopleType ||
|
|
36
|
-
matchedPerson?.peopleType ||
|
|
37
|
-
opportunityClient?.peopleType ||
|
|
38
|
-
'',
|
|
39
|
-
)
|
|
40
|
-
.trim()
|
|
41
|
-
.toUpperCase();
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
selectedClient,
|
|
45
|
-
params: {
|
|
46
|
-
clientId,
|
|
47
|
-
contextKey: 'client',
|
|
48
|
-
initialTab: peopleType === 'J' ? 'sellers' : 'general',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
resolveClientDetailsNavigation,
|
|
55
|
-
extractId,
|
|
56
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permission rules for client ↔ seller linkage UI (issue #2 / residual #36).
|
|
3
|
-
* Boundary is APP_TYPE (MANAGER vs others), not only company role.
|
|
4
|
-
*
|
|
5
|
-
* MANAGER: full management + commission visibility
|
|
6
|
-
* Non-MANAGER (e.g. CRM): can see linked seller name only
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const normalizeAppType = appType =>
|
|
10
|
-
String(appType || '')
|
|
11
|
-
.trim()
|
|
12
|
-
.toUpperCase();
|
|
13
|
-
|
|
14
|
-
const isManagerApp = appType => normalizeAppType(appType) === 'MANAGER';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} [appType] - APP_TYPE from runtime (MANAGER, CRM, POS, SHOP, …)
|
|
18
|
-
* @returns {{
|
|
19
|
-
* canViewSeller: boolean,
|
|
20
|
-
* canManageSellers: boolean,
|
|
21
|
-
* canChangeSeller: boolean,
|
|
22
|
-
* canRemoveSeller: boolean,
|
|
23
|
-
* canAddMultipleSellers: boolean,
|
|
24
|
-
* canEditSeller: boolean,
|
|
25
|
-
* canViewCommissionPercent: boolean,
|
|
26
|
-
* canViewMinimumCommission: boolean,
|
|
27
|
-
* }}
|
|
28
|
-
*/
|
|
29
|
-
const resolveClientSellerVisibility = (appType) => {
|
|
30
|
-
const manager = isManagerApp(appType);
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
canViewSeller: true,
|
|
34
|
-
canManageSellers: manager,
|
|
35
|
-
canChangeSeller: manager,
|
|
36
|
-
canRemoveSeller: manager,
|
|
37
|
-
canAddMultipleSellers: manager,
|
|
38
|
-
canEditSeller: manager,
|
|
39
|
-
canViewCommissionPercent: manager,
|
|
40
|
-
canViewMinimumCommission: manager,
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Whether commission-related fields should be shown in the UI.
|
|
46
|
-
*/
|
|
47
|
-
const canShowCommissionFields = appType => isManagerApp(appType);
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Whether seller linkage management actions (add/change/remove) are allowed.
|
|
51
|
-
*/
|
|
52
|
-
const canManageSellerLinks = appType => isManagerApp(appType);
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
resolveClientSellerVisibility,
|
|
56
|
-
canShowCommissionFields,
|
|
57
|
-
canManageSellerLinks,
|
|
58
|
-
isManagerApp,
|
|
59
|
-
normalizeAppType,
|
|
60
|
-
};
|