@controleonline/ui-crm 1.0.42 → 1.0.44
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 +82 -0
- package/.github/workflows/manager-worker.yml +7 -155
- package/.github/workflows/publish-npm.yml +73 -22
- package/AGENTS.md +2 -0
- package/package.json +2 -2
- package/src/react/pages/crm/hooks/useCrmData.js +23 -17
- package/src/react/pages/proposals/CreateProposalsModal.js +1 -0
- package/src/react/pages/proposals/index.js +14 -33
- package/src/react/pages/settings/GeneralSettings.styles.js +2 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +58 -145
- package/src/react/pages/settings/sections/LoyaltySection.js +35 -9
- package/src/react/pages/settings/sections/MapsFranchisePreview.js +102 -0
- package/src/react/pages/settings/sections/MapsMapasControls.js +262 -0
- package/src/react/pages/settings/sections/MapsSection.js +71 -247
- package/src/react/pages/settings/sections/loyaltyProductCompany.js +57 -0
- package/src/react/pages/settings/sections/mapsSectionHelpers.js +137 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +7 -28
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +54 -8
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +32 -11
- package/src/react/utils/clientDetailsNavigation.js +56 -0
- package/src/react/utils/clientSellerVisibility.js +60 -0
- package/src/react/utils/proposalProductSelection.js +103 -13
- package/src/react/utils/proposalStatus.js +160 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +25 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +173 -347
- package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +41 -0
- package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +38 -0
- package/src/tests/react/utils/clientDetailsNavigation.test.js +98 -0
- package/src/tests/react/utils/clientSellerVisibility.test.js +74 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +57 -1
- package/src/tests/react/utils/proposalStatus.test.mjs +77 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
export const normalizeProposalStatusKey = value =>
|
|
2
|
+
String(value || '')
|
|
3
|
+
.trim()
|
|
4
|
+
.toLowerCase()
|
|
5
|
+
.replace(/[_-]+/g, ' ')
|
|
6
|
+
.replace(/\s+/g, ' ');
|
|
7
|
+
|
|
8
|
+
export const getProposalStatusColor = status => {
|
|
9
|
+
const normalized = normalizeProposalStatusKey(status);
|
|
10
|
+
|
|
11
|
+
switch (normalized) {
|
|
12
|
+
case 'ativo':
|
|
13
|
+
case 'active':
|
|
14
|
+
case 'assinado':
|
|
15
|
+
case 'signed':
|
|
16
|
+
return '#10B981';
|
|
17
|
+
case 'inativo':
|
|
18
|
+
case 'inactive':
|
|
19
|
+
case 'cancelado':
|
|
20
|
+
case 'canceled':
|
|
21
|
+
return '#EF4444';
|
|
22
|
+
case 'pendente':
|
|
23
|
+
case 'pending':
|
|
24
|
+
return '#F59E0B';
|
|
25
|
+
case 'open':
|
|
26
|
+
case 'aberto':
|
|
27
|
+
return '#3B82F6';
|
|
28
|
+
default:
|
|
29
|
+
return '#64748B';
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const getProposalStatusTranslationKey = status => {
|
|
34
|
+
const normalized = normalizeProposalStatusKey(status);
|
|
35
|
+
const map = {
|
|
36
|
+
ativo: 'active',
|
|
37
|
+
active: 'active',
|
|
38
|
+
inativo: 'inactive',
|
|
39
|
+
inactive: 'inactive',
|
|
40
|
+
pendente: 'pending',
|
|
41
|
+
pending: 'pending',
|
|
42
|
+
open: 'open',
|
|
43
|
+
aberto: 'open',
|
|
44
|
+
closed: 'closed',
|
|
45
|
+
fechado: 'closed',
|
|
46
|
+
cancelado: 'canceled',
|
|
47
|
+
canceled: 'canceled',
|
|
48
|
+
'waiting signature': 'waitingSignature',
|
|
49
|
+
'awaiting signature': 'waitingSignature',
|
|
50
|
+
'signature pending': 'waitingSignature',
|
|
51
|
+
assinado: 'signed',
|
|
52
|
+
signed: 'signed',
|
|
53
|
+
draft: 'draft',
|
|
54
|
+
rascunho: 'draft',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return map[normalized] || '';
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const getProposalStatusLabel = (status, translate) => {
|
|
61
|
+
const translationKey = getProposalStatusTranslationKey(status);
|
|
62
|
+
if (translationKey) {
|
|
63
|
+
return translate?.('contract', 'status', translationKey);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return translate?.('contract', 'label', 'na') || '';
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const getProposalStatusFilterKey = item => {
|
|
70
|
+
if (!item) {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (item['@id']) {
|
|
75
|
+
return item['@id'];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (item.id != null) {
|
|
79
|
+
return `/statuses/${item.id}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const normalized = normalizeProposalStatusKey(item.realStatus || item.status);
|
|
83
|
+
return normalized ? `realStatus:${normalized}` : '';
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const buildProposalStatusFilterOptions = ({ contracts = [], translate } = {}) => {
|
|
87
|
+
const options = [
|
|
88
|
+
{
|
|
89
|
+
key: 'realStatus:open',
|
|
90
|
+
label: translate?.('contract', 'status', 'open'),
|
|
91
|
+
color: getProposalStatusColor('open'),
|
|
92
|
+
normalizedStatus: 'open',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
key: 'realStatus:pending',
|
|
96
|
+
label: translate?.('contract', 'status', 'pending'),
|
|
97
|
+
color: getProposalStatusColor('pending'),
|
|
98
|
+
normalizedStatus: 'pending',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: 'realStatus:closed',
|
|
102
|
+
label: translate?.('contract', 'status', 'closed'),
|
|
103
|
+
color: getProposalStatusColor('closed'),
|
|
104
|
+
normalizedStatus: 'closed',
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
contracts.forEach(contract => {
|
|
109
|
+
const statusObj = contract?.status || {};
|
|
110
|
+
const key = getProposalStatusFilterKey(statusObj);
|
|
111
|
+
if (!key || options.some(item => item.key === key)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const normalizedStatus = normalizeProposalStatusKey(statusObj.realStatus || statusObj.status);
|
|
116
|
+
options.push({
|
|
117
|
+
key,
|
|
118
|
+
label: getProposalStatusLabel(statusObj.status || statusObj.realStatus, translate),
|
|
119
|
+
color: statusObj.color || getProposalStatusColor(normalizedStatus),
|
|
120
|
+
normalizedStatus,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return options;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const proposalMatchesStatusFilter = (contract, filterKey, statusFilterOptions = []) => {
|
|
128
|
+
if (!filterKey) {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const statusObj = contract?.status || {};
|
|
133
|
+
const statusIri = statusObj['@id']
|
|
134
|
+
? statusObj['@id']
|
|
135
|
+
: statusObj.id != null
|
|
136
|
+
? `/statuses/${statusObj.id}`
|
|
137
|
+
: '';
|
|
138
|
+
|
|
139
|
+
const normalizedStatus = normalizeProposalStatusKey(
|
|
140
|
+
statusObj.realStatus || statusObj.status,
|
|
141
|
+
);
|
|
142
|
+
const normalizedFilter = normalizeProposalStatusKey(
|
|
143
|
+
String(filterKey || '').replace('realStatus:', ''),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
if (filterKey.startsWith('/statuses/')) {
|
|
147
|
+
if (statusIri === filterKey) {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const selectedOption = statusFilterOptions.find(item => item.key === filterKey);
|
|
152
|
+
if (selectedOption?.normalizedStatus) {
|
|
153
|
+
return normalizedStatus === selectedOption.normalizedStatus;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return normalizedStatus === normalizedFilter;
|
|
160
|
+
};
|
|
@@ -96,6 +96,15 @@ 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
|
+
|
|
99
108
|
test.describe('Create proposal — product filter by model category (#85)', () => {
|
|
100
109
|
test('filters products by selected model category and clears incompatible selections', async ({
|
|
101
110
|
page,
|
|
@@ -145,5 +154,21 @@ test.describe('Create proposal — product filter by model category (#85)', () =
|
|
|
145
154
|
selectedModelCategoryId: consultCatId,
|
|
146
155
|
});
|
|
147
156
|
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);
|
|
148
173
|
});
|
|
149
174
|
});
|