@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,490 @@
1
+ /*
2
+ * @agents Shop general settings: home toggles, franchise locator, catalog, checkout, loyalty.
3
+ */
4
+ import React, {useCallback, useEffect, useMemo, useState} from 'react';
5
+ import {Text, TextInput, TouchableOpacity, View} from 'react-native';
6
+ import Icon from 'react-native-vector-icons/MaterialIcons';
7
+ import css from '@controleonline/ui-orders/src/react/css/orders';
8
+ import {
9
+ getEnabledShopHomeOptions,
10
+ normalizeBooleanConfig,
11
+ normalizeShopCatalogProductTypes,
12
+ normalizeShopMoneyConfig,
13
+ normalizeShopPrimaryEntry,
14
+ normalizeShopTextConfig,
15
+ SHOP_BOTTOM_BAR_ENABLED_CONFIG_KEY,
16
+ SHOP_CATALOG_DEFAULT_PRODUCT_TYPES,
17
+ SHOP_CATALOG_PRODUCT_TYPES_CONFIG_KEY,
18
+ SHOP_CHARGE_ON_DELIVERY_ENABLED_CONFIG_KEY,
19
+ SHOP_DELIVERY_FEE_ENABLED_CONFIG_KEY,
20
+ SHOP_DELIVERY_FEE_VALUE_CONFIG_KEY,
21
+ SHOP_FRANCHISE_LOCATOR_ENABLED_CONFIG_KEY,
22
+ SHOP_GOOGLE_MAPS_API_KEY_CONFIG_KEY,
23
+ SHOP_HOME_OPTION_FRANCHISE_LOCATOR,
24
+ SHOP_HOME_OPTION_LOYALTY,
25
+ SHOP_HOME_OPTION_SALES,
26
+ SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
27
+ SHOP_PRIMARY_ENTRY_CONFIG_KEY,
28
+ SHOP_SALES_PAGE_ENABLED_CONFIG_KEY,
29
+ saveAndUpdateConfigValue,
30
+ toggleAndSaveBooleanConfig,
31
+ } from '@controleonline/ui-common/src/react/utils/shopConfig';
32
+ import {
33
+ useGeneralSettingsPalette,
34
+ useGeneralSettingsStyles,
35
+ } from '../GeneralSettings.styles';
36
+ import GeneralSettingsSection from '../GeneralSettingsSection';
37
+ import {useGeneralSettingsConfig} from '../GeneralSettings.shared';
38
+ import {ConfigToggleRow} from './shop/shopSettingsShared';
39
+ import ShopFranchiseLocatorSection from './shop/ShopFranchiseLocatorSection';
40
+ import ShopLoyaltySection from './shop/ShopLoyaltySection';
41
+
42
+ const SHOP_HOME_OPTIONS = [
43
+ {
44
+ key: SHOP_HOME_OPTION_SALES,
45
+ label: 'Pagina de vendas',
46
+ description:
47
+ 'Libera a vitrine principal do shop para navegacao por categorias e produtos.',
48
+ },
49
+ {
50
+ key: SHOP_HOME_OPTION_FRANCHISE_LOCATOR,
51
+ label: 'Localizador de franquias',
52
+ description:
53
+ 'Libera a entrada do shop focada em encontrar unidades ou franquias.',
54
+ },
55
+ {
56
+ key: SHOP_HOME_OPTION_LOYALTY,
57
+ label: 'Cartao fidelidade',
58
+ description:
59
+ 'Libera a entrada do shop para acompanhar a fidelidade e os brindes.',
60
+ },
61
+ ];
62
+
63
+ const SHOP_CATALOG_PRODUCT_TYPE_OPTIONS = [
64
+ {
65
+ key: 'product',
66
+ label: 'Produtos',
67
+ description: 'Exibe produtos simples no cardapio do shop.',
68
+ },
69
+ {
70
+ key: 'manufactured',
71
+ label: 'Produtos fabricados',
72
+ description: 'Exibe itens produzidos ou montados pela loja.',
73
+ },
74
+ {
75
+ key: 'custom',
76
+ label: 'Produtos customizaveis',
77
+ description: 'Exibe itens com grupos de complementos e variacoes.',
78
+ },
79
+ {
80
+ key: 'service',
81
+ label: 'Servicos',
82
+ description: 'Exibe servicos quando a loja opera como shop de servicos.',
83
+ },
84
+ ];
85
+
86
+ const ShopSection = () => {
87
+ const {globalStyles} = css();
88
+ const localStyles = useGeneralSettingsStyles();
89
+ const {
90
+ currentCompany,
91
+ mainCompanyLabel,
92
+ effectiveCompanyConfigs,
93
+ isMainCompanySelected,
94
+ saveConfig,
95
+ saveConfigs,
96
+ } = useGeneralSettingsConfig();
97
+ const themePalette = useGeneralSettingsPalette();
98
+
99
+ const [salesPageEnabled, setSalesPageEnabled] = useState(false);
100
+ const [franchiseLocatorEnabled, setFranchiseLocatorEnabled] = useState(false);
101
+ const [bottomBarEnabled, setBottomBarEnabled] = useState(false);
102
+ const [chargeOnDeliveryEnabled, setChargeOnDeliveryEnabled] = useState(false);
103
+ const [deliveryFeeEnabled, setDeliveryFeeEnabled] = useState(false);
104
+ const [deliveryFeeValue, setDeliveryFeeValue] = useState('');
105
+ const [catalogProductTypes, setCatalogProductTypes] = useState(
106
+ SHOP_CATALOG_DEFAULT_PRODUCT_TYPES,
107
+ );
108
+ const [googleMapsApiKey, setGoogleMapsApiKey] = useState('');
109
+ const [primaryEntry, setPrimaryEntry] = useState('');
110
+ const [loyaltyCouponsEnabled, setLoyaltyCouponsEnabled] = useState(false);
111
+
112
+ useEffect(() => {
113
+ const nextSalesPageEnabled = normalizeBooleanConfig(
114
+ effectiveCompanyConfigs[SHOP_SALES_PAGE_ENABLED_CONFIG_KEY],
115
+ );
116
+ const nextFranchiseLocatorEnabled = normalizeBooleanConfig(
117
+ effectiveCompanyConfigs[SHOP_FRANCHISE_LOCATOR_ENABLED_CONFIG_KEY],
118
+ );
119
+ const nextLoyaltyCouponsEnabled = normalizeBooleanConfig(
120
+ effectiveCompanyConfigs[SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY],
121
+ );
122
+ setSalesPageEnabled(nextSalesPageEnabled);
123
+ setFranchiseLocatorEnabled(nextFranchiseLocatorEnabled);
124
+ setBottomBarEnabled(
125
+ normalizeBooleanConfig(
126
+ effectiveCompanyConfigs[SHOP_BOTTOM_BAR_ENABLED_CONFIG_KEY],
127
+ ),
128
+ );
129
+ setChargeOnDeliveryEnabled(
130
+ normalizeBooleanConfig(
131
+ effectiveCompanyConfigs[SHOP_CHARGE_ON_DELIVERY_ENABLED_CONFIG_KEY],
132
+ ),
133
+ );
134
+ setDeliveryFeeEnabled(
135
+ normalizeBooleanConfig(
136
+ effectiveCompanyConfigs[SHOP_DELIVERY_FEE_ENABLED_CONFIG_KEY],
137
+ ),
138
+ );
139
+ setDeliveryFeeValue(
140
+ String(
141
+ normalizeShopMoneyConfig(
142
+ effectiveCompanyConfigs[SHOP_DELIVERY_FEE_VALUE_CONFIG_KEY],
143
+ ) || '',
144
+ ),
145
+ );
146
+ setCatalogProductTypes(
147
+ normalizeShopCatalogProductTypes(
148
+ effectiveCompanyConfigs[SHOP_CATALOG_PRODUCT_TYPES_CONFIG_KEY],
149
+ ),
150
+ );
151
+ setGoogleMapsApiKey(
152
+ normalizeShopTextConfig(
153
+ effectiveCompanyConfigs[SHOP_GOOGLE_MAPS_API_KEY_CONFIG_KEY],
154
+ ),
155
+ );
156
+ setLoyaltyCouponsEnabled(nextLoyaltyCouponsEnabled);
157
+ setPrimaryEntry(
158
+ normalizeShopPrimaryEntry(
159
+ effectiveCompanyConfigs[SHOP_PRIMARY_ENTRY_CONFIG_KEY],
160
+ {
161
+ salesPageEnabled: nextSalesPageEnabled,
162
+ franchiseLocatorEnabled: nextFranchiseLocatorEnabled,
163
+ loyaltyCouponsEnabled: nextLoyaltyCouponsEnabled,
164
+ },
165
+ ),
166
+ );
167
+ }, [effectiveCompanyConfigs]);
168
+
169
+ useEffect(() => {
170
+ const nextPrimaryEntry = normalizeShopPrimaryEntry(primaryEntry, {
171
+ salesPageEnabled,
172
+ franchiseLocatorEnabled,
173
+ loyaltyCouponsEnabled,
174
+ });
175
+ if (nextPrimaryEntry === primaryEntry) {
176
+ return;
177
+ }
178
+ setPrimaryEntry(nextPrimaryEntry);
179
+ saveConfig(SHOP_PRIMARY_ENTRY_CONFIG_KEY, nextPrimaryEntry).catch(() => {});
180
+ }, [
181
+ franchiseLocatorEnabled,
182
+ loyaltyCouponsEnabled,
183
+ primaryEntry,
184
+ salesPageEnabled,
185
+ saveConfig,
186
+ ]);
187
+
188
+ const enabledHomeOptions = useMemo(
189
+ () =>
190
+ getEnabledShopHomeOptions({
191
+ salesPageEnabled,
192
+ franchiseLocatorEnabled,
193
+ loyaltyCouponsEnabled,
194
+ }),
195
+ [franchiseLocatorEnabled, loyaltyCouponsEnabled, salesPageEnabled],
196
+ );
197
+
198
+ const primaryEntryOptions = useMemo(
199
+ () =>
200
+ SHOP_HOME_OPTIONS.filter(option =>
201
+ enabledHomeOptions.includes(option.key),
202
+ ),
203
+ [enabledHomeOptions],
204
+ );
205
+
206
+ const toggleCatalogProductType = useCallback(
207
+ typeKey => {
208
+ const nextTypes = catalogProductTypes.includes(typeKey)
209
+ ? catalogProductTypes.filter(item => item !== typeKey)
210
+ : [...catalogProductTypes, typeKey];
211
+ const normalized = nextTypes.length
212
+ ? nextTypes
213
+ : SHOP_CATALOG_DEFAULT_PRODUCT_TYPES;
214
+ saveAndUpdateConfigValue({
215
+ configKey: SHOP_CATALOG_PRODUCT_TYPES_CONFIG_KEY,
216
+ nextValue: normalized,
217
+ saveConfig,
218
+ setValue: setCatalogProductTypes,
219
+ });
220
+ },
221
+ [catalogProductTypes, saveConfig],
222
+ );
223
+
224
+ if (!isMainCompanySelected) {
225
+ return (
226
+ <GeneralSettingsSection
227
+ description="Centraliza a configuracao da home do shop e das franquias visiveis no localizador."
228
+ icon="shopping-bag"
229
+ iconBackgroundColor={themePalette.cardIconBackground}
230
+ iconColor={themePalette.cardIconColor}
231
+ title="Home do shop">
232
+ <View style={localStyles.emptyBox}>
233
+ <Text style={localStyles.emptyTitle}>Disponivel na empresa principal</Text>
234
+ <Text style={localStyles.emptyText}>
235
+ Selecione a empresa principal ({mainCompanyLabel}) para configurar o shop.
236
+ </Text>
237
+ </View>
238
+ </GeneralSettingsSection>
239
+ );
240
+ }
241
+
242
+ return (
243
+ <>
244
+ <GeneralSettingsSection
245
+ description="Centraliza a configuracao da home do shop e das franquias visiveis no localizador."
246
+ icon="shopping-bag"
247
+ iconBackgroundColor={themePalette.cardIconBackground}
248
+ iconColor={themePalette.cardIconColor}
249
+ title="Home do shop">
250
+ <ConfigToggleRow
251
+ label="Pagina de vendas"
252
+ description="Libera a vitrine principal do shop."
253
+ palette={themePalette}
254
+ styles={localStyles}
255
+ value={salesPageEnabled}
256
+ onToggle={() =>
257
+ toggleAndSaveBooleanConfig({
258
+ configKey: SHOP_SALES_PAGE_ENABLED_CONFIG_KEY,
259
+ nextValue: !salesPageEnabled,
260
+ saveConfig,
261
+ setValue: setSalesPageEnabled,
262
+ })
263
+ }
264
+ />
265
+ <ConfigToggleRow
266
+ label="Localizador de franquias"
267
+ description="Libera a entrada do shop focada em encontrar unidades ou franquias."
268
+ palette={themePalette}
269
+ styles={localStyles}
270
+ value={franchiseLocatorEnabled}
271
+ onToggle={() =>
272
+ toggleAndSaveBooleanConfig({
273
+ configKey: SHOP_FRANCHISE_LOCATOR_ENABLED_CONFIG_KEY,
274
+ nextValue: !franchiseLocatorEnabled,
275
+ saveConfig,
276
+ setValue: setFranchiseLocatorEnabled,
277
+ })
278
+ }
279
+ />
280
+ <ConfigToggleRow
281
+ label="Cartao fidelidade"
282
+ description="Libera a entrada do shop para acompanhar a fidelidade e os brindes."
283
+ palette={themePalette}
284
+ styles={localStyles}
285
+ value={loyaltyCouponsEnabled}
286
+ onToggle={() =>
287
+ toggleAndSaveBooleanConfig({
288
+ configKey: SHOP_LOYALTY_COUPONS_ENABLED_CONFIG_KEY,
289
+ nextValue: !loyaltyCouponsEnabled,
290
+ saveConfig,
291
+ setValue: setLoyaltyCouponsEnabled,
292
+ })
293
+ }
294
+ />
295
+ <ConfigToggleRow
296
+ label="Barra inferior do shop"
297
+ description="Exibe a navegacao inferior nas telas do shop."
298
+ palette={themePalette}
299
+ styles={localStyles}
300
+ value={bottomBarEnabled}
301
+ onToggle={() =>
302
+ toggleAndSaveBooleanConfig({
303
+ configKey: SHOP_BOTTOM_BAR_ENABLED_CONFIG_KEY,
304
+ nextValue: !bottomBarEnabled,
305
+ saveConfig,
306
+ setValue: setBottomBarEnabled,
307
+ })
308
+ }
309
+ />
310
+ <View style={localStyles.fieldBlock}>
311
+ <Text style={localStyles.fieldLabel}>Entrada principal</Text>
312
+ {primaryEntryOptions.length === 0 ? (
313
+ <Text style={localStyles.helperText}>
314
+ Ative ao menos uma opcao da home para definir a entrada principal.
315
+ </Text>
316
+ ) : (
317
+ primaryEntryOptions.map(option => {
318
+ const selected = primaryEntry === option.key;
319
+ const locked = primaryEntryOptions.length === 1;
320
+ return (
321
+ <TouchableOpacity
322
+ key={`shop-primary-entry-${option.key}`}
323
+ style={[
324
+ localStyles.printerItem,
325
+ selected && localStyles.printerItemActive,
326
+ ]}
327
+ activeOpacity={0.85}
328
+ disabled={locked}
329
+ onPress={() => {
330
+ if (locked || selected) return;
331
+ saveAndUpdateConfigValue({
332
+ configKey: SHOP_PRIMARY_ENTRY_CONFIG_KEY,
333
+ nextValue: option.key,
334
+ saveConfig,
335
+ setValue: setPrimaryEntry,
336
+ });
337
+ }}>
338
+ <Icon
339
+ name={selected ? 'check-circle' : 'radio-button-unchecked'}
340
+ size={20}
341
+ color={
342
+ selected ? themePalette.iconActive : themePalette.iconDisabled
343
+ }
344
+ />
345
+ <View style={localStyles.printerCopy}>
346
+ <Text style={localStyles.printerName}>{option.label}</Text>
347
+ <Text style={localStyles.printerDevice}>{option.description}</Text>
348
+ </View>
349
+ </TouchableOpacity>
350
+ );
351
+ })
352
+ )}
353
+ </View>
354
+ <View style={localStyles.fieldBlock}>
355
+ <Text style={localStyles.fieldLabel}>Google Maps API Key</Text>
356
+ <TextInput
357
+ value={googleMapsApiKey}
358
+ onChangeText={setGoogleMapsApiKey}
359
+ onBlur={() =>
360
+ saveAndUpdateConfigValue({
361
+ configKey: SHOP_GOOGLE_MAPS_API_KEY_CONFIG_KEY,
362
+ nextValue: googleMapsApiKey,
363
+ saveConfig,
364
+ setValue: setGoogleMapsApiKey,
365
+ })
366
+ }
367
+ placeholder="Chave da API do Google Maps"
368
+ placeholderTextColor={themePalette.inputPlaceholderText}
369
+ style={localStyles.input}
370
+ />
371
+ </View>
372
+ <ShopFranchiseLocatorSection
373
+ currentCompanyId={currentCompany?.id}
374
+ effectiveCompanyConfigs={effectiveCompanyConfigs}
375
+ localStyles={localStyles}
376
+ saveConfigs={saveConfigs}
377
+ themePalette={themePalette}
378
+ globalStyles={globalStyles}
379
+ />
380
+ </GeneralSettingsSection>
381
+
382
+ <GeneralSettingsSection
383
+ description="Define quais tipos de itens aparecem no cardapio."
384
+ icon="category"
385
+ iconBackgroundColor={themePalette.cardIconBackground}
386
+ iconColor={themePalette.cardIconColor}
387
+ title="Catalogo do shop">
388
+ <View style={localStyles.printerList}>
389
+ {SHOP_CATALOG_PRODUCT_TYPE_OPTIONS.map(option => {
390
+ const selected = catalogProductTypes.includes(option.key);
391
+ return (
392
+ <TouchableOpacity
393
+ key={`shop-catalog-type-${option.key}`}
394
+ style={[
395
+ localStyles.printerItem,
396
+ selected && localStyles.printerItemActive,
397
+ ]}
398
+ activeOpacity={0.85}
399
+ onPress={() => toggleCatalogProductType(option.key)}>
400
+ <Icon
401
+ name={selected ? 'check-circle' : 'radio-button-unchecked'}
402
+ size={20}
403
+ color={
404
+ selected ? themePalette.iconActive : themePalette.iconDisabled
405
+ }
406
+ />
407
+ <View style={localStyles.printerCopy}>
408
+ <Text style={localStyles.printerName}>{option.label}</Text>
409
+ <Text style={localStyles.printerDevice}>{option.description}</Text>
410
+ </View>
411
+ </TouchableOpacity>
412
+ );
413
+ })}
414
+ </View>
415
+ </GeneralSettingsSection>
416
+
417
+ <GeneralSettingsSection
418
+ description="Opcoes de pagamento e taxa no checkout do shop."
419
+ icon="point-of-sale"
420
+ iconBackgroundColor={themePalette.cardIconBackground}
421
+ iconColor={themePalette.cardIconColor}
422
+ title="Checkout do shop">
423
+ <ConfigToggleRow
424
+ label="Cobrar na entrega"
425
+ description="Libera registrar pedidos pagos manualmente na entrega."
426
+ palette={themePalette}
427
+ styles={localStyles}
428
+ value={chargeOnDeliveryEnabled}
429
+ onToggle={() =>
430
+ toggleAndSaveBooleanConfig({
431
+ configKey: SHOP_CHARGE_ON_DELIVERY_ENABLED_CONFIG_KEY,
432
+ nextValue: !chargeOnDeliveryEnabled,
433
+ saveConfig,
434
+ setValue: setChargeOnDeliveryEnabled,
435
+ })
436
+ }
437
+ />
438
+ <ConfigToggleRow
439
+ label="Taxa de entrega"
440
+ description="Habilita cobranca de taxa de entrega no checkout."
441
+ palette={themePalette}
442
+ styles={localStyles}
443
+ value={deliveryFeeEnabled}
444
+ onToggle={() =>
445
+ toggleAndSaveBooleanConfig({
446
+ configKey: SHOP_DELIVERY_FEE_ENABLED_CONFIG_KEY,
447
+ nextValue: !deliveryFeeEnabled,
448
+ saveConfig,
449
+ setValue: setDeliveryFeeEnabled,
450
+ })
451
+ }
452
+ />
453
+ {deliveryFeeEnabled ? (
454
+ <View style={localStyles.fieldBlock}>
455
+ <Text style={localStyles.fieldLabel}>Valor da taxa de entrega</Text>
456
+ <TextInput
457
+ value={deliveryFeeValue}
458
+ onChangeText={setDeliveryFeeValue}
459
+ onBlur={() =>
460
+ saveAndUpdateConfigValue({
461
+ configKey: SHOP_DELIVERY_FEE_VALUE_CONFIG_KEY,
462
+ nextValue: deliveryFeeValue,
463
+ saveConfig,
464
+ setValue: setDeliveryFeeValue,
465
+ })
466
+ }
467
+ keyboardType="decimal-pad"
468
+ placeholder="0,00"
469
+ placeholderTextColor={themePalette.inputPlaceholderText}
470
+ style={localStyles.input}
471
+ />
472
+ </View>
473
+ ) : null}
474
+ </GeneralSettingsSection>
475
+
476
+ <ShopLoyaltySection
477
+ effectiveCompanyConfigs={effectiveCompanyConfigs}
478
+ localStyles={localStyles}
479
+ saveConfig={saveConfig}
480
+ themePalette={themePalette}
481
+ globalStyles={globalStyles}
482
+ currentCompanyId={currentCompany?.id}
483
+ loyaltyCouponsEnabled={loyaltyCouponsEnabled}
484
+ setLoyaltyCouponsEnabled={setLoyaltyCouponsEnabled}
485
+ />
486
+ </>
487
+ );
488
+ };
489
+
490
+ export default ShopSection;
@@ -0,0 +1,124 @@
1
+ /*
2
+ * fluxo: outros | etapa: general-settings-mapas-map-preview
3
+ * https://github.com/ControleOnline/app-community/wiki/Smoke-Test-Flows
4
+ * Preview map (Leaflet iframe / static image) for selected franchise pins.
5
+ * Outer box = full content width; Leaflet HTML gets explicit px size so the
6
+ * map fills the iframe (srcDoc % height often leaves empty space on the right).
7
+ */
8
+ import React, {createElement, useState} from 'react';
9
+ import {ActivityIndicator, Image, Platform, Text, View} from 'react-native';
10
+ import {
11
+ buildLeafletMapHtml,
12
+ buildOsmStaticMapUrl,
13
+ buildStaticMapUrl,
14
+ } from './mapsFranchiseMapHelpers';
15
+
16
+ const MAP_HEIGHT = 360;
17
+
18
+ const FranchiseMapPreview = ({
19
+ isLoading,
20
+ mapMarkers,
21
+ webGoogleMapsApiKey,
22
+ localStyles,
23
+ themePalette,
24
+ visibleFranchiseCompanyIds = [],
25
+ }) => {
26
+ const [mapBoxWidth, setMapBoxWidth] = useState(0);
27
+
28
+ const staticMapUrl = buildStaticMapUrl({
29
+ apiKey: webGoogleMapsApiKey,
30
+ markers: mapMarkers,
31
+ size: '1280x480',
32
+ });
33
+ const osmStaticMapUrl = buildOsmStaticMapUrl(mapMarkers, '1280x480');
34
+ const leafletMapHtml =
35
+ mapBoxWidth > 0
36
+ ? buildLeafletMapHtml(mapMarkers, {
37
+ width: mapBoxWidth,
38
+ height: MAP_HEIGHT,
39
+ })
40
+ : '';
41
+ const previewMapUrl = staticMapUrl || osmStaticMapUrl;
42
+
43
+ return (
44
+ <View
45
+ style={[localStyles.fieldBlock, {alignSelf: 'stretch', width: '100%'}]}
46
+ testID="maps-franchise-map">
47
+ <Text style={localStyles.fieldLabel}>Mapa das franquias</Text>
48
+ <Text style={localStyles.helperText}>
49
+ Pins das franquias marcadas acima (com latitude/longitude).
50
+ </Text>
51
+ {isLoading ? (
52
+ <ActivityIndicator
53
+ size="small"
54
+ color={themePalette.loadingSpinner || themePalette.primary}
55
+ style={localStyles.sectionLoader}
56
+ />
57
+ ) : mapMarkers.length === 0 ? (
58
+ <View style={localStyles.emptyBox}>
59
+ <Text style={localStyles.emptyTitle}>Nenhum pin para exibir</Text>
60
+ <Text style={localStyles.emptyText}>
61
+ Marque franquias com latitude/longitude na lista acima para
62
+ aparecerem no mapa.
63
+ </Text>
64
+ </View>
65
+ ) : (
66
+ <View style={{alignSelf: 'stretch', width: '100%'}}>
67
+ <View
68
+ onLayout={event => {
69
+ const nextWidth = Math.round(
70
+ event?.nativeEvent?.layout?.width || 0,
71
+ );
72
+ if (nextWidth > 0 && nextWidth !== mapBoxWidth) {
73
+ setMapBoxWidth(nextWidth);
74
+ }
75
+ }}
76
+ style={{
77
+ alignSelf: 'stretch',
78
+ width: '100%',
79
+ height: MAP_HEIGHT,
80
+ borderRadius: 8,
81
+ overflow: 'hidden',
82
+ backgroundColor: themePalette.inputBackground || '#eee',
83
+ }}>
84
+ {Platform.OS === 'web' && leafletMapHtml && mapBoxWidth > 0
85
+ ? createElement('iframe', {
86
+ key: `franchise-map-${mapBoxWidth}-${mapMarkers.length}`,
87
+ title: 'Mapa das franquias',
88
+ srcDoc: leafletMapHtml,
89
+ width: mapBoxWidth,
90
+ height: MAP_HEIGHT,
91
+ style: {
92
+ width: mapBoxWidth,
93
+ height: MAP_HEIGHT,
94
+ border: 'none',
95
+ display: 'block',
96
+ margin: 0,
97
+ padding: 0,
98
+ maxWidth: '100%',
99
+ },
100
+ })
101
+ : previewMapUrl
102
+ ? (
103
+ <Image
104
+ source={{uri: previewMapUrl}}
105
+ style={{width: '100%', height: MAP_HEIGHT}}
106
+ resizeMode="cover"
107
+ accessibilityLabel="Mapa das franquias com pins"
108
+ />
109
+ )
110
+ : null}
111
+ </View>
112
+ <Text style={localStyles.helperText}>
113
+ {mapMarkers.length} pin(s) no mapa
114
+ {visibleFranchiseCompanyIds.length > 0
115
+ ? ` · ${visibleFranchiseCompanyIds.length} franquia(s) selecionada(s)`
116
+ : ''}
117
+ </Text>
118
+ </View>
119
+ )}
120
+ </View>
121
+ );
122
+ };
123
+
124
+ export default FranchiseMapPreview;
@@ -0,0 +1,57 @@
1
+ import React, {useState} from 'react';
2
+ import {Text, TextInput, TouchableOpacity, View} from 'react-native';
3
+ import Icon from 'react-native-vector-icons/MaterialIcons';
4
+
5
+ import useShopDomainShowcasesStyles from './ShopDomainShowcasesSection.styles';
6
+
7
+ const t = (type, key) => global.t?.t?.('configs', type, key);
8
+
9
+ const normalizeDomain = value =>
10
+ String(value || '')
11
+ .trim()
12
+ .replace(/^https?:\/\//i, '')
13
+ .replace(/\/.*$/u, '')
14
+ .toLowerCase();
15
+
16
+ const ShopDomainCreateForm = ({onCancel, onCreate, palette}) => {
17
+ const styles = useShopDomainShowcasesStyles();
18
+ const [domain, setDomain] = useState('');
19
+ const normalizedDomain = normalizeDomain(domain);
20
+ const disabled = normalizedDomain === '';
21
+
22
+ return (
23
+ <View style={styles.createPanel}>
24
+ <Text style={styles.panelTitle}>{t('title', 'newShopDomain')}</Text>
25
+ <TextInput
26
+ autoCapitalize="none"
27
+ autoCorrect={false}
28
+ onChangeText={setDomain}
29
+ placeholder={t('placeholder', 'shopDomain')}
30
+ style={styles.domainInput}
31
+ value={domain}
32
+ />
33
+ <View style={styles.createActions}>
34
+ <TouchableOpacity
35
+ activeOpacity={0.85}
36
+ onPress={onCancel}
37
+ style={styles.secondaryButton}>
38
+ <Text style={styles.secondaryButtonText}>
39
+ {t('button', 'cancel')}
40
+ </Text>
41
+ </TouchableOpacity>
42
+ <TouchableOpacity
43
+ activeOpacity={0.85}
44
+ disabled={disabled}
45
+ onPress={() => onCreate(normalizedDomain)}
46
+ style={[styles.primaryButton, disabled && styles.disabledButton]}>
47
+ <Icon name="add" size={16} color={palette.buttonText} />
48
+ <Text style={styles.primaryButtonText}>
49
+ {t('button', 'createShopDomain')}
50
+ </Text>
51
+ </TouchableOpacity>
52
+ </View>
53
+ </View>
54
+ );
55
+ };
56
+
57
+ export default ShopDomainCreateForm;