@controleonline/ui-common 1.2.134 → 1.2.136

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 (68) hide show
  1. package/.release/rc-manifest.json +5 -5
  2. package/package.json +7 -2
  3. package/src/react/components/CategoryForm.js +539 -539
  4. package/src/react/components/DefaultProvider.native.js +2 -2
  5. package/src/react/components/DefaultProvider.web.js +2 -2
  6. package/src/react/components/LinkedOrderProductsTab.js +17 -8
  7. package/src/react/components/LinkedOrderProductsTab.styles.js +15 -0
  8. package/src/react/components/RuntimeInfoFooter.js +26 -6
  9. package/src/react/components/documentDetails/DocumentDetailsShell.js +147 -0
  10. package/src/react/components/documentDetails/DocumentDetailsShell.styles.js +163 -0
  11. package/src/react/components/documentDetails/DocumentSheet.js +87 -0
  12. package/src/react/components/integrations/IntegrationHero/index.js +1 -1
  13. package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
  14. package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
  15. package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
  16. package/src/react/hooks/useLinkedOrderSummary.js +41 -0
  17. package/src/react/pages/Connections.styles.js +72 -72
  18. package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
  19. package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
  20. package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
  21. package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
  22. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
  23. package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
  24. package/src/react/pages/Devices.js +2 -2
  25. package/src/react/pages/Devices.styles.js +353 -353
  26. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
  27. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
  28. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
  29. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
  30. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
  31. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
  32. package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
  33. package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
  34. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
  35. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
  36. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
  37. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
  38. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
  39. package/src/react/pages/Imports.js +1 -1
  40. package/src/react/pages/Imports.styles.js +223 -223
  41. package/src/react/pages/IntegrationConfigPage.js +2 -2
  42. package/src/react/pages/Integrations.js +2 -15
  43. package/src/react/pages/Integrations.styles.js +130 -130
  44. package/src/react/pages/LinkedInIntegrationPage.js +2 -2
  45. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
  46. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
  47. package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
  48. package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
  49. package/src/react/pages/PrinterDeviceFormPage.js +2 -2
  50. package/src/react/pages/WhatsAppConnectionPage.styles.js +315 -279
  51. package/src/react/pages/WhatsAppProviderForm.js +1 -1
  52. package/src/react/pages/whatsAppConnectionHelpers.js +38 -10
  53. package/src/react/router/__tests__/publicRoutes.test.js +12 -0
  54. package/src/react/router/publicRoutes.js +3 -0
  55. package/src/react/utils/clientPortfolioParams.js +42 -0
  56. package/src/react/utils/commercialDocumentOrders.js +13 -20
  57. package/src/react/utils/documentFileContent.js +61 -0
  58. package/src/react/utils/fileUrl.js +1 -1
  59. package/src/react/utils/linkedOrderPayload.js +43 -0
  60. package/src/react/utils/orderProductsSummary.js +28 -0
  61. package/src/react/utils/peopleDisplay.js +8 -13
  62. package/src/store/connections/customActions.js +16 -14
  63. package/src/store/connections/index.js +109 -105
  64. package/src/tests/react/components/RuntimeInfoFooter.platform.contract.test.mjs +24 -0
  65. package/src/tests/react/utils/clientPortfolioParams.test.js +30 -0
  66. package/src/tests/react/utils/documentFileContent.test.js +29 -0
  67. package/src/tests/react/utils/linkedOrderPayload.test.js +46 -0
  68. package/src/tests/react/utils/orderProductsSummary.test.js +24 -0
@@ -0,0 +1,24 @@
1
+ import test from 'node:test';
2
+ import assert from 'node:assert/strict';
3
+ import {readFileSync} from 'node:fs';
4
+
5
+ const source = readFileSync(
6
+ new URL('../../../react/components/RuntimeInfoFooter.js', import.meta.url),
7
+ 'utf8',
8
+ );
9
+
10
+ test('footer rotates every 4s only on web', () => {
11
+ assert.match(source, /ROTATION_INTERVAL_MS = 4000/);
12
+ assert.match(source, /const isWeb = Platform\.OS === 'web'/);
13
+ assert.match(source, /shouldRotate = isWeb && !showDebugInfo && rotationEntries\.length > 1/);
14
+ assert.match(source, /setInterval\([\s\S]*ROTATION_INTERVAL_MS\)/);
15
+ });
16
+
17
+ test('footer is a continuous ticker only on mobile (native)', () => {
18
+ assert.match(source, /continuous=\{!isWeb\}/);
19
+ assert.match(source, /getRuntimeFooterTickerText/);
20
+ });
21
+
22
+ test('footer hooks run before the early return', () => {
23
+ assert.ok(source.indexOf('useEffect(() => {\n if (!shouldRotate)') < source.indexOf('if (rotationEntries.length === 0 && !showDebugInfo)'));
24
+ });
@@ -0,0 +1,30 @@
1
+ const test = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const { resolveClientPortfolioParams } = require('../../../react/utils/clientPortfolioParams');
4
+
5
+ test('seller only sees his own portfolio', () => {
6
+ assert.deepEqual(
7
+ resolveClientPortfolioParams({ currentCompanyId: 1, permissions: ['salesman'], sellerPeopleId: 31487 }),
8
+ { 'link.company': '/people/31487', 'link.linkType': 'sellers-client' },
9
+ );
10
+ });
11
+
12
+ test('owners and managers see every company client', () => {
13
+ const expected = { 'link.company': '/people/1', 'link.linkType': 'client' };
14
+ assert.deepEqual(
15
+ resolveClientPortfolioParams({ currentCompanyId: 1, permissions: ['salesman', 'owner'], sellerPeopleId: 7 }),
16
+ expected,
17
+ );
18
+ assert.deepEqual(
19
+ resolveClientPortfolioParams({ currentCompanyId: '/people/1', permissions: 'manager', sellerPeopleId: 7 }),
20
+ expected,
21
+ );
22
+ });
23
+
24
+ test('without seller data falls back to company clients, without company returns null', () => {
25
+ assert.deepEqual(
26
+ resolveClientPortfolioParams({ currentCompanyId: 1, permissions: ['salesman'] }),
27
+ { 'link.company': '/people/1', 'link.linkType': 'client' },
28
+ );
29
+ assert.equal(resolveClientPortfolioParams({ permissions: ['salesman'], sellerPeopleId: 1 }), null);
30
+ });
@@ -0,0 +1,29 @@
1
+ const test = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const { resolveDocumentFileContent } = require('../../../react/utils/documentFileContent');
4
+
5
+ const toBase64 = text => Buffer.from(text, 'utf8').toString('base64');
6
+
7
+ test('decodes base64 HTML documents returned by the files API', () => {
8
+ const html = '<h1>Proposta</h1><p>Codex — R$ 260,00 (ação)</p>';
9
+ assert.deepEqual(resolveDocumentFileContent(toBase64(html)), { kind: 'html', content: html });
10
+ });
11
+
12
+ test('keeps plain HTML as is', () => {
13
+ assert.deepEqual(resolveDocumentFileContent(' <p>ok</p>'), { kind: 'html', content: ' <p>ok</p>' });
14
+ });
15
+
16
+ test('plain-text models are returned decoded as text', () => {
17
+ const text = 'CONTRATO PADRÃO\nCláusula 1 – <nome_contratante> & mais';
18
+ assert.deepEqual(resolveDocumentFileContent(toBase64(text)), { kind: 'text', content: text });
19
+ });
20
+
21
+ test('PDF payloads stay base64 for the viewer', () => {
22
+ const pdf = Buffer.from('%PDF-1.7\n\xff\xfe binary', 'binary').toString('base64');
23
+ assert.deepEqual(resolveDocumentFileContent(pdf), { kind: 'pdf', content: pdf });
24
+ });
25
+
26
+ test('empty contents', () => {
27
+ assert.deepEqual(resolveDocumentFileContent(''), { kind: 'empty', content: '' });
28
+ assert.deepEqual(resolveDocumentFileContent(null), { kind: 'empty', content: '' });
29
+ });
@@ -0,0 +1,46 @@
1
+ const test = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const {
4
+ LINKED_ORDER_TYPE,
5
+ buildLinkedOrderPayload,
6
+ } = require('../../../react/utils/linkedOrderPayload');
7
+
8
+ test('linked commercial orders start as cart so products can be edited', () => {
9
+ assert.equal(LINKED_ORDER_TYPE, 'cart');
10
+ const payload = buildLinkedOrderPayload({
11
+ contractIri: '/contracts/27',
12
+ providerIri: '/people/1',
13
+ statusIri: '/statuses/119',
14
+ clientIri: '/people/105792',
15
+ });
16
+
17
+ assert.deepEqual(payload, {
18
+ app: 'CRM',
19
+ orderType: 'cart',
20
+ contract: '/contracts/27',
21
+ provider: '/people/1',
22
+ status: '/statuses/119',
23
+ client: '/people/105792',
24
+ payer: '/people/105792',
25
+ });
26
+ });
27
+
28
+ test('empty orderType falls back to cart instead of being sent blank', () => {
29
+ assert.equal(buildLinkedOrderPayload({orderType: ''}).orderType, 'cart');
30
+ assert.equal(buildLinkedOrderPayload({orderType: null}).orderType, 'cart');
31
+ });
32
+
33
+ test('explicit payer wins over client and optional refs are omitted', () => {
34
+ const payload = buildLinkedOrderPayload({
35
+ contractIri: '/contracts/1',
36
+ providerIri: '/people/1',
37
+ clientIri: '/people/2',
38
+ payerIri: '/people/3',
39
+ });
40
+ assert.equal(payload.payer, '/people/3');
41
+ assert.equal('status' in payload, false);
42
+
43
+ const withoutParties = buildLinkedOrderPayload({contractIri: '/contracts/1'});
44
+ assert.equal('client' in withoutParties, false);
45
+ assert.equal('payer' in withoutParties, false);
46
+ });
@@ -0,0 +1,24 @@
1
+ const test = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+ const { formatBRL, summarizeOrderProducts } = require('../../../react/utils/orderProductsSummary');
4
+
5
+ test('sums only top-level lines', () => {
6
+ const items = [
7
+ { id: 1, quantity: 2, price: 130, total: 260 },
8
+ { id: 2, quantity: 1, price: 0.01, total: 0.01 },
9
+ { id: 3, quantity: 1, price: 10, total: 10, orderProduct: '/order_products/1' },
10
+ ];
11
+ assert.deepEqual(summarizeOrderProducts(items), { count: 2, total: 260.01 });
12
+ });
13
+
14
+ test('falls back to price x quantity and handles empty input', () => {
15
+ assert.deepEqual(summarizeOrderProducts([{ quantity: 3, price: 2.5 }]), { count: 1, total: 7.5 });
16
+ assert.deepEqual(summarizeOrderProducts(null), { count: 0, total: 0 });
17
+ });
18
+
19
+ test('formats Brazilian currency', () => {
20
+ assert.equal(formatBRL(1260), 'R$ 1.260,00');
21
+ assert.equal(formatBRL(260.01), 'R$ 260,01');
22
+ assert.equal(formatBRL(0), 'R$ 0,00');
23
+ assert.equal(formatBRL(1234567.8), 'R$ 1.234.567,80');
24
+ });