@controleonline/ui-common 1.2.134 → 1.2.135
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/.release/rc-manifest.json +12 -5
- package/package.json +6 -2
- package/src/react/components/CategoryForm.js +539 -539
- package/src/react/components/DefaultProvider.native.js +2 -2
- package/src/react/components/DefaultProvider.web.js +2 -2
- package/src/react/components/LinkedOrderProductsTab.js +17 -8
- package/src/react/components/LinkedOrderProductsTab.styles.js +15 -0
- package/src/react/components/documentDetails/DocumentDetailsShell.js +147 -0
- package/src/react/components/documentDetails/DocumentDetailsShell.styles.js +163 -0
- package/src/react/components/documentDetails/DocumentSheet.js +87 -0
- package/src/react/components/integrations/IntegrationHero/index.js +1 -1
- package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
- package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
- package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
- package/src/react/hooks/useLinkedOrderSummary.js +41 -0
- package/src/react/pages/Connections.styles.js +72 -72
- package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
- package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
- package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
- package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
- package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
- package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
- package/src/react/pages/Devices.js +2 -2
- package/src/react/pages/Devices.styles.js +353 -353
- package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
- package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
- package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
- package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
- package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
- package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
- package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
- package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
- package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
- package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
- package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
- package/src/react/pages/Imports.js +1 -1
- package/src/react/pages/Imports.styles.js +223 -223
- package/src/react/pages/IntegrationConfigPage.js +2 -2
- package/src/react/pages/Integrations.js +2 -15
- package/src/react/pages/Integrations.styles.js +130 -130
- package/src/react/pages/LinkedInIntegrationPage.js +2 -2
- package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
- package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
- package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
- package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
- package/src/react/pages/PrinterDeviceFormPage.js +2 -2
- package/src/react/pages/WhatsAppConnectionPage.styles.js +315 -279
- package/src/react/pages/WhatsAppProviderForm.js +1 -1
- package/src/react/pages/whatsAppConnectionHelpers.js +38 -10
- package/src/react/router/__tests__/publicRoutes.test.js +12 -0
- package/src/react/router/publicRoutes.js +3 -0
- package/src/react/utils/clientPortfolioParams.js +42 -0
- package/src/react/utils/commercialDocumentOrders.js +13 -20
- package/src/react/utils/documentFileContent.js +61 -0
- package/src/react/utils/fileUrl.js +1 -1
- package/src/react/utils/linkedOrderPayload.js +43 -0
- package/src/react/utils/orderProductsSummary.js +28 -0
- package/src/react/utils/peopleDisplay.js +8 -13
- package/src/store/connections/customActions.js +16 -14
- package/src/store/connections/index.js +109 -105
- package/src/tests/react/utils/clientPortfolioParams.test.js +30 -0
- package/src/tests/react/utils/documentFileContent.test.js +29 -0
- package/src/tests/react/utils/linkedOrderPayload.test.js +46 -0
- package/src/tests/react/utils/orderProductsSummary.test.js +24 -0
|
@@ -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
|
+
});
|