@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
@@ -29,25 +29,16 @@ export const resolveProductLabel = product => {
29
29
  );
30
30
  };
31
31
 
32
- export const resolveProductMetaParts = product => {
32
+ export const resolveProductMeta = product => {
33
33
  const sku = String(product?.sku || '').trim();
34
34
  const price = Number(product?.price || 0);
35
- const priceLabel =
36
- Number.isFinite(price) && price > 0
37
- ? `R$ ${price.toFixed(2).replace('.', ',')}`
38
- : '';
39
-
40
- return {
41
- sku: sku ? `SKU ${sku}` : '',
42
- priceLabel,
43
- metaLine: [sku ? `SKU ${sku}` : null].filter(Boolean).join(' • '),
44
- };
45
- };
35
+ const priceLabel = Number.isFinite(price)
36
+ ? `R$ ${price.toFixed(2).replace('.', ',')}`
37
+ : '';
46
38
 
47
- /** Prefer resolveProductMetaParts when layout needs price separated. */
48
- export const resolveProductMeta = product => {
49
- const {sku, priceLabel} = resolveProductMetaParts(product);
50
- return [sku || null, priceLabel || null].filter(Boolean).join(' • ');
39
+ return [sku ? `SKU ${sku}` : null, price > 0 ? priceLabel : null]
40
+ .filter(Boolean)
41
+ .join(' • ');
51
42
  };
52
43
 
53
44
  export const resolveCompanyLabel = company =>
@@ -401,29 +392,17 @@ export const SelectionModal = ({
401
392
  color={selected ? palette.iconActive : palette.iconDisabled}
402
393
  />
403
394
  <View style={styles.selectionModalItemCopy}>
404
- <Text style={styles.selectionModalItemTitle} numberOfLines={2}>
395
+ <Text style={styles.selectionModalItemTitle}>
405
396
  {resolveItemLabel(item)}
406
397
  </Text>
407
- <Text style={styles.selectionModalItemMeta} numberOfLines={1}>
398
+ <Text style={styles.selectionModalItemMeta}>
408
399
  {(selected
409
400
  ? selectionMeta?.(item, {selected, multiSelect})
410
401
  : null) ||
411
- resolveProductMetaParts(item).metaLine ||
412
- resolveProductMetaParts(item).sku ||
402
+ resolveItemMeta(item) ||
413
403
  'Toque para selecionar'}
414
404
  </Text>
415
405
  </View>
416
- {!!resolveProductMetaParts(item).priceLabel && (
417
- <Text
418
- style={{
419
- fontSize: 13,
420
- fontWeight: '700',
421
- color: palette.iconSuccess || palette.success,
422
- marginLeft: 8,
423
- }}>
424
- {resolveProductMetaParts(item).priceLabel}
425
- </Text>
426
- )}
427
406
  </TouchableOpacity>
428
407
  );
429
408
  })
@@ -438,7 +417,7 @@ export const SelectionModal = ({
438
417
  styles.selectionModalActionButton,
439
418
  ]}
440
419
  onPress={onClose}>
441
- <Text style={styles.primaryButtonText}>Concluir seleção</Text>
420
+ <Text style={styles.primaryButtonText}>Concluir selecao</Text>
442
421
  </TouchableOpacity>
443
422
  )}
444
423
  </View>
@@ -6,6 +6,7 @@ import CrmIndex from '@controleonline/ui-crm/src/react/pages/crm/index';
6
6
  import ProposalsPage from '../pages/proposals';
7
7
  import CrmConversation from '../pages/crm/conversation';
8
8
  import GeneralSettings from '../pages/settings/GeneralSettings';
9
+ import McpPage from '../pages/mcp/McpPage';
9
10
  import ProposalDetails from '../pages/proposals/ProposalDetails';
10
11
 
11
12
  const crmRoutes = [
@@ -120,6 +121,19 @@ const crmRoutes = [
120
121
  title: 'Propostas',
121
122
  },
122
123
  },
124
+ {
125
+ name: 'McpPage',
126
+ component: McpPage,
127
+ path: 'mcp',
128
+ options: {
129
+ showCompanyFilter: true,
130
+ showBottomToolBar: true,
131
+ headerShown: true,
132
+ headerBackVisible: true,
133
+ companyFilterMode: 'icon',
134
+ title: 'Chat IA / MCP',
135
+ },
136
+ },
123
137
  {
124
138
  name: 'CrmConversation',
125
139
  component: CrmConversation,
@@ -24,102 +24,20 @@ const normalizeEntityId = value => {
24
24
  return String(value);
25
25
  };
26
26
 
27
- /**
28
- * Resolve a category id from common payload shapes:
29
- * - plain id / IRI / Category object
30
- * - product.category (legacy / sparse payloads)
31
- * - product.productCategory[] (ProductCategory join entities)
32
- * - nested { category: ... } wrappers
33
- */
34
- const normalizeCategoryId = value => {
35
- if (value === null || value === undefined || value === '') {
36
- return null;
37
- }
38
-
39
- if (Array.isArray(value)) {
40
- for (const entry of value) {
41
- const resolved = normalizeCategoryId(entry);
42
- if (resolved) {
43
- return resolved;
44
- }
45
- }
46
- return null;
47
- }
48
-
49
- if (typeof value === 'object') {
50
- // ProductCategory join: { category: Category|IRI, product: ... }
51
- if (value.category !== undefined && value.category !== null) {
52
- return normalizeCategoryId(value.category);
53
- }
54
-
55
- // Category entity or sparse object
56
- if (value.parent !== undefined && value.parent !== null && !value['@id'] && !value.id) {
57
- return normalizeCategoryId(value.parent);
58
- }
59
-
60
- return normalizeEntityId(value['@id'] || value.id || value.value || value.parent);
61
- }
62
-
63
- return normalizeEntityId(value);
64
- };
65
-
66
- const collectProductCategoryIds = product => {
67
- const ids = new Set();
68
-
69
- const pushId = candidate => {
70
- const id = normalizeCategoryId(candidate);
71
- if (id) {
72
- ids.add(id);
73
- }
74
- };
75
-
76
- if (!product || typeof product !== 'object') {
77
- return ids;
78
- }
79
-
80
- // Legacy / sparse single category field
81
- pushId(product.category);
82
-
83
- // Canonical join collection from Product::productCategory
84
- const joinCollection =
85
- product.productCategory ||
86
- product.productCategories ||
87
- product.categories ||
88
- product.product_category;
89
-
90
- if (Array.isArray(joinCollection)) {
91
- joinCollection.forEach(entry => {
92
- pushId(entry);
93
- pushId(entry?.category);
94
- });
95
- } else if (joinCollection) {
96
- pushId(joinCollection);
97
- pushId(joinCollection?.category);
98
- }
99
-
100
- return ids;
101
- };
27
+ const normalizeCategoryId = value =>
28
+ normalizeEntityId(
29
+ value?.category ||
30
+ value?.parent ||
31
+ value?.['@id'] ||
32
+ value?.id ||
33
+ value,
34
+ );
102
35
 
103
36
  const getProposalModelCategoryId = model => normalizeCategoryId(model?.category);
104
37
 
105
38
  const getProposalModelCategoryName = model =>
106
39
  String(model?.category?.name || model?.category?.category || '').trim();
107
40
 
108
- const productMatchesModelCategory = (product, selectedModelCategoryId) => {
109
- if (!selectedModelCategoryId) {
110
- return true;
111
- }
112
-
113
- const productCategoryIds = collectProductCategoryIds(product);
114
- if (productCategoryIds.size === 0) {
115
- // When the payload does not embed categories, do not client-side-reject:
116
- // the API filter (productCategory.category) is the source of truth.
117
- return true;
118
- }
119
-
120
- return productCategoryIds.has(String(selectedModelCategoryId));
121
- };
122
-
123
41
  const filterProductsByModelCategory = ({ products, selectedModelCategoryId }) => {
124
42
  const normalizedProducts = Array.isArray(products) ? products : [];
125
43
 
@@ -127,8 +45,8 @@ const filterProductsByModelCategory = ({ products, selectedModelCategoryId }) =>
127
45
  return normalizedProducts;
128
46
  }
129
47
 
130
- return normalizedProducts.filter(product =>
131
- productMatchesModelCategory(product, selectedModelCategoryId),
48
+ return normalizedProducts.filter(
49
+ product => normalizeCategoryId(product?.category) === selectedModelCategoryId,
132
50
  );
133
51
  };
134
52
 
@@ -137,25 +55,17 @@ const keepCompatibleSelectedProducts = ({ selectedProducts, selectedModelCategor
137
55
  return Array.isArray(selectedProducts) ? selectedProducts : [];
138
56
  }
139
57
 
140
- const list = Array.isArray(selectedProducts) ? selectedProducts : [];
141
-
142
- return list.filter(product => {
143
- const productCategoryIds = collectProductCategoryIds(product);
144
- // Keep selection when we cannot prove incompatibility from sparse payload
145
- if (productCategoryIds.size === 0) {
146
- return true;
147
- }
148
- return productCategoryIds.has(String(selectedModelCategoryId));
58
+ return filterProductsByModelCategory({
59
+ products: selectedProducts,
60
+ selectedModelCategoryId,
149
61
  });
150
62
  };
151
63
 
152
64
  module.exports = {
153
- collectProductCategoryIds,
154
65
  filterProductsByModelCategory,
155
66
  getProposalModelCategoryId,
156
67
  getProposalModelCategoryName,
157
68
  keepCompatibleSelectedProducts,
158
69
  normalizeCategoryId,
159
70
  normalizeEntityId,
160
- productMatchesModelCategory,
161
71
  };
@@ -96,15 +96,6 @@ const productGeral = {
96
96
  price: 50,
97
97
  };
98
98
 
99
- // Real API shape: Product has productCategory[] join, not product.category
100
- const productServicoJoin = {
101
- id: 103,
102
- name: 'Serviço via productCategory',
103
- '@id': '/products/103',
104
- productCategory: [{ category: categoryServicos }],
105
- price: 150,
106
- };
107
-
108
99
  test.describe('Create proposal — product filter by model category (#85)', () => {
109
100
  test('filters products by selected model category and clears incompatible selections', async ({
110
101
  page,
@@ -154,21 +145,5 @@ test.describe('Create proposal — product filter by model category (#85)', () =
154
145
  selectedModelCategoryId: consultCatId,
155
146
  });
156
147
  expect(kept.map(p => p.id)).toEqual([101]);
157
-
158
- // productCategory join (canonical API shape) must match model category
159
- const filteredJoin = filterProductsByModelCategory({
160
- products: [productServicoJoin, productConsultoria],
161
- selectedModelCategoryId: servicosCatId,
162
- });
163
- expect(filteredJoin.map(p => p.id)).toEqual([103]);
164
-
165
- // Sparse payload (no embedded categories) is kept — API filter is source of truth
166
- const sparse = [{ id: 200, '@id': '/products/200' }];
167
- expect(
168
- filterProductsByModelCategory({
169
- products: sparse,
170
- selectedModelCategoryId: servicosCatId,
171
- }),
172
- ).toHaveLength(1);
173
148
  });
174
149
  });