@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,405 @@
1
+ /*
2
+ * @agents This section controls the menu catalog visibility rules for groups and categories.
3
+ * Keep the visible lists and persisted ids aligned with the shared config contract.
4
+ */
5
+ import React, {useCallback, useEffect, useMemo, useState} from 'react';
6
+ import {
7
+ ActivityIndicator,
8
+ Text,
9
+ TouchableOpacity,
10
+ View,
11
+ } from 'react-native';
12
+ import {Picker} from '@react-native-picker/picker';
13
+ import Icon from 'react-native-vector-icons/MaterialIcons';
14
+
15
+ import css from '@controleonline/ui-orders/src/react/css/orders';
16
+ import {
17
+ MENU_CATALOG_MODEL_CONFIG_KEY,
18
+ normalizeModelReference,
19
+ } from '@controleonline/ui-common/src/react/utils/menuCatalogConfig';
20
+ import {useStore} from '@store';
21
+
22
+ import {
23
+ useGeneralSettingsPalette,
24
+ useGeneralSettingsStyles,
25
+ } from '../GeneralSettings.styles';
26
+ import GeneralSettingsSection from '../GeneralSettingsSection';
27
+ import {
28
+ GENERAL_SETTINGS_PICKER_MODE,
29
+ getMenuGroupOptionLabel,
30
+ MENU_CATALOG_HIDDEN_CATEGORY_IDS_CONFIG_KEY,
31
+ MENU_CATALOG_HIDDEN_GROUP_IDS_CONFIG_KEY,
32
+ normalizeEntityId,
33
+ normalizeIdList,
34
+ useGeneralSettingsConfig,
35
+ } from '../GeneralSettings.shared';
36
+
37
+ const MenuCatalogSection = () => {
38
+ const {styles} = css();
39
+ const localStyles = useGeneralSettingsStyles();
40
+ const themePalette = useGeneralSettingsPalette();
41
+ const {
42
+ currentCompany,
43
+ effectiveCompanyConfigs,
44
+ saveConfigs,
45
+ } = useGeneralSettingsConfig();
46
+
47
+ const categoriesStore = useStore('categories');
48
+ const {
49
+ items: menuCategories = [],
50
+ isLoading: isLoadingMenuCategories,
51
+ } = categoriesStore.getters;
52
+ const categoryActions = categoriesStore.actions;
53
+
54
+ const productGroupStore = useStore('product_group');
55
+ const {
56
+ items: menuGroups = [],
57
+ isLoading: isLoadingMenuGroups,
58
+ } = productGroupStore.getters;
59
+ const productGroupActions = productGroupStore.actions;
60
+
61
+ const modelsStore = useStore('models');
62
+ const modelActions = modelsStore.actions;
63
+
64
+ const [menuCatalogModel, setMenuCatalogModel] = useState('');
65
+ const [menuModels, setMenuModels] = useState([]);
66
+ const [isLoadingMenuModels, setIsLoadingMenuModels] = useState(false);
67
+ const [menuHiddenCategoryIds, setMenuHiddenCategoryIds] = useState([]);
68
+ const [menuHiddenGroupIds, setMenuHiddenGroupIds] = useState([]);
69
+
70
+ useEffect(() => {
71
+ setMenuCatalogModel(
72
+ normalizeModelReference(
73
+ effectiveCompanyConfigs[MENU_CATALOG_MODEL_CONFIG_KEY],
74
+ ),
75
+ );
76
+ setMenuHiddenCategoryIds(
77
+ normalizeIdList(
78
+ effectiveCompanyConfigs[MENU_CATALOG_HIDDEN_CATEGORY_IDS_CONFIG_KEY],
79
+ ),
80
+ );
81
+ setMenuHiddenGroupIds(
82
+ normalizeIdList(
83
+ effectiveCompanyConfigs[MENU_CATALOG_HIDDEN_GROUP_IDS_CONFIG_KEY],
84
+ ),
85
+ );
86
+ }, [effectiveCompanyConfigs]);
87
+
88
+ useEffect(() => {
89
+ if (!currentCompany?.id) {
90
+ setMenuModels([]);
91
+ setMenuCatalogModel('');
92
+ setIsLoadingMenuModels(false);
93
+ return;
94
+ }
95
+
96
+ categoryActions
97
+ .getItems({
98
+ context: 'products',
99
+ company: currentCompany.id,
100
+ 'order[name]': 'ASC',
101
+ })
102
+ .catch(() => {});
103
+ productGroupActions
104
+ .getItems({
105
+ 'parentProduct.company': '/people/' + currentCompany.id,
106
+ 'order[groupOrder]': 'ASC',
107
+ 'order[productGroup]': 'ASC',
108
+ })
109
+ .catch(() => {});
110
+
111
+ setIsLoadingMenuModels(true);
112
+ modelActions
113
+ .getItems({
114
+ context: 'menu',
115
+ people: currentCompany.id,
116
+ })
117
+ .then(response => {
118
+ const currentCompanyId = normalizeEntityId(currentCompany.id);
119
+ const availableModels = (Array.isArray(response) ? response : [])
120
+ .filter(model => {
121
+ const modelCompanyId = normalizeEntityId(
122
+ model?.people || model?.company,
123
+ );
124
+ return !modelCompanyId || modelCompanyId === currentCompanyId;
125
+ })
126
+ .sort((first, second) =>
127
+ String(first?.model || '').localeCompare(
128
+ String(second?.model || ''),
129
+ 'pt-BR',
130
+ {sensitivity: 'base'},
131
+ ),
132
+ );
133
+
134
+ setMenuModels(availableModels);
135
+ modelActions.setError?.(null);
136
+ })
137
+ .catch(() => {
138
+ setMenuModels([]);
139
+ modelActions.setError?.(null);
140
+ })
141
+ .finally(() => {
142
+ setIsLoadingMenuModels(false);
143
+ });
144
+ }, [categoryActions, currentCompany?.id, modelActions, productGroupActions]);
145
+
146
+ const normalizedMenuCategories = useMemo(
147
+ () => (Array.isArray(menuCategories) ? menuCategories : []),
148
+ [menuCategories],
149
+ );
150
+ const normalizedMenuGroups = useMemo(
151
+ () => (Array.isArray(menuGroups) ? menuGroups : []),
152
+ [menuGroups],
153
+ );
154
+ const normalizedMenuModels = useMemo(
155
+ () => (Array.isArray(menuModels) ? menuModels : []),
156
+ [menuModels],
157
+ );
158
+
159
+ const saveMenuCatalogConfigs = useCallback(
160
+ async ({
161
+ hiddenCategoryIds = menuHiddenCategoryIds,
162
+ hiddenGroupIds = menuHiddenGroupIds,
163
+ model = menuCatalogModel,
164
+ } = {}) => {
165
+ await saveConfigs({
166
+ [MENU_CATALOG_MODEL_CONFIG_KEY]: normalizeModelReference(model),
167
+ [MENU_CATALOG_HIDDEN_CATEGORY_IDS_CONFIG_KEY]: hiddenCategoryIds,
168
+ [MENU_CATALOG_HIDDEN_GROUP_IDS_CONFIG_KEY]: hiddenGroupIds,
169
+ });
170
+ },
171
+ [menuCatalogModel, menuHiddenCategoryIds, menuHiddenGroupIds, saveConfigs],
172
+ );
173
+
174
+ const toggleMenuHiddenCategory = useCallback(
175
+ categoryId => {
176
+ const normalizedId = String(categoryId || '').replace(/\D+/g, '').trim();
177
+ if (!normalizedId) {
178
+ return;
179
+ }
180
+
181
+ const nextValue = menuHiddenCategoryIds.includes(normalizedId)
182
+ ? menuHiddenCategoryIds.filter(item => item !== normalizedId)
183
+ : [...menuHiddenCategoryIds, normalizedId];
184
+
185
+ setMenuHiddenCategoryIds(nextValue);
186
+ saveMenuCatalogConfigs({hiddenCategoryIds: nextValue});
187
+ },
188
+ [menuHiddenCategoryIds, saveMenuCatalogConfigs],
189
+ );
190
+
191
+ const toggleMenuHiddenGroup = useCallback(
192
+ groupId => {
193
+ const normalizedId = String(groupId || '').replace(/\D+/g, '').trim();
194
+ if (!normalizedId) {
195
+ return;
196
+ }
197
+
198
+ const nextValue = menuHiddenGroupIds.includes(normalizedId)
199
+ ? menuHiddenGroupIds.filter(item => item !== normalizedId)
200
+ : [...menuHiddenGroupIds, normalizedId];
201
+
202
+ setMenuHiddenGroupIds(nextValue);
203
+ saveMenuCatalogConfigs({hiddenGroupIds: nextValue});
204
+ },
205
+ [menuHiddenGroupIds, saveMenuCatalogConfigs],
206
+ );
207
+
208
+ return (
209
+ <GeneralSettingsSection
210
+ description="Define o modelo HTML/Twig usado no PDF e quais categorias e grupos de customizacao ficam ocultos no arquivo baixado no manager e na rota publica `/download` do shop."
211
+ icon="restaurant-menu"
212
+ iconBackgroundColor={themePalette.cardIconBackground}
213
+ iconColor={themePalette.cardIconColor}
214
+ title="Cardapio em PDF">
215
+ <View style={localStyles.fieldBlock}>
216
+ <Text style={localStyles.fieldLabel}>Modelo do cardapio</Text>
217
+ <Text style={localStyles.helperText}>
218
+ Selecione o modelo com contexto `menu` que sera usado para gerar o
219
+ PDF dessa empresa.
220
+ </Text>
221
+
222
+ {isLoadingMenuModels ? (
223
+ <ActivityIndicator
224
+ size="small"
225
+ style={localStyles.sectionLoader}
226
+ color={themePalette.loadingSpinner}
227
+ />
228
+ ) : normalizedMenuModels.length === 0 ? (
229
+ <View style={localStyles.emptyBox}>
230
+ <Text style={localStyles.emptyTitle}>
231
+ Nenhum modelo de cardapio encontrado
232
+ </Text>
233
+ <Text style={localStyles.emptyText}>
234
+ Cadastre um modelo com contexto `menu` em Modelos HTML/Twig para
235
+ habilitar o download do cardapio.
236
+ </Text>
237
+ </View>
238
+ ) : (
239
+ <Picker
240
+ selectedValue={menuCatalogModel}
241
+ mode={GENERAL_SETTINGS_PICKER_MODE}
242
+ onValueChange={value => {
243
+ const nextModel = normalizeModelReference(value);
244
+ setMenuCatalogModel(nextModel);
245
+ saveMenuCatalogConfigs({model: nextModel});
246
+ }}
247
+ style={styles.Settings.picker}>
248
+ <Picker.Item
249
+ label="Selecione o modelo do cardapio"
250
+ value=""
251
+ />
252
+ {normalizedMenuModels.map(modelOption => (
253
+ <Picker.Item
254
+ key={`menu-model-${modelOption?.id || modelOption?.['@id']}`}
255
+ label={String(
256
+ modelOption?.model || `Modelo #${modelOption?.id || ''}`,
257
+ )}
258
+ value={normalizeModelReference(
259
+ modelOption?.['@id'] || modelOption?.id,
260
+ )}
261
+ />
262
+ ))}
263
+ </Picker>
264
+ )}
265
+ </View>
266
+
267
+ <Text style={localStyles.helperText}>
268
+ {menuCatalogModel
269
+ ? 'Modelo configurado para a empresa.'
270
+ : 'Nenhum modelo configurado ainda. Sem esse modelo, a rota publica de download retorna erro.'}
271
+ </Text>
272
+
273
+ <Text style={localStyles.helperText}>
274
+ {menuHiddenCategoryIds.length > 0 || menuHiddenGroupIds.length > 0
275
+ ? `${menuHiddenCategoryIds.length} categoria(s) e ${menuHiddenGroupIds.length} grupo(s) oculto(s) no PDF.`
276
+ : 'Nenhum filtro aplicado. O PDF usa todas as categorias e grupos visiveis da empresa.'}
277
+ </Text>
278
+
279
+ <View style={localStyles.fieldBlock}>
280
+ <Text style={localStyles.fieldLabel}>Categorias ocultas</Text>
281
+ <Text style={localStyles.helperText}>
282
+ Toque nas categorias que nao devem aparecer no cardapio gerado.
283
+ </Text>
284
+
285
+ {isLoadingMenuCategories ? (
286
+ <ActivityIndicator
287
+ size="small"
288
+ style={localStyles.sectionLoader}
289
+ color={themePalette.loadingSpinner}
290
+ />
291
+ ) : normalizedMenuCategories.length === 0 ? (
292
+ <View style={localStyles.emptyBox}>
293
+ <Text style={localStyles.emptyTitle}>
294
+ Nenhuma categoria encontrada
295
+ </Text>
296
+ <Text style={localStyles.emptyText}>
297
+ Cadastre categorias de produtos para controlar a visibilidade
298
+ delas no PDF do cardapio.
299
+ </Text>
300
+ </View>
301
+ ) : (
302
+ <View style={localStyles.printerList}>
303
+ {normalizedMenuCategories.map(categoryOption => {
304
+ const categoryId = String(categoryOption?.id || '').trim();
305
+ const hidden = menuHiddenCategoryIds.includes(categoryId);
306
+
307
+ return (
308
+ <TouchableOpacity
309
+ key={`menu-category-${categoryId}`}
310
+ style={[
311
+ localStyles.printerItem,
312
+ hidden && localStyles.printerItemActive,
313
+ ]}
314
+ activeOpacity={0.85}
315
+ onPress={() => toggleMenuHiddenCategory(categoryId)}>
316
+ <Icon
317
+ name={hidden ? 'visibility-off' : 'category'}
318
+ size={20}
319
+ color={
320
+ hidden
321
+ ? themePalette.iconActive
322
+ : themePalette.iconDisabled
323
+ }
324
+ />
325
+ <View style={localStyles.printerCopy}>
326
+ <Text style={localStyles.printerName}>
327
+ {categoryOption?.name || `Categoria #${categoryId}`}
328
+ </Text>
329
+ <Text style={localStyles.printerDevice}>
330
+ {hidden ? 'Oculta no PDF' : 'Visivel no PDF'}
331
+ </Text>
332
+ </View>
333
+ </TouchableOpacity>
334
+ );
335
+ })}
336
+ </View>
337
+ )}
338
+ </View>
339
+
340
+ <View style={localStyles.fieldBlock}>
341
+ <Text style={localStyles.fieldLabel}>Grupos ocultos</Text>
342
+ <Text style={localStyles.helperText}>
343
+ Esses grupos deixam de aparecer dentro dos produtos customizaveis no
344
+ cardapio em PDF.
345
+ </Text>
346
+
347
+ {isLoadingMenuGroups ? (
348
+ <ActivityIndicator
349
+ size="small"
350
+ style={localStyles.sectionLoader}
351
+ color={themePalette.loadingSpinner}
352
+ />
353
+ ) : normalizedMenuGroups.length === 0 ? (
354
+ <View style={localStyles.emptyBox}>
355
+ <Text style={localStyles.emptyTitle}>
356
+ Nenhum grupo de customizacao encontrado
357
+ </Text>
358
+ <Text style={localStyles.emptyText}>
359
+ Os grupos sao lidos dos produtos customizaveis da empresa.
360
+ </Text>
361
+ </View>
362
+ ) : (
363
+ <View style={localStyles.printerList}>
364
+ {normalizedMenuGroups.map(groupOption => {
365
+ const groupId = String(groupOption?.id || '').trim();
366
+ const hidden = menuHiddenGroupIds.includes(groupId);
367
+
368
+ return (
369
+ <TouchableOpacity
370
+ key={`menu-group-${groupId}`}
371
+ style={[
372
+ localStyles.printerItem,
373
+ hidden && localStyles.printerItemActive,
374
+ ]}
375
+ activeOpacity={0.85}
376
+ onPress={() => toggleMenuHiddenGroup(groupId)}>
377
+ <Icon
378
+ name={hidden ? 'visibility-off' : 'tune'}
379
+ size={20}
380
+ color={
381
+ hidden
382
+ ? themePalette.iconActive
383
+ : themePalette.iconDisabled
384
+ }
385
+ />
386
+ <View style={localStyles.printerCopy}>
387
+ <Text style={localStyles.printerName}>
388
+ {getMenuGroupOptionLabel(groupOption)}
389
+ </Text>
390
+ <Text style={localStyles.printerDevice}>
391
+ {hidden ? 'Oculto no PDF' : 'Visivel no PDF'}
392
+ </Text>
393
+ </View>
394
+ </TouchableOpacity>
395
+ );
396
+ })}
397
+ </View>
398
+ )}
399
+ </View>
400
+
401
+ </GeneralSettingsSection>
402
+ );
403
+ };
404
+
405
+ export default MenuCatalogSection;
@@ -0,0 +1,303 @@
1
+ /*
2
+ * @agents This section controls the POS defaults for statuses, wallets, and notifications.
3
+ * The visible options must come from the shared stores and save back through the config contract.
4
+ */
5
+ import React, {useCallback, useEffect, useMemo, useState} from 'react';
6
+ import {Text, TextInput, View} from 'react-native';
7
+ import {Picker} from '@react-native-picker/picker';
8
+
9
+ import css from '@controleonline/ui-orders/src/react/css/orders';
10
+ import {useStore} from '@store';
11
+ import useToastMessage from '@controleonline/ui-crm/src/react/hooks/useToastMessage';
12
+
13
+ import {
14
+ useGeneralSettingsPalette,
15
+ useGeneralSettingsStyles,
16
+ } from '../GeneralSettings.styles';
17
+ import GeneralSettingsSection from '../GeneralSettingsSection';
18
+ import {
19
+ GENERAL_SETTINGS_PICKER_MODE,
20
+ normalizeNotificationTargets,
21
+ useGeneralSettingsConfig,
22
+ } from '../GeneralSettings.shared';
23
+
24
+ const OperationsSection = () => {
25
+ const {styles} = css();
26
+ const localStyles = useGeneralSettingsStyles();
27
+ const themePalette = useGeneralSettingsPalette();
28
+ const {showError, showSuccess} = useToastMessage();
29
+ const {currentCompany, effectiveCompanyConfigs, saveConfigs} =
30
+ useGeneralSettingsConfig();
31
+
32
+ const statusStore = useStore('status');
33
+ const {items: statuses = []} = statusStore.getters;
34
+ const statusActions = statusStore.actions;
35
+
36
+ const walletStore = useStore('wallet');
37
+ const {items: wallets = []} = walletStore.getters;
38
+ const walletActions = walletStore.actions;
39
+
40
+ const [posDefaultStatus, setPosDefaultStatus] = useState('');
41
+ const [posPaidStatus, setPosPaidStatus] = useState('');
42
+ const [posCashWallet, setPosCashWallet] = useState('');
43
+ const [posWithdrawWallet, setPosWithdrawWallet] = useState('');
44
+ const [posCieloWallet, setPosCieloWallet] = useState('');
45
+ const [posInfinitePayWallet, setPosInfinitePayWallet] = useState('');
46
+ const [cashRegisterNotifications, setCashRegisterNotifications] = useState('');
47
+
48
+ useEffect(() => {
49
+ setPosDefaultStatus(String(effectiveCompanyConfigs['pos-default-status'] || ''));
50
+ setPosPaidStatus(String(effectiveCompanyConfigs['pos-paid-status'] || ''));
51
+ setPosCashWallet(String(effectiveCompanyConfigs['pos-cash-wallet'] || ''));
52
+ setPosWithdrawWallet(
53
+ String(
54
+ effectiveCompanyConfigs['pos-withdrawl-wallet'] ||
55
+ effectiveCompanyConfigs['pos-withdrawal-wallet'] ||
56
+ '',
57
+ ),
58
+ );
59
+ setPosCieloWallet(String(effectiveCompanyConfigs['pos-cielo-wallet'] || ''));
60
+ setPosInfinitePayWallet(
61
+ String(effectiveCompanyConfigs['pos-infinite-pay-wallet'] || ''),
62
+ );
63
+ setCashRegisterNotifications(
64
+ normalizeNotificationTargets(
65
+ effectiveCompanyConfigs['cash-register-notifications'],
66
+ ).join('\n'),
67
+ );
68
+ }, [effectiveCompanyConfigs]);
69
+
70
+ useEffect(() => {
71
+ if (!currentCompany?.id) {
72
+ return;
73
+ }
74
+
75
+ statusActions.getItems({}).catch(() => {});
76
+ walletActions
77
+ .getItems({people: currentCompany.id})
78
+ .catch(() => {});
79
+ }, [currentCompany?.id, statusActions, walletActions]);
80
+
81
+ const normalizedStatusOptions = useMemo(
82
+ () => (Array.isArray(statuses) ? statuses : []),
83
+ [statuses],
84
+ );
85
+ const normalizedWalletOptions = useMemo(
86
+ () => (Array.isArray(wallets) ? wallets : []),
87
+ [wallets],
88
+ );
89
+
90
+ const saveOperationalConfigs = useCallback(
91
+ async ({
92
+ nextCashRegisterNotifications = cashRegisterNotifications,
93
+ nextPosCashWallet = posCashWallet,
94
+ nextPosCieloWallet = posCieloWallet,
95
+ nextPosDefaultStatus = posDefaultStatus,
96
+ nextPosInfinitePayWallet = posInfinitePayWallet,
97
+ nextPosPaidStatus = posPaidStatus,
98
+ nextPosWithdrawWallet = posWithdrawWallet,
99
+ } = {}) => {
100
+ if (!currentCompany?.id) {
101
+ showError('Selecione uma empresa para salvar as configuracoes.');
102
+ return false;
103
+ }
104
+
105
+ const success = await saveConfigs(
106
+ {
107
+ 'pos-default-status': String(nextPosDefaultStatus || '').trim(),
108
+ 'pos-paid-status': String(nextPosPaidStatus || '').trim(),
109
+ 'pos-cash-wallet': String(nextPosCashWallet || '').trim(),
110
+ 'pos-withdrawl-wallet': String(nextPosWithdrawWallet || '').trim(),
111
+ 'pos-cielo-wallet': String(nextPosCieloWallet || '').trim(),
112
+ 'pos-infinite-pay-wallet': String(nextPosInfinitePayWallet || '').trim(),
113
+ 'cash-register-notifications': normalizeNotificationTargets(
114
+ nextCashRegisterNotifications,
115
+ ),
116
+ },
117
+ {
118
+ suppressAlert: true,
119
+ },
120
+ );
121
+
122
+ if (!success) {
123
+ showError('Nao foi possivel salvar as configuracoes de Operacao e PDV.');
124
+ return false;
125
+ }
126
+
127
+ showSuccess('Configuracoes de Operacao e PDV salvas com sucesso.');
128
+ return true;
129
+ },
130
+ [
131
+ cashRegisterNotifications,
132
+ currentCompany?.id,
133
+ posCashWallet,
134
+ posCieloWallet,
135
+ posDefaultStatus,
136
+ posInfinitePayWallet,
137
+ posPaidStatus,
138
+ posWithdrawWallet,
139
+ saveConfigs,
140
+ showError,
141
+ showSuccess,
142
+ ],
143
+ );
144
+
145
+ return (
146
+ <GeneralSettingsSection
147
+ description="Status, carteiras e notificacoes usadas pelos fluxos de pedido, pagamento e fechamento de caixa."
148
+ icon="point-of-sale"
149
+ iconBackgroundColor={themePalette.cardIconBackground}
150
+ iconColor={themePalette.cardIconColor}
151
+ title="Operacao e PDV">
152
+ <View style={localStyles.fieldBlock}>
153
+ <Text style={localStyles.fieldLabel}>Status padrao do PDV</Text>
154
+ <Picker
155
+ selectedValue={posDefaultStatus}
156
+ mode={GENERAL_SETTINGS_PICKER_MODE}
157
+ onValueChange={value => {
158
+ const nextValue = String(value || '');
159
+ setPosDefaultStatus(nextValue);
160
+ saveOperationalConfigs({nextPosDefaultStatus: nextValue});
161
+ }}
162
+ style={styles.Settings.picker}>
163
+ <Picker.Item label="Selecione um status" value="" />
164
+ {normalizedStatusOptions.map(statusOption => (
165
+ <Picker.Item
166
+ key={statusOption.id}
167
+ label={`${statusOption.context || 'geral'} • ${statusOption.status}`}
168
+ value={String(statusOption.id)}
169
+ />
170
+ ))}
171
+ </Picker>
172
+ </View>
173
+
174
+ <View style={localStyles.fieldBlock}>
175
+ <Text style={localStyles.fieldLabel}>Status pago</Text>
176
+ <Picker
177
+ selectedValue={posPaidStatus}
178
+ mode={GENERAL_SETTINGS_PICKER_MODE}
179
+ onValueChange={value => {
180
+ const nextValue = String(value || '');
181
+ setPosPaidStatus(nextValue);
182
+ saveOperationalConfigs({nextPosPaidStatus: nextValue});
183
+ }}
184
+ style={styles.Settings.picker}>
185
+ <Picker.Item label="Selecione um status" value="" />
186
+ {normalizedStatusOptions.map(statusOption => (
187
+ <Picker.Item
188
+ key={`paid-${statusOption.id}`}
189
+ label={`${statusOption.context || 'geral'} • ${statusOption.status}`}
190
+ value={String(statusOption.id)}
191
+ />
192
+ ))}
193
+ </Picker>
194
+ </View>
195
+
196
+ <View style={localStyles.fieldBlock}>
197
+ <Text style={localStyles.fieldLabel}>Carteira de dinheiro</Text>
198
+ <Picker
199
+ selectedValue={posCashWallet}
200
+ mode={GENERAL_SETTINGS_PICKER_MODE}
201
+ onValueChange={value => {
202
+ const nextValue = String(value || '');
203
+ setPosCashWallet(nextValue);
204
+ saveOperationalConfigs({nextPosCashWallet: nextValue});
205
+ }}
206
+ style={styles.Settings.picker}>
207
+ <Picker.Item label="Selecione uma carteira" value="" />
208
+ {normalizedWalletOptions.map(walletOption => (
209
+ <Picker.Item
210
+ key={`cash-${walletOption.id}`}
211
+ label={walletOption.wallet}
212
+ value={String(walletOption.id)}
213
+ />
214
+ ))}
215
+ </Picker>
216
+ </View>
217
+
218
+ <View style={localStyles.fieldBlock}>
219
+ <Text style={localStyles.fieldLabel}>Carteira de sangria</Text>
220
+ <Picker
221
+ selectedValue={posWithdrawWallet}
222
+ mode={GENERAL_SETTINGS_PICKER_MODE}
223
+ onValueChange={value => {
224
+ const nextValue = String(value || '');
225
+ setPosWithdrawWallet(nextValue);
226
+ saveOperationalConfigs({nextPosWithdrawWallet: nextValue});
227
+ }}
228
+ style={styles.Settings.picker}>
229
+ <Picker.Item label="Selecione uma carteira" value="" />
230
+ {normalizedWalletOptions.map(walletOption => (
231
+ <Picker.Item
232
+ key={`withdraw-${walletOption.id}`}
233
+ label={walletOption.wallet}
234
+ value={String(walletOption.id)}
235
+ />
236
+ ))}
237
+ </Picker>
238
+ </View>
239
+
240
+ <View style={localStyles.fieldBlock}>
241
+ <Text style={localStyles.fieldLabel}>Carteira Cielo</Text>
242
+ <Picker
243
+ selectedValue={posCieloWallet}
244
+ mode={GENERAL_SETTINGS_PICKER_MODE}
245
+ onValueChange={value => {
246
+ const nextValue = String(value || '');
247
+ setPosCieloWallet(nextValue);
248
+ saveOperationalConfigs({nextPosCieloWallet: nextValue});
249
+ }}
250
+ style={styles.Settings.picker}>
251
+ <Picker.Item label="Selecione uma carteira" value="" />
252
+ {normalizedWalletOptions.map(walletOption => (
253
+ <Picker.Item
254
+ key={`cielo-${walletOption.id}`}
255
+ label={walletOption.wallet}
256
+ value={String(walletOption.id)}
257
+ />
258
+ ))}
259
+ </Picker>
260
+ </View>
261
+
262
+ <View style={localStyles.fieldBlock}>
263
+ <Text style={localStyles.fieldLabel}>Carteira Infinite Pay</Text>
264
+ <Picker
265
+ selectedValue={posInfinitePayWallet}
266
+ mode={GENERAL_SETTINGS_PICKER_MODE}
267
+ onValueChange={value => {
268
+ const nextValue = String(value || '');
269
+ setPosInfinitePayWallet(nextValue);
270
+ saveOperationalConfigs({nextPosInfinitePayWallet: nextValue});
271
+ }}
272
+ style={styles.Settings.picker}>
273
+ <Picker.Item label="Selecione uma carteira" value="" />
274
+ {normalizedWalletOptions.map(walletOption => (
275
+ <Picker.Item
276
+ key={`infinite-${walletOption.id}`}
277
+ label={walletOption.wallet}
278
+ value={String(walletOption.id)}
279
+ />
280
+ ))}
281
+ </Picker>
282
+ </View>
283
+
284
+ <View style={localStyles.fieldBlock}>
285
+ <Text style={localStyles.fieldLabel}>
286
+ Notificacoes de fechamento de caixa
287
+ </Text>
288
+ <TextInput
289
+ style={[localStyles.input, localStyles.multilineInput]}
290
+ value={cashRegisterNotifications}
291
+ multiline
292
+ numberOfLines={4}
293
+ onChangeText={setCashRegisterNotifications}
294
+ onBlur={() => saveOperationalConfigs()}
295
+ placeholder="Um numero por linha ou separado por virgula"
296
+ />
297
+ </View>
298
+
299
+ </GeneralSettingsSection>
300
+ );
301
+ };
302
+
303
+ export default OperationsSection;