@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,15 +1,19 @@
1
1
  /*
2
2
  * @agents Shared product picker helpers for Loyalty (Fidelidade) settings.
3
- * ProductSelectionModal reuses the canonical SelectionModal chrome from shop settings.
4
3
  */
5
4
  import React, {useEffect, useState} from 'react';
6
- import {normalizeShopProductId} from '@controleonline/ui-common/src/react/utils/shopConfig';
7
- import {searchCompanyProducts} from '@controleonline/ui-common/src/react/utils/commercialDocumentOrders';
8
5
  import {
9
- filterProductsByCompany,
10
- normalizeLoyaltyCompanyId,
11
- } from './loyaltyProductCompany';
12
- import {SelectionModal} from './shop/shopSettingsShared';
6
+ ActivityIndicator,
7
+ ScrollView,
8
+ Text,
9
+ TextInput,
10
+ TouchableOpacity,
11
+ View,
12
+ } from 'react-native';
13
+ import Icon from 'react-native-vector-icons/MaterialIcons';
14
+ import AnimatedModal from '@controleonline/ui-common/src/react/components/AnimatedModal';
15
+ import {searchCompanyProducts} from '@controleonline/ui-common/src/react/utils/commercialDocumentOrders';
16
+ import {normalizeShopProductId} from '@controleonline/ui-common/src/react/utils/shopConfig';
13
17
 
14
18
  export const resolveProductLabel = product => {
15
19
  const normalizedId = normalizeShopProductId(product);
@@ -23,35 +27,25 @@ export const resolveProductLabel = product => {
23
27
  );
24
28
  };
25
29
 
26
- export const resolveProductMetaParts = product => {
30
+ export const resolveProductMeta = product => {
27
31
  const sku = String(product?.sku || '').trim();
28
32
  const price = Number(product?.price || 0);
29
- const priceLabel =
30
- Number.isFinite(price) && price > 0
31
- ? `R$ ${price.toFixed(2).replace('.', ',')}`
32
- : '';
33
-
34
- return {
35
- sku: sku ? `SKU ${sku}` : '',
36
- priceLabel,
37
- metaLine: [sku ? `SKU ${sku}` : null].filter(Boolean).join(' • '),
38
- };
39
- };
33
+ const priceLabel = Number.isFinite(price)
34
+ ? `R$ ${price.toFixed(2).replace('.', ',')}`
35
+ : '';
40
36
 
41
- /** Prefer resolveProductMetaParts when layout needs price separated. */
42
- export const resolveProductMeta = product => {
43
- const {sku, priceLabel} = resolveProductMetaParts(product);
44
- return [sku || null, priceLabel || null].filter(Boolean).join(' • ');
37
+ return [sku ? `SKU ${sku}` : null, price > 0 ? priceLabel : null]
38
+ .filter(Boolean)
39
+ .join(' • ');
45
40
  };
46
41
 
47
42
  export const useProductBrowser = ({companyId, visible}) => {
48
43
  const [query, setQuery] = useState('');
49
44
  const [results, setResults] = useState([]);
50
45
  const [isLoading, setIsLoading] = useState(false);
51
- const scopedCompanyId = normalizeLoyaltyCompanyId(companyId);
52
46
 
53
47
  useEffect(() => {
54
- if (!visible || !scopedCompanyId) {
48
+ if (!visible || !companyId) {
55
49
  setResults([]);
56
50
  setIsLoading(false);
57
51
  return undefined;
@@ -64,11 +58,11 @@ export const useProductBrowser = ({companyId, visible}) => {
64
58
  setIsLoading(true);
65
59
  try {
66
60
  const items = await searchCompanyProducts({
67
- companyId: scopedCompanyId,
61
+ companyId,
68
62
  query: trimmedQuery,
69
63
  });
70
64
  if (!cancelled) {
71
- setResults(filterProductsByCompany(items, scopedCompanyId));
65
+ setResults(Array.isArray(items) ? items : []);
72
66
  }
73
67
  } catch {
74
68
  if (!cancelled) {
@@ -85,7 +79,7 @@ export const useProductBrowser = ({companyId, visible}) => {
85
79
  cancelled = true;
86
80
  clearTimeout(timeoutId);
87
81
  };
88
- }, [scopedCompanyId, query, visible]);
82
+ }, [companyId, query, visible]);
89
83
 
90
84
  useEffect(() => {
91
85
  if (!visible) {
@@ -111,33 +105,126 @@ export const ProductSelectionModal = ({
111
105
  palette,
112
106
  styles,
113
107
  globalStyles,
114
- }) => (
115
- <SelectionModal
116
- visible={visible}
117
- title={title}
118
- helperText={helperText}
119
- browser={browser}
120
- globalStyles={globalStyles}
121
- onClose={onClose}
122
- onSelect={onSelect}
123
- selectedIds={selectedIds}
124
- selectedItemId={selectedItemId}
125
- multiSelect={multiSelect}
126
- emptyIconName="inventory-2"
127
- emptyTitle="Nenhum produto encontrado"
128
- emptyText="Tente outro termo para localizar um produto existente."
129
- resolveItemId={normalizeShopProductId}
130
- resolveItemLabel={resolveProductLabel}
131
- resolveItemMeta={product =>
132
- resolveProductMeta(product) || 'Toque para selecionar'
133
- }
134
- searchPlaceholder="Pesquisar produto..."
135
- selectionMeta={() =>
136
- multiSelect
137
- ? 'Selecionado para participar da fidelidade'
138
- : 'Selecionado como brinde'
139
- }
140
- palette={palette}
141
- styles={styles}
142
- />
143
- );
108
+ }) => {
109
+ const selectedSet = selectedIds || new Set();
110
+ const selectedId = String(selectedItemId || '').trim();
111
+
112
+ return (
113
+ <AnimatedModal visible={visible} onRequestClose={onClose}>
114
+ <View style={styles.selectionModal}>
115
+ <View style={styles.selectionModalHeader}>
116
+ <View style={styles.selectionModalHeaderCopy}>
117
+ <Text style={styles.selectionModalTitle}>{title}</Text>
118
+ {helperText ? (
119
+ <Text style={styles.selectionModalSubtitle}>{helperText}</Text>
120
+ ) : null}
121
+ </View>
122
+ <TouchableOpacity
123
+ style={styles.selectionModalClose}
124
+ onPress={onClose}
125
+ activeOpacity={0.85}>
126
+ <Icon name="close" size={20} color={palette.iconDefault} />
127
+ </TouchableOpacity>
128
+ </View>
129
+
130
+ <View style={styles.selectorRow}>
131
+ <Icon
132
+ name="search"
133
+ size={18}
134
+ color={palette.iconMuted}
135
+ style={{marginRight: 8}}
136
+ />
137
+ <TextInput
138
+ value={browser.query}
139
+ onChangeText={browser.setQuery}
140
+ placeholder="Pesquisar produto..."
141
+ placeholderTextColor={palette.inputPlaceholderText}
142
+ style={[styles.input, styles.selectorInput, {flex: 1}]}
143
+ returnKeyType="search"
144
+ />
145
+ </View>
146
+
147
+ <ScrollView
148
+ style={styles.selectionModalList}
149
+ contentContainerStyle={styles.selectionModalListContent}
150
+ keyboardShouldPersistTaps="handled">
151
+ {browser.isLoading ? (
152
+ <ActivityIndicator
153
+ size="small"
154
+ color={palette.loadingSpinner}
155
+ style={styles.sectionLoader}
156
+ />
157
+ ) : browser.results.length === 0 ? (
158
+ <View style={styles.searchEmptyState}>
159
+ <Icon name="inventory-2" size={28} color={palette.iconMuted} />
160
+ <Text style={styles.searchEmptyStateTitle}>
161
+ Nenhum produto encontrado
162
+ </Text>
163
+ <Text style={styles.searchEmptyStateText}>
164
+ {String(browser.query || '').trim()
165
+ ? 'Tente outro termo para localizar um produto existente.'
166
+ : 'Nenhum item disponível apareceu para seleção.'}
167
+ </Text>
168
+ </View>
169
+ ) : (
170
+ browser.results.map(item => {
171
+ const itemId = normalizeShopProductId(item);
172
+ const selected = multiSelect
173
+ ? selectedSet.has(itemId)
174
+ : itemId === selectedId;
175
+
176
+ return (
177
+ <TouchableOpacity
178
+ key={`loyalty-picker-${itemId}`}
179
+ style={[
180
+ styles.selectionModalItem,
181
+ selected && styles.selectionModalItemActive,
182
+ ]}
183
+ activeOpacity={0.85}
184
+ onPress={() => onSelect(item)}>
185
+ <Icon
186
+ name={
187
+ selected
188
+ ? multiSelect
189
+ ? 'check-circle'
190
+ : 'radio-button-checked'
191
+ : multiSelect
192
+ ? 'add-circle-outline'
193
+ : 'radio-button-unchecked'
194
+ }
195
+ size={20}
196
+ color={selected ? palette.iconActive : palette.iconDisabled}
197
+ />
198
+ <View style={styles.selectionModalItemCopy}>
199
+ <Text style={styles.selectionModalItemTitle}>
200
+ {resolveProductLabel(item)}
201
+ </Text>
202
+ <Text style={styles.selectionModalItemMeta}>
203
+ {selected
204
+ ? multiSelect
205
+ ? 'Selecionado para participar da fidelidade'
206
+ : 'Selecionado como brinde'
207
+ : resolveProductMeta(item) || 'Toque para selecionar'}
208
+ </Text>
209
+ </View>
210
+ </TouchableOpacity>
211
+ );
212
+ })
213
+ )}
214
+ </ScrollView>
215
+
216
+ {multiSelect ? (
217
+ <TouchableOpacity
218
+ style={[
219
+ globalStyles.button,
220
+ styles.primaryButton,
221
+ styles.selectionModalActionButton,
222
+ ]}
223
+ onPress={onClose}>
224
+ <Text style={styles.primaryButtonText}>Concluir seleção</Text>
225
+ </TouchableOpacity>
226
+ ) : null}
227
+ </View>
228
+ </AnimatedModal>
229
+ );
230
+ };
@@ -37,7 +37,6 @@ import {
37
37
  ProductSelectionModal,
38
38
  resolveProductLabel,
39
39
  resolveProductMeta,
40
- resolveProductMetaParts,
41
40
  useProductBrowser,
42
41
  } from './LoyaltyProductPicker';
43
42
 
@@ -47,7 +46,7 @@ const LoyaltySection = () => {
47
46
  const {globalStyles} = css();
48
47
  const palette = useGeneralSettingsPalette();
49
48
  const styles = useGeneralSettingsStyles();
50
- const {currentCompany, effectiveCompanyConfigs, saveConfig, selectedCompanyId} =
49
+ const {currentCompany, effectiveCompanyConfigs, saveConfig} =
51
50
  useGeneralSettingsConfig();
52
51
  const productActions = useStore('products').actions;
53
52
 
@@ -63,11 +62,11 @@ const LoyaltySection = () => {
63
62
  const [giftVisible, setGiftVisible] = useState(false);
64
63
 
65
64
  const participantsBrowser = useProductBrowser({
66
- companyId: selectedCompanyId || currentCompany?.id,
65
+ companyId: currentCompany?.id,
67
66
  visible: participantsVisible,
68
67
  });
69
68
  const giftBrowser = useProductBrowser({
70
- companyId: selectedCompanyId || currentCompany?.id,
69
+ companyId: currentCompany?.id,
71
70
  visible: giftVisible,
72
71
  });
73
72
 
@@ -340,26 +339,13 @@ const LoyaltySection = () => {
340
339
  color={palette.iconDanger}
341
340
  />
342
341
  <View style={styles.printerCopy}>
343
- <Text style={styles.printerName} numberOfLines={2}>
342
+ <Text style={styles.printerName}>
344
343
  {resolveProductLabel(product)}
345
344
  </Text>
346
- <Text style={styles.printerDevice} numberOfLines={1}>
347
- {resolveProductMetaParts(product).metaLine ||
348
- resolveProductMetaParts(product).sku ||
349
- 'Toque para remover'}
345
+ <Text style={styles.printerDevice}>
346
+ {resolveProductMeta(product) || 'Toque para remover'}
350
347
  </Text>
351
348
  </View>
352
- {!!resolveProductMetaParts(product).priceLabel && (
353
- <Text
354
- style={{
355
- fontSize: 13,
356
- fontWeight: '700',
357
- color: palette.iconSuccess || palette.success,
358
- marginLeft: 8,
359
- }}>
360
- {resolveProductMetaParts(product).priceLabel}
361
- </Text>
362
- )}
363
349
  </TouchableOpacity>
364
350
  );
365
351
  })}
@@ -410,26 +396,14 @@ const LoyaltySection = () => {
410
396
  color={palette.iconActive}
411
397
  />
412
398
  <View style={styles.printerCopy}>
413
- <Text style={styles.printerName} numberOfLines={2}>
399
+ <Text style={styles.printerName}>
414
400
  {resolveProductLabel(selectedGiftProduct)}
415
401
  </Text>
416
- <Text style={styles.printerDevice} numberOfLines={1}>
417
- {resolveProductMetaParts(selectedGiftProduct).metaLine ||
418
- resolveProductMetaParts(selectedGiftProduct).sku ||
402
+ <Text style={styles.printerDevice}>
403
+ {resolveProductMeta(selectedGiftProduct) ||
419
404
  `ID ${giftProductId}`}
420
405
  </Text>
421
406
  </View>
422
- {!!resolveProductMetaParts(selectedGiftProduct).priceLabel && (
423
- <Text
424
- style={{
425
- fontSize: 13,
426
- fontWeight: '700',
427
- color: palette.iconSuccess || palette.success,
428
- marginLeft: 8,
429
- }}>
430
- {resolveProductMetaParts(selectedGiftProduct).priceLabel}
431
- </Text>
432
- )}
433
407
  </View>
434
408
  </View>
435
409
  ) : (
@@ -26,16 +26,16 @@ const MaintenanceSection = () => {
26
26
  const themePalette = useGeneralSettingsPalette();
27
27
  const {showError, showSuccess} = useToastMessage();
28
28
  const {
29
- mainCompany,
30
- mainCompanyLabel,
31
- hasMainCompanyAccess,
29
+ defaultCompany,
30
+ defaultCompanyLabel,
31
+ hasDefaultCompanyAccess,
32
32
  isMainCompanySelected,
33
33
  isSaving,
34
34
  peopleActions,
35
35
  saveConfigs,
36
36
  } = useGeneralSettingsConfig();
37
37
  const [routines, setRoutines] = useState(
38
- normalizeMaintenanceRoutines(mainCompany?.configs?.[
38
+ normalizeMaintenanceRoutines(defaultCompany?.configs?.[
39
39
  MAINTENANCE_ROUTINES_CONFIG_KEY
40
40
  ]),
41
41
  );
@@ -43,22 +43,22 @@ const MaintenanceSection = () => {
43
43
  useEffect(() => {
44
44
  setRoutines(
45
45
  normalizeMaintenanceRoutines(
46
- mainCompany?.configs?.[MAINTENANCE_ROUTINES_CONFIG_KEY],
46
+ defaultCompany?.configs?.[MAINTENANCE_ROUTINES_CONFIG_KEY],
47
47
  ),
48
48
  );
49
- }, [mainCompany?.configs]);
49
+ }, [defaultCompany?.configs]);
50
50
 
51
51
  const editable =
52
- hasMainCompanyAccess &&
53
- !!mainCompany?.id &&
52
+ hasDefaultCompanyAccess &&
53
+ !!defaultCompany?.id &&
54
54
  isMainCompanySelected &&
55
55
  !isSaving;
56
56
 
57
57
  const saveRoutines = useCallback(
58
58
  async (nextRoutines = routines) => {
59
- if (!hasMainCompanyAccess || !mainCompany?.id || !isMainCompanySelected) {
59
+ if (!hasDefaultCompanyAccess || !defaultCompany?.id || !isMainCompanySelected) {
60
60
  showError(
61
- `Abra a empresa principal (${mainCompanyLabel}) para editar as rotinas.`,
61
+ `Abra a empresa principal (${defaultCompanyLabel}) para editar as rotinas.`,
62
62
  );
63
63
  return;
64
64
  }
@@ -87,16 +87,16 @@ const MaintenanceSection = () => {
87
87
  }
88
88
 
89
89
  try {
90
- await peopleActions.mainCompany();
90
+ await peopleActions.defaultCompany();
91
91
  } catch {}
92
92
 
93
93
  showSuccess('Rotinas de manutencao salvas com sucesso.');
94
94
  return true;
95
95
  },
96
96
  [
97
- mainCompany?.id,
98
- mainCompanyLabel,
99
- hasMainCompanyAccess,
97
+ defaultCompany?.id,
98
+ defaultCompanyLabel,
99
+ hasDefaultCompanyAccess,
100
100
  isMainCompanySelected,
101
101
  peopleActions,
102
102
  routines,
@@ -133,10 +133,10 @@ const MaintenanceSection = () => {
133
133
  iconColor={themePalette.cardIconColor}
134
134
  title="Rotinas de manutencao">
135
135
  <Text style={localStyles.helperText}>
136
- {`Essas rotinas ficam gravadas na empresa principal (${mainCompanyLabel}) e o cron geral tenta executa-las a cada minuto.`}
136
+ {`Essas rotinas ficam gravadas na empresa principal (${defaultCompanyLabel}) e o cron geral tenta executa-las a cada minuto.`}
137
137
  </Text>
138
138
 
139
- {!isMainCompanySelected && hasMainCompanyAccess && (
139
+ {!isMainCompanySelected && hasDefaultCompanyAccess && (
140
140
  <Text style={localStyles.helperText}>
141
141
  Abra a empresa principal para editar a agenda. Fora dela esta tela
142
142
  fica somente para consulta.