@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,317 @@
1
+ import React, {useCallback, useEffect, useMemo, useState} from 'react';
2
+ import {ScrollView, Text, TouchableOpacity, View} from 'react-native';
3
+ import {SafeAreaView} from 'react-native-safe-area-context';
4
+ import {useFocusEffect} from '@react-navigation/native';
5
+ import Icon from 'react-native-vector-icons/MaterialIcons';
6
+
7
+ import css from '@controleonline/ui-orders/src/react/css/orders';
8
+ import StateStore from '@controleonline/ui-common/src/react/components/StateStore';
9
+
10
+ import {
11
+ useGeneralSettingsPalette,
12
+ useGeneralSettingsStyles,
13
+ } from './GeneralSettings.styles';
14
+ import {
15
+ useGeneralSettingsConfig,
16
+ } from './GeneralSettings.shared';
17
+ import {
18
+ readGeneralSettingsActiveTab,
19
+ resolveGeneralSettingsActiveTab,
20
+ writeGeneralSettingsActiveTab,
21
+ } from './generalSettingsActiveTab';
22
+ import DeviceRuntimeFooterSection from './sections/DeviceRuntimeFooterSection';
23
+ import OrderPrintSection from './sections/OrderPrintSection';
24
+ import DisplayPreparationSection from './sections/DisplayPreparationSection';
25
+ import MenuCatalogSection from './sections/MenuCatalogSection';
26
+ import OrderPaymentSection from './sections/OrderPaymentSection';
27
+ import OperationsSection from './sections/OperationsSection';
28
+ import CrmSection from './sections/CrmSection';
29
+ import LoyaltySection from './sections/LoyaltySection';
30
+ import MapsSection from './sections/MapsSection';
31
+ import ShopSettingsSection from './sections/shop/ShopSettingsSection';
32
+ import IntegrationsSection from './sections/IntegrationsSection';
33
+ import LogSection from './sections/LogSection';
34
+ import MaintenanceSection from './sections/MaintenanceSection';
35
+
36
+ const MAIN_COMPANY_ONLY_TABS = new Set(['shop']);
37
+ const TECHNICAL_TABS = new Set(['integrations', 'logs', 'maintenance']);
38
+
39
+ const SETTINGS_TABS = [
40
+ {
41
+ key: 'devices',
42
+ label: 'Devices',
43
+ icon: 'dvr',
44
+ stores: ['configs', 'people'],
45
+ Component: DeviceRuntimeFooterSection,
46
+ },
47
+ {
48
+ key: 'integrations',
49
+ label: 'Integrações',
50
+ icon: 'link',
51
+ stores: ['configs', 'people'],
52
+ Component: IntegrationsSection,
53
+ },
54
+ {
55
+ key: 'logs',
56
+ label: 'Logs',
57
+ icon: 'bug-report',
58
+ stores: ['configs', 'people'],
59
+ Component: LogSection,
60
+ },
61
+ {
62
+ key: 'maintenance',
63
+ label: 'Rotinas',
64
+ icon: 'schedule',
65
+ stores: ['configs', 'people'],
66
+ Component: MaintenanceSection,
67
+ },
68
+ {
69
+ key: 'print',
70
+ label: 'Conferência',
71
+ icon: 'print',
72
+ stores: ['configs', 'printer', 'device_config'],
73
+ Component: OrderPrintSection,
74
+ },
75
+ {
76
+ key: 'preparation',
77
+ label: 'Preparo',
78
+ icon: 'receipt-long',
79
+ stores: ['device_config'],
80
+ Component: DisplayPreparationSection,
81
+ },
82
+ {
83
+ key: 'menu',
84
+ label: 'Cardapio PDF',
85
+ icon: 'restaurant-menu',
86
+ stores: ['configs', 'categories', 'product_group', 'models'],
87
+ Component: MenuCatalogSection,
88
+ },
89
+ {
90
+ key: 'payment',
91
+ label: 'Pagamento',
92
+ icon: 'credit-card',
93
+ stores: ['configs', 'device_config'],
94
+ Component: OrderPaymentSection,
95
+ },
96
+ {
97
+ key: 'operations',
98
+ label: 'Operações',
99
+ icon: 'point-of-sale',
100
+ stores: [],
101
+ Component: OperationsSection,
102
+ },
103
+ {
104
+ key: 'crm',
105
+ label: 'CRM',
106
+ icon: 'groups',
107
+ stores: ['configs'],
108
+ Component: CrmSection,
109
+ },
110
+ {
111
+ key: 'loyalty',
112
+ label: 'Fidelidade',
113
+ icon: 'loyalty',
114
+ stores: ['configs', 'products'],
115
+ Component: LoyaltySection,
116
+ },
117
+ {
118
+ key: 'maps',
119
+ label: 'Mapas',
120
+ icon: 'map',
121
+ stores: ['configs'],
122
+ Component: MapsSection,
123
+ },
124
+ {
125
+ key: 'shop',
126
+ label: 'Shop',
127
+ icon: 'shopping-bag',
128
+ stores: ['people_domains', 'product_showcases'],
129
+ Component: ShopSettingsSection,
130
+ },
131
+ ];
132
+
133
+ const GeneralSettings = () => {
134
+ const {styles} = css();
135
+ const localStyles = useGeneralSettingsStyles();
136
+ const {
137
+ companies,
138
+ currentCompany,
139
+ mainCompany,
140
+ hasMainCompanyAccess,
141
+ isMainCompanySelected,
142
+ peopleActions,
143
+ } =
144
+ useGeneralSettingsConfig();
145
+ const themePalette = useGeneralSettingsPalette();
146
+ const [activeTab, setActiveTab] = useState(
147
+ () => readGeneralSettingsActiveTab() || SETTINGS_TABS[0].key,
148
+ );
149
+ /*
150
+ * @agents Wait for the company context before correcting the tab selection.
151
+ * Without this guard the screen can briefly snap back to the first tab during bootstrap.
152
+ */
153
+ const [isCompanyContextReady, setIsCompanyContextReady] = useState(false);
154
+
155
+ const availableTabs = useMemo(
156
+ () =>
157
+ SETTINGS_TABS.filter(
158
+ tab =>
159
+ (!MAIN_COMPANY_ONLY_TABS.has(tab.key) || isMainCompanySelected) &&
160
+ (!TECHNICAL_TABS.has(tab.key) || hasMainCompanyAccess),
161
+ ),
162
+ [hasMainCompanyAccess, isMainCompanySelected],
163
+ );
164
+
165
+ useFocusEffect(
166
+ useCallback(() => {
167
+ let cancelled = false;
168
+ const requests = [];
169
+
170
+ setIsCompanyContextReady(false);
171
+
172
+ if (!Array.isArray(companies) || companies.length === 0) {
173
+ const companiesRequest = peopleActions.myCompanies?.();
174
+ if (companiesRequest?.then) {
175
+ requests.push(companiesRequest.catch(() => {}));
176
+ }
177
+ }
178
+
179
+ if (!mainCompany?.id) {
180
+ const mainCompanyRequest = peopleActions.mainCompany?.();
181
+ if (mainCompanyRequest?.then) {
182
+ requests.push(mainCompanyRequest.catch(() => {}));
183
+ }
184
+ }
185
+
186
+ Promise.allSettled(requests).finally(() => {
187
+ if (!cancelled) {
188
+ setIsCompanyContextReady(true);
189
+ }
190
+ });
191
+
192
+ if (requests.length === 0) {
193
+ setIsCompanyContextReady(true);
194
+ }
195
+
196
+ return () => {
197
+ cancelled = true;
198
+ };
199
+ }, [companies, mainCompany?.id, peopleActions]),
200
+ );
201
+
202
+ /*
203
+ * @agents Validate the current tab after mount, then only correct the selection when
204
+ * the active tab stops being available because of company or permission changes.
205
+ */
206
+ useEffect(() => {
207
+ if (!isCompanyContextReady) {
208
+ return;
209
+ }
210
+
211
+ const nextActiveTab = resolveGeneralSettingsActiveTab({
212
+ activeTab,
213
+ availableTabs,
214
+ fallbackTab: SETTINGS_TABS[0].key,
215
+ });
216
+
217
+ if (nextActiveTab !== activeTab) {
218
+ setActiveTab(nextActiveTab);
219
+ }
220
+ }, [activeTab, availableTabs, isCompanyContextReady]);
221
+
222
+ /*
223
+ * @agents Persist the current tab for the next visit, but never use storage to
224
+ * override a valid in-session click.
225
+ */
226
+ useEffect(() => {
227
+ writeGeneralSettingsActiveTab(activeTab);
228
+ }, [activeTab]);
229
+
230
+ const activeTabConfig = useMemo(
231
+ () =>
232
+ availableTabs.find(tab => tab.key === activeTab) ||
233
+ SETTINGS_TABS.find(tab => tab.key === activeTab) ||
234
+ availableTabs[0] ||
235
+ SETTINGS_TABS[0],
236
+ [activeTab, availableTabs],
237
+ );
238
+ const ActiveTabComponent = activeTabConfig.Component;
239
+ const activeStores = useMemo(
240
+ () => Array.from(new Set(activeTabConfig?.stores || ['configs'])),
241
+ [activeTabConfig],
242
+ );
243
+
244
+ return (
245
+ <SafeAreaView style={styles.Settings.container}>
246
+ <StateStore stores={activeStores} />
247
+ <ScrollView contentContainerStyle={styles.Settings.scrollContent}>
248
+ <View style={styles.Settings.mainContainer}>
249
+ <Text style={localStyles.pageTitle}>Configurador geral</Text>
250
+ <Text style={localStyles.pageSubtitle}>
251
+ {currentCompany?.name || currentCompany?.alias || 'Empresa ativa'}
252
+ </Text>
253
+
254
+ <ScrollView
255
+ horizontal
256
+ showsHorizontalScrollIndicator={false}
257
+ style={localStyles.tabBar}
258
+ contentContainerStyle={localStyles.tabBarContent}>
259
+ {availableTabs.map(tab => {
260
+ const active = tab.key === activeTab;
261
+ const tabColors = active
262
+ ? {
263
+ backgroundColor: themePalette.buttonBackground,
264
+ borderColor: themePalette.buttonBorder,
265
+ iconColor: themePalette.buttonIcon,
266
+ textColor: themePalette.buttonText,
267
+ }
268
+ : {
269
+ backgroundColor: themePalette.buttonBackgroundSecondary,
270
+ borderColor: themePalette.buttonBorderSecondary,
271
+ iconColor: themePalette.buttonIconSecondary,
272
+ textColor: themePalette.buttonTextSecondary,
273
+ };
274
+
275
+ return (
276
+ <TouchableOpacity
277
+ key={tab.key}
278
+ style={[
279
+ localStyles.tabItem,
280
+ {
281
+ backgroundColor: tabColors.backgroundColor,
282
+ borderColor: tabColors.borderColor,
283
+ },
284
+ ]}
285
+ activeOpacity={0.85}
286
+ onPress={() => setActiveTab(tab.key)}>
287
+ <Icon
288
+ name={tab.icon}
289
+ size={18}
290
+ color={tabColors.iconColor}
291
+ />
292
+ <Text
293
+ style={[
294
+ localStyles.tabLabel,
295
+ active && localStyles.tabLabelActive,
296
+ {color: tabColors.textColor},
297
+ ]}>
298
+ {tab.label}
299
+ </Text>
300
+ </TouchableOpacity>
301
+ );
302
+ })}
303
+ </ScrollView>
304
+
305
+ <Text style={localStyles.tabHelper}>
306
+ Cada aba carrega apenas os dados da própria sessão para reduzir a
307
+ latência inicial e deixar a tela mais organizada.
308
+ </Text>
309
+
310
+ <ActiveTabComponent />
311
+ </View>
312
+ </ScrollView>
313
+ </SafeAreaView>
314
+ );
315
+ };
316
+
317
+ export default GeneralSettings;