@controleonline/ui-crm 1.0.42

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 (141) hide show
  1. package/.github/actions/workers/manager/action.yml +147 -0
  2. package/.github/actions/workers/qa/action.yml +44 -0
  3. package/.github/actions/workers/security/action.yml +44 -0
  4. package/.github/actions/workers/technical-documenter/action.yml +51 -0
  5. package/.github/workflows/manager-worker.yml +167 -0
  6. package/.github/workflows/publish-npm.yml +40 -0
  7. package/.github/workflows/pull-request-checks.yml +29 -0
  8. package/.scrutinizer.yml +24 -0
  9. package/AGENTS.md +56 -0
  10. package/FUNDING.yml +1 -0
  11. package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +121 -0
  12. package/docs/technical/Income-Statements-Demonstrativo.md +38 -0
  13. package/docs/technical/Oportunidades-Ordenacao-por-Data-de-Retorno.md +134 -0
  14. package/docs/technical/Propostas-Filtro-de-Status.md +147 -0
  15. package/docs/technical/Royalties-a-pagar-Franqueado.md +51 -0
  16. package/docs/technical/Visao-Vendedor-Comissoes.md +58 -0
  17. package/docs/wiki.md +1 -0
  18. package/package.json +43 -0
  19. package/scripts/validate-wiki-pointer.cjs +13 -0
  20. package/src/react/components/AnimatedModal.js +149 -0
  21. package/src/react/components/AnimatedModal.styles.js +21 -0
  22. package/src/react/components/CreateContractModal.js +151 -0
  23. package/src/react/components/CreateContractModal.styles.js +43 -0
  24. package/src/react/hooks/useToastMessage.js +59 -0
  25. package/src/react/index.js +4 -0
  26. package/src/react/pages/ModelTemplatesPage.js +1461 -0
  27. package/src/react/pages/ModelTemplatesPage.styles.js +441 -0
  28. package/src/react/pages/comissions/IncomeStatementDetailsModal.js +102 -0
  29. package/src/react/pages/comissions/IncomeStatementsFilters.js +120 -0
  30. package/src/react/pages/comissions/SellerCommissionsPage.js +368 -0
  31. package/src/react/pages/comissions/SellerCommissionsPage.styles.js +219 -0
  32. package/src/react/pages/comissions/incomeStatementsHelpers.js +233 -0
  33. package/src/react/pages/comissions/index.js +309 -0
  34. package/src/react/pages/comissions/index.styles.js +381 -0
  35. package/src/react/pages/comissions/sellerCommissionsHelpers.js +222 -0
  36. package/src/react/pages/crm/components/CrmHeader.js +117 -0
  37. package/src/react/pages/crm/components/MarketingEventsSection.js +142 -0
  38. package/src/react/pages/crm/components/MarketingEventsSection.styles.js +105 -0
  39. package/src/react/pages/crm/components/OpportunityCard.js +138 -0
  40. package/src/react/pages/crm/components/OpportunityFormModal.js +279 -0
  41. package/src/react/pages/crm/components/OpportunityList.js +113 -0
  42. package/src/react/pages/crm/components/OpportunitySkeletons.js +53 -0
  43. package/src/react/pages/crm/components/ProviderSelectModal.js +166 -0
  44. package/src/react/pages/crm/components/SelectModal.js +178 -0
  45. package/src/react/pages/crm/conversation.js +342 -0
  46. package/src/react/pages/crm/conversation.styles.js +206 -0
  47. package/src/react/pages/crm/hooks/useCrmData.js +494 -0
  48. package/src/react/pages/crm/hooks/useOpportunityForms.js +306 -0
  49. package/src/react/pages/crm/index.js +262 -0
  50. package/src/react/pages/crm/index.styles.js +13 -0
  51. package/src/react/pages/crm/marketingEventsHelpers.js +41 -0
  52. package/src/react/pages/crm/styles/card.styles.js +178 -0
  53. package/src/react/pages/crm/styles/layout.styles.js +184 -0
  54. package/src/react/pages/crm/styles/modal.styles.js +347 -0
  55. package/src/react/pages/home/index.js +559 -0
  56. package/src/react/pages/home/index.styles.js +268 -0
  57. package/src/react/pages/proposals/CreateProposalsModal.js +466 -0
  58. package/src/react/pages/proposals/CreateProposalsModal.styles.js +344 -0
  59. package/src/react/pages/proposals/CreateProposalsPickers.js +187 -0
  60. package/src/react/pages/proposals/CreateProposalsProductSection.js +117 -0
  61. package/src/react/pages/proposals/ProposalCard.js +112 -0
  62. package/src/react/pages/proposals/ProposalDetails.js +263 -0
  63. package/src/react/pages/proposals/ProposalDetails.styles.js +195 -0
  64. package/src/react/pages/proposals/index.js +488 -0
  65. package/src/react/pages/proposals/index.styles.js +248 -0
  66. package/src/react/pages/proposals/proposalListHelpers.js +216 -0
  67. package/src/react/pages/proposals/proposalNavigation.js +26 -0
  68. package/src/react/pages/royalties/ReceivablePage.js +233 -0
  69. package/src/react/pages/royalties/RoyaltiesPayablePage.js +260 -0
  70. package/src/react/pages/royalties/index.js +2 -0
  71. package/src/react/pages/royalties/royaltiesReceivableHelpers.js +68 -0
  72. package/src/react/pages/settings/GeneralSettings.js +317 -0
  73. package/src/react/pages/settings/GeneralSettings.shared.js +490 -0
  74. package/src/react/pages/settings/GeneralSettings.styles.js +746 -0
  75. package/src/react/pages/settings/GeneralSettingsSection.js +57 -0
  76. package/src/react/pages/settings/generalSettingsActiveTab.js +85 -0
  77. package/src/react/pages/settings/sections/CrmSection.js +281 -0
  78. package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +128 -0
  79. package/src/react/pages/settings/sections/DisplayPreparationSection.js +155 -0
  80. package/src/react/pages/settings/sections/IntegrationsSection.js +392 -0
  81. package/src/react/pages/settings/sections/LogSection.js +322 -0
  82. package/src/react/pages/settings/sections/LoginSection.js +137 -0
  83. package/src/react/pages/settings/sections/LoyaltyProductPicker.js +230 -0
  84. package/src/react/pages/settings/sections/LoyaltySection.js +451 -0
  85. package/src/react/pages/settings/sections/MaintenanceSection.js +205 -0
  86. package/src/react/pages/settings/sections/MapsSection.js +629 -0
  87. package/src/react/pages/settings/sections/MenuCatalogSection.js +405 -0
  88. package/src/react/pages/settings/sections/OperationsSection.js +303 -0
  89. package/src/react/pages/settings/sections/OrderPaymentSection.js +379 -0
  90. package/src/react/pages/settings/sections/OrderPrintSection.js +308 -0
  91. package/src/react/pages/settings/sections/ShopSection.js +490 -0
  92. package/src/react/pages/settings/sections/shop/FranchiseMapPreview.js +124 -0
  93. package/src/react/pages/settings/sections/shop/ShopDomainCreateForm.js +57 -0
  94. package/src/react/pages/settings/sections/shop/ShopDomainPanel.js +184 -0
  95. package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.js +237 -0
  96. package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.styles.js +256 -0
  97. package/src/react/pages/settings/sections/shop/ShopDomainTabs.js +61 -0
  98. package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +526 -0
  99. package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +426 -0
  100. package/src/react/pages/settings/sections/shop/ShopSettingsSection.js +10 -0
  101. package/src/react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js +163 -0
  102. package/src/react/pages/settings/sections/shop/shopDomainShowcasesUtils.js +68 -0
  103. package/src/react/pages/settings/sections/shop/shopFranchiseVisibility.js +158 -0
  104. package/src/react/pages/settings/sections/shop/shopSettingsShared.js +427 -0
  105. package/src/react/router/routes.js +135 -0
  106. package/src/react/utils/opportunityDate.js +82 -0
  107. package/src/react/utils/opportunityEditorReferences.js +76 -0
  108. package/src/react/utils/opportunityEmptyState.js +20 -0
  109. package/src/react/utils/opportunityPeople.js +111 -0
  110. package/src/react/utils/opportunityPhone.js +82 -0
  111. package/src/react/utils/opportunityStage.js +30 -0
  112. package/src/react/utils/opportunityStatusFilter.js +54 -0
  113. package/src/react/utils/proposalCreateHelpers.js +61 -0
  114. package/src/react/utils/proposalProductSelection.js +71 -0
  115. package/src/react/utils/royaltiesPayableParams.js +37 -0
  116. package/src/react/utils/translateWithFallback.js +42 -0
  117. package/src/store/crm/index.js +2 -0
  118. package/src/store/model/index.js +104 -0
  119. package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +149 -0
  120. package/src/tests/browser/crm/crm-index-status-filter.spec.js +263 -0
  121. package/src/tests/browser/crm/crm-opportunity-category-editor.spec.js +269 -0
  122. package/src/tests/browser/crm/royalties-payable.spec.js +122 -0
  123. package/src/tests/browser/crm/royalties-receivable.spec.js +121 -0
  124. package/src/tests/browser/crm/seller-commissions.spec.js +214 -0
  125. package/src/tests/browser/manager/general-settings-maps.spec.js +400 -0
  126. package/src/tests/react/pages/comissions/incomeStatementsHelpers.test.js +181 -0
  127. package/src/tests/react/pages/comissions/sellerCommissionsHelpers.test.js +132 -0
  128. package/src/tests/react/pages/crm/marketingEventsHelpers.test.cjs +53 -0
  129. package/src/tests/react/pages/crm/opportunitySearchParams.test.cjs +44 -0
  130. package/src/tests/react/pages/proposals/navigation.test.js +71 -0
  131. package/src/tests/react/pages/proposals/proposalListHelpers.test.js +42 -0
  132. package/src/tests/react/pages/royalties/royaltiesReceivableHelpers.test.js +60 -0
  133. package/src/tests/react/pages/settings/generalSettings.shared.test.js +102 -0
  134. package/src/tests/react/pages/settings/sections/shop/shopDomainShowcasesUtils.test.js +60 -0
  135. package/src/tests/react/pages/settings/sections/shop/shopFranchiseVisibility.test.js +80 -0
  136. package/src/tests/react/utils/opportunityEditorReferences.test.js +70 -0
  137. package/src/tests/react/utils/opportunityEmptyState.test.js +39 -0
  138. package/src/tests/react/utils/opportunityStatusFilter.test.cjs +81 -0
  139. package/src/tests/react/utils/proposalCreateHelpers.test.js +25 -0
  140. package/src/tests/react/utils/proposalProductSelection.test.js +76 -0
  141. package/src/tests/react/utils/royaltiesPayableParams.test.js +44 -0
@@ -0,0 +1,248 @@
1
+ import { Platform, StyleSheet } from 'react-native';
2
+ import { colors } from '@controleonline/../../src/styles/colors';
3
+
4
+ const styles = StyleSheet.create({
5
+ container: {
6
+ flex: 1,
7
+ backgroundColor: colors.background,
8
+ },
9
+ subHeader: {
10
+ paddingHorizontal: 16,
11
+ paddingTop: 9,
12
+ paddingBottom: 9,
13
+ backgroundColor: colors.white,
14
+ borderBottomWidth: 1,
15
+ borderBottomColor: colors.border,
16
+ },
17
+ searchRow: {
18
+ flexDirection: 'row',
19
+ alignItems: 'center',
20
+ },
21
+ statusFilterSection: {
22
+ marginTop: 10,
23
+ },
24
+ statusFilterLabel: {
25
+ fontSize: 12,
26
+ color: '#64748B',
27
+ fontWeight: '600',
28
+ marginBottom: 8,
29
+ },
30
+ statusFilterRow: {
31
+ paddingRight: 4,
32
+ },
33
+ statusFilterChip: {
34
+ borderWidth: 1,
35
+ borderColor: '#DCE3EC',
36
+ backgroundColor: '#F8FAFC',
37
+ borderRadius: 999,
38
+ paddingHorizontal: 12,
39
+ paddingVertical: 7,
40
+ marginRight: 8,
41
+ },
42
+ statusFilterChipActive: {
43
+ borderColor: colors.primary,
44
+ backgroundColor: '#E7F3FF',
45
+ },
46
+ statusFilterChipText: {
47
+ fontSize: 12,
48
+ color: '#64748B',
49
+ fontWeight: '600',
50
+ },
51
+ statusFilterChipTextActive: {
52
+ color: colors.primary,
53
+ },
54
+ searchInputContainer: {
55
+ flex: 1,
56
+ flexDirection: 'row',
57
+ alignItems: 'center',
58
+ backgroundColor: colors.background,
59
+ borderRadius: 8,
60
+ paddingHorizontal: 12,
61
+ height: 40,
62
+ borderWidth: 1,
63
+ borderColor: colors.border,
64
+ },
65
+ searchInput: {
66
+ flex: 1,
67
+ height: '100%',
68
+ paddingHorizontal: 8,
69
+ fontSize: 14,
70
+ color: colors.text,
71
+ },
72
+ clearSearchButton: {
73
+ padding: 4,
74
+ },
75
+ addButton: {
76
+ backgroundColor: colors.primary,
77
+ width: 40,
78
+ height: 40,
79
+ borderRadius: 20,
80
+ alignItems: 'center',
81
+ justifyContent: 'center',
82
+ marginLeft: 12,
83
+ shadowColor: colors.primary,
84
+ shadowOffset: { width: 0, height: 2 },
85
+ shadowOpacity: 0.3,
86
+ shadowRadius: 4,
87
+ elevation: 3,
88
+ },
89
+ listContent: {
90
+ padding: 16,
91
+ paddingBottom: 32,
92
+ },
93
+ card: {
94
+ backgroundColor: colors.white,
95
+ borderRadius: 12,
96
+ marginBottom: 12,
97
+ padding: 16,
98
+ borderWidth: 1,
99
+ borderColor: colors.border,
100
+ ...Platform.select({
101
+ android: { elevation: 4 },
102
+ ios: {
103
+ shadowColor: '#0F172A',
104
+ shadowOffset: { width: 0, height: 4 },
105
+ shadowOpacity: 0.1,
106
+ shadowRadius: 12,
107
+ },
108
+ web: { boxShadow: '0 8px 16px rgba(15, 23, 42, 0.1), 0 2px 6px rgba(15, 23, 42, 0.06)' },
109
+ }),
110
+ },
111
+ cardHeader: {
112
+ marginBottom: 12,
113
+ },
114
+ headerContent: {
115
+ flexDirection: 'row',
116
+ justifyContent: 'space-between',
117
+ alignItems: 'flex-start',
118
+ },
119
+ cardTitle: {
120
+ fontSize: 16,
121
+ fontWeight: '600',
122
+ color: colors.text,
123
+ flex: 1,
124
+ marginRight: 12,
125
+ lineHeight: 22,
126
+ },
127
+ statusBadge: {
128
+ paddingHorizontal: 8,
129
+ paddingVertical: 4,
130
+ borderRadius: 6,
131
+ },
132
+ statusText: {
133
+ color: colors.white,
134
+ fontSize: 10,
135
+ fontWeight: '700',
136
+ textTransform: 'uppercase',
137
+ },
138
+ cardBody: {
139
+ paddingBottom: 12,
140
+ borderBottomWidth: 1,
141
+ borderBottomColor: colors.border,
142
+ marginBottom: 12,
143
+ },
144
+ clientRow: {
145
+ flexDirection: 'row',
146
+ alignItems: 'center',
147
+ marginBottom: 8,
148
+ },
149
+ clientText: {
150
+ fontSize: 13,
151
+ color: colors.text,
152
+ marginLeft: 6,
153
+ fontWeight: '500',
154
+ flex: 1,
155
+ },
156
+ datesContainer: {
157
+ flexDirection: 'row',
158
+ flexWrap: 'wrap',
159
+ gap: 8,
160
+ },
161
+ dateBadge: {
162
+ flexDirection: 'row',
163
+ alignItems: 'center',
164
+ backgroundColor: colors.background,
165
+ paddingHorizontal: 8,
166
+ paddingVertical: 4,
167
+ borderRadius: 6,
168
+ borderWidth: 1,
169
+ borderColor: colors.border,
170
+ },
171
+ dateText: {
172
+ fontSize: 12,
173
+ color: colors.textSecondary,
174
+ marginLeft: 6,
175
+ },
176
+ cardFooter: {
177
+ flexDirection: 'row',
178
+ alignItems: 'center',
179
+ justifyContent: 'flex-end',
180
+ paddingTop: 4,
181
+ },
182
+ footerActions: {
183
+ flexDirection: 'row',
184
+ alignItems: 'center',
185
+ gap: 8,
186
+ flex: 1,
187
+ justifyContent: 'flex-end',
188
+ },
189
+ footerButton: {
190
+ flexDirection: 'row',
191
+ alignItems: 'center',
192
+ gap: 4,
193
+ paddingVertical: 6,
194
+ paddingHorizontal: 10,
195
+ borderRadius: 8,
196
+ backgroundColor: '#F1F5F9',
197
+ },
198
+ footerButtonPrimary: {
199
+ backgroundColor: 'transparent',
200
+ },
201
+ footerButtonText: {
202
+ fontSize: 13,
203
+ fontWeight: '600',
204
+ color: '#64748B',
205
+ },
206
+ footerButtonTextPrimary: {
207
+ color: colors.primary,
208
+ marginRight: 0,
209
+ },
210
+ viewDetailsText: {
211
+ fontSize: 13,
212
+ fontWeight: '600',
213
+ color: colors.primary,
214
+ marginRight: 4,
215
+ },
216
+ loadingContainer: {
217
+ padding: 32,
218
+ alignItems: 'center',
219
+ },
220
+ loadingText: {
221
+ marginTop: 12,
222
+ color: colors.textSecondary,
223
+ },
224
+ emptyContainer: {
225
+ padding: 40,
226
+ alignItems: 'center',
227
+ justifyContent: 'center',
228
+ },
229
+ emptyTitle: {
230
+ fontSize: 18,
231
+ fontWeight: '700',
232
+ color: colors.text,
233
+ marginTop: 16,
234
+ },
235
+ emptySubtitle: {
236
+ fontSize: 14,
237
+ color: colors.textSecondary,
238
+ textAlign: 'center',
239
+ marginTop: 4,
240
+ },
241
+ });
242
+
243
+ export default styles;
244
+
245
+ export const inlineStyle_669_129 = {
246
+ marginVertical: 20,
247
+ };
248
+
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Pure helpers for proposals list (status labels/colors + client name resolution).
3
+ * Extracted from the list page to keep index.js under the 500-line quality bar.
4
+ */
5
+
6
+ function normalizeDigits(value) {
7
+ return String(value || '').replace(/\D/g, '');
8
+ }
9
+
10
+ function normalizeText(value) {
11
+ return String(value || '').trim();
12
+ }
13
+
14
+ function normalizeStatusKey(status) {
15
+ return String(status || '')
16
+ .trim()
17
+ .toLowerCase()
18
+ .replace(/[_-]+/g, ' ')
19
+ .replace(/\s+/g, ' ');
20
+ }
21
+
22
+ function getStatusColor(status) {
23
+ const normalized = normalizeStatusKey(status);
24
+
25
+ switch (normalized) {
26
+ case 'ativo':
27
+ case 'active':
28
+ case 'assinado':
29
+ case 'signed':
30
+ return '#10B981';
31
+ case 'inativo':
32
+ case 'inactive':
33
+ case 'cancelado':
34
+ case 'canceled':
35
+ return '#c10015';
36
+ case 'pendente':
37
+ case 'pending':
38
+ return '#e67e22';
39
+ case 'open':
40
+ case 'aberto':
41
+ return '#3B82F6';
42
+ default:
43
+ return '#64748B';
44
+ }
45
+ }
46
+
47
+ function getStatusLabel(status) {
48
+ const normalized = normalizeStatusKey(status);
49
+ const map = {
50
+ ativo: global.t?.t('contract', 'status', 'active'),
51
+ active: global.t?.t('contract', 'status', 'active'),
52
+ inativo: global.t?.t('contract', 'status', 'inactive'),
53
+ inactive: global.t?.t('contract', 'status', 'inactive'),
54
+ pendente: global.t?.t('contract', 'status', 'pending'),
55
+ pending: global.t?.t('contract', 'status', 'pending'),
56
+ open: global.t?.t('contract', 'status', 'open'),
57
+ aberto: global.t?.t('contract', 'status', 'open'),
58
+ closed: global.t?.t('contract', 'status', 'closed'),
59
+ fechado: global.t?.t('contract', 'status', 'closed'),
60
+ cancelado: global.t?.t('contract', 'status', 'canceled'),
61
+ canceled: global.t?.t('contract', 'status', 'canceled'),
62
+ 'waiting signature': global.t?.t('contract', 'status', 'waitingSignature'),
63
+ 'awaiting signature': global.t?.t('contract', 'status', 'waitingSignature'),
64
+ 'signature pending': global.t?.t('contract', 'status', 'waitingSignature'),
65
+ assinado: global.t?.t('contract', 'status', 'signed'),
66
+ signed: global.t?.t('contract', 'status', 'signed'),
67
+ draft: global.t?.t('contract', 'status', 'draft'),
68
+ rascunho: global.t?.t('contract', 'status', 'draft'),
69
+ };
70
+
71
+ return map[normalized] || status || global.t?.t('contract', 'label', 'na');
72
+ }
73
+
74
+ function extractPeopleId(person) {
75
+ if (person == null) return '';
76
+ if (typeof person === 'string' || typeof person === 'number') {
77
+ return normalizeDigits(person);
78
+ }
79
+ if (person.id != null) return normalizeDigits(person.id);
80
+ if (person['@id']) {
81
+ const parts = String(person['@id']).split('/');
82
+ return normalizeDigits(parts[parts.length - 1]);
83
+ }
84
+ return '';
85
+ }
86
+
87
+ function resolvePeopleName(person) {
88
+ if (!person || typeof person !== 'object') return '';
89
+ return (
90
+ normalizeText(person.name) ||
91
+ normalizeText(person.alias) ||
92
+ normalizeText(person.people?.name) ||
93
+ normalizeText(person.people?.alias) ||
94
+ ''
95
+ );
96
+ }
97
+
98
+ function getContractPartyCandidates(contract) {
99
+ const participants = Array.isArray(contract?.peoples) ? contract.peoples : [];
100
+ const participantsOrdered = [...participants].sort((left, right) => {
101
+ const leftType = String(left?.peopleType || '').trim().toLowerCase();
102
+ const rightType = String(right?.peopleType || '').trim().toLowerCase();
103
+
104
+ const weight = type => {
105
+ if (type === 'provider') return 0;
106
+ if (type === 'contractor') return 1;
107
+ if (type === 'witness') return 2;
108
+ return 3;
109
+ };
110
+
111
+ return weight(leftType) - weight(rightType);
112
+ });
113
+
114
+ return [
115
+ ...participantsOrdered.map(entry => entry?.people),
116
+ contract?.client,
117
+ contract?.customer,
118
+ contract?.contractor,
119
+ contract?.people,
120
+ contract?.provider,
121
+ ].filter(Boolean);
122
+ }
123
+
124
+ function isCurrentCompanyPerson(person, currentCompany) {
125
+ const reference = String(
126
+ typeof person === 'object' ? person?.['@id'] || person?.id : person || '',
127
+ ).trim();
128
+ const companyId = normalizeDigits(currentCompany?.id);
129
+ if (!reference || !companyId) {
130
+ return false;
131
+ }
132
+
133
+ const referenceDigits = extractPeopleId(reference);
134
+ return (
135
+ reference === `/people/${companyId}` ||
136
+ reference === `/peoples/${companyId}` ||
137
+ referenceDigits === companyId
138
+ );
139
+ }
140
+
141
+ function isIgnoredContractPartyId(contract, personId, currentCompany) {
142
+ if (!personId) {
143
+ return true;
144
+ }
145
+
146
+ const companyId = normalizeDigits(currentCompany?.id);
147
+ const modelPeopleId = normalizeDigits(contract?.contractModel?.people);
148
+ const signerId = normalizeDigits(contract?.contractModel?.signer);
149
+
150
+ return [companyId, modelPeopleId, signerId].some(
151
+ referenceId => referenceId && referenceId === personId,
152
+ );
153
+ }
154
+
155
+ function getResolvedPeopleName(person, peopleNameById = {}) {
156
+ const directName = resolvePeopleName(person);
157
+ if (directName) {
158
+ return directName;
159
+ }
160
+
161
+ const personId = extractPeopleId(person);
162
+ return personId ? peopleNameById[personId] || '' : '';
163
+ }
164
+
165
+ function getContractClientName(contract, { currentCompany, peopleNameById } = {}) {
166
+ const candidates = getContractPartyCandidates(contract);
167
+ for (const candidate of candidates) {
168
+ const personId = extractPeopleId(candidate);
169
+ if (personId && isIgnoredContractPartyId(contract, personId, currentCompany)) {
170
+ continue;
171
+ }
172
+
173
+ if (personId && isCurrentCompanyPerson(candidate, currentCompany)) {
174
+ continue;
175
+ }
176
+
177
+ const name = getResolvedPeopleName(candidate, peopleNameById);
178
+ if (name) {
179
+ return name;
180
+ }
181
+ }
182
+
183
+ return '';
184
+ }
185
+
186
+ function isContractClientPendingResolution(
187
+ contract,
188
+ { currentCompany, peopleNameById } = {},
189
+ ) {
190
+ const candidates = getContractPartyCandidates(contract);
191
+ return candidates.some(candidate => {
192
+ const personId = extractPeopleId(candidate);
193
+ if (!personId || isIgnoredContractPartyId(contract, personId, currentCompany)) {
194
+ return false;
195
+ }
196
+
197
+ const name = getResolvedPeopleName(candidate, peopleNameById);
198
+ return !name;
199
+ });
200
+ }
201
+
202
+ module.exports = {
203
+ normalizeDigits,
204
+ normalizeText,
205
+ normalizeStatusKey,
206
+ getStatusColor,
207
+ getStatusLabel,
208
+ extractPeopleId,
209
+ resolvePeopleName,
210
+ getContractPartyCandidates,
211
+ isCurrentCompanyPerson,
212
+ isIgnoredContractPartyId,
213
+ getResolvedPeopleName,
214
+ getContractClientName,
215
+ isContractClientPendingResolution,
216
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Navigation helpers for proposal details (app-community#55).
3
+ * Opens ProposalDetails already on the products tab so users can associate products/services.
4
+ */
5
+
6
+ function buildProposalDetailsParams(contractId, options = {}) {
7
+ const params = { contractId };
8
+ if (options.initialTab) {
9
+ params.initialTab = options.initialTab;
10
+ }
11
+ return params;
12
+ }
13
+
14
+ function buildProposalProductsParams(contractId) {
15
+ return buildProposalDetailsParams(contractId, { initialTab: 'products' });
16
+ }
17
+
18
+ function getProposalInitialTabIndex(initialTab) {
19
+ return String(initialTab || '').trim().toLowerCase() === 'products' ? 1 : 0;
20
+ }
21
+
22
+ module.exports = {
23
+ buildProposalDetailsParams,
24
+ buildProposalProductsParams,
25
+ getProposalInitialTabIndex,
26
+ };