@controleonline/ui-common 1.2.70 → 1.2.75

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 (188) 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 +168 -0
  6. package/.github/workflows/publish-npm.yml +45 -0
  7. package/.gitmodules +3 -0
  8. package/AGENTS.md +6 -0
  9. package/README.md +14 -0
  10. package/package.json +32 -28
  11. package/src/api/fetch.js +1 -1
  12. package/src/api/index.js +328 -58
  13. package/src/react/components/AddImportModal.js +95 -111
  14. package/src/react/components/AnimatedModal.js +171 -0
  15. package/src/react/components/AnimatedModal.styles.js +21 -0
  16. package/src/react/components/AppTypeSwitcher.js +164 -0
  17. package/src/react/components/AppTypeSwitcher.styles.js +109 -0
  18. package/src/react/components/BackgroundRuntimeBridge.js +5 -4
  19. package/src/react/components/BottomNavigationBar.config.js +211 -231
  20. package/src/react/components/BottomNavigationBar.js +86 -31
  21. package/src/react/components/BottomNavigationBar.styles.js +118 -110
  22. package/src/react/components/CategoryForm.js +52 -35
  23. package/src/react/components/DefaultProvider.native.js +194 -156
  24. package/src/react/components/DefaultProvider.web.js +188 -112
  25. package/src/react/components/DeliveryPushBridge.native.js +2 -2
  26. package/src/react/components/DeviceAlertSoundService.js +3 -3
  27. package/src/react/components/KioskModeBridge.js +2 -2
  28. package/src/react/components/LauncherModeBridge.js +2 -2
  29. package/src/react/components/ManagerPushBridge.native.js +2 -2
  30. package/src/react/components/NetworkPrinterPreviewModal.js +249 -0
  31. package/src/react/components/NetworkPrinterPreviewModal.styles.js +159 -0
  32. package/src/react/components/RemoteCheckoutService.js +28 -20
  33. package/src/react/components/RuntimeBottomNavigationBar.js +146 -119
  34. package/src/react/components/RuntimeInfoFooter.js +137 -45
  35. package/src/react/components/RuntimeInfoFooter.styles.js +3 -0
  36. package/src/react/components/StateStore.js +258 -0
  37. package/src/react/components/UnifiedPaymentBar.js +7 -4
  38. package/src/react/components/UserAvatar.js +160 -0
  39. package/src/react/components/WebsocketListener.native.js +11 -11
  40. package/src/react/components/integrations/IntegrationHero/index.js +48 -0
  41. package/src/react/components/integrations/IntegrationHero/styles.js +57 -0
  42. package/src/react/components/integrations/IntegrationTabs/index.js +89 -0
  43. package/src/react/components/integrations/IntegrationTabs/styles.js +44 -0
  44. package/src/react/config/deviceConfigBootstrap.js +71 -30
  45. package/src/react/css/orders.js +72 -0
  46. package/src/react/pages/Connections.js +229 -0
  47. package/src/react/pages/Connections.styles.js +222 -0
  48. package/src/react/pages/DeviceDetailPage.js +2814 -0
  49. package/src/react/pages/DeviceDetailPage.styles.js +308 -0
  50. package/src/react/pages/Devices/currentDevice.js +194 -0
  51. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +257 -0
  52. package/src/react/pages/Devices/deviceTypes/all.js +23 -0
  53. package/src/react/pages/Devices/deviceTypes/device.js +25 -0
  54. package/src/react/pages/Devices/deviceTypes/deviceListHelpers.js +178 -0
  55. package/src/react/pages/Devices/deviceTypes/display.js +26 -0
  56. package/src/react/pages/Devices/deviceTypes/index.js +145 -0
  57. package/src/react/pages/Devices/deviceTypes/ipCamera.js +35 -0
  58. package/src/react/pages/Devices/deviceTypes/pdv.js +88 -0
  59. package/src/react/pages/Devices/deviceTypes/printer.js +37 -0
  60. package/src/react/pages/Devices/deviceTypes/shared.js +453 -0
  61. package/src/react/pages/Devices/deviceTypes/useDeviceNetworkConnectivity.js +145 -0
  62. package/src/react/pages/Devices.js +183 -0
  63. package/src/react/pages/Devices.styles.js +353 -0
  64. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -0
  65. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -0
  66. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -0
  67. package/src/react/pages/Food99IntegrationPage/components/Food99ProductCard.js +1 -0
  68. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +181 -0
  69. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -0
  70. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -0
  71. package/src/react/pages/Food99IntegrationPage/index.js +1530 -0
  72. package/src/react/pages/Food99IntegrationPage/styles.js +792 -0
  73. package/src/react/pages/Food99IntegrationPage/utils.js +155 -0
  74. package/src/react/pages/Food99IntegrationPage.js +1 -0
  75. package/src/react/pages/Food99IntegrationPage.styles.js +1 -0
  76. package/src/react/pages/GenericLogPage.js +42 -167
  77. package/src/react/pages/IFoodIntegrationPage/components/IFoodCatalogTab.js +8 -0
  78. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +420 -0
  79. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -0
  80. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +103 -0
  81. package/src/react/pages/IFoodIntegrationPage/components/IFoodProductCard.js +1 -0
  82. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -0
  83. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -0
  84. package/src/react/pages/IFoodIntegrationPage/styles.js +764 -0
  85. package/src/react/pages/IFoodIntegrationPage/utils.js +91 -0
  86. package/src/react/pages/IFoodIntegrationPage.js +1 -0
  87. package/src/react/pages/IFoodIntegrationPage.styles.js +1 -0
  88. package/src/react/pages/Imports.js +214 -166
  89. package/src/react/pages/IntegrationConfigPage.js +744 -0
  90. package/src/react/pages/IntegrationConfigPage.styles.js +269 -0
  91. package/src/react/pages/Integrations.js +299 -0
  92. package/src/react/pages/Integrations.styles.js +130 -0
  93. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -0
  94. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -0
  95. package/src/react/pages/MarketplaceIntegrationPage/components/RemoteMarketplaceMenuTab.js +335 -0
  96. package/src/react/pages/MarketplaceIntegrationPage/index.js +60 -0
  97. package/src/react/pages/MarketplaceIntegrationPage/utils.js +137 -0
  98. package/src/react/pages/MercadoLivreIntegrationPage.js +538 -0
  99. package/src/react/pages/PrinterDeviceDetailPage.js +1916 -0
  100. package/src/react/pages/PrinterDeviceDetailPage.styles.js +223 -0
  101. package/src/react/pages/PrinterDeviceFormPage.js +521 -0
  102. package/src/react/pages/PrinterDeviceFormPage.styles.js +159 -0
  103. package/src/react/pages/SettingsPage/PaymentTypesByWalletTab.js +484 -454
  104. package/src/react/pages/SettingsPage/index.js +1266 -1167
  105. package/src/react/pages/WhatsAppConnectionPage.js +459 -0
  106. package/src/react/pages/WhatsAppConnectionPage.styles.js +284 -0
  107. package/src/react/pages/integrationsCatalog.js +399 -0
  108. package/src/react/print/providers/local.js +1 -1
  109. package/src/react/router/publicRoutes.js +25 -0
  110. package/src/react/services/Cielo/Checkout.js +39 -0
  111. package/src/react/services/Cielo/Cielo.js +193 -0
  112. package/src/react/services/Cielo/Print.js +7 -0
  113. package/src/react/services/InfinitePay/Checkout.js +33 -0
  114. package/src/react/services/InfinitePay/InfinitePay.js +24 -0
  115. package/src/react/{utils → services}/paymentGatewayExecution.js +91 -91
  116. package/src/react/styles/global.js +115 -0
  117. package/src/react/utils/categoryContexts.js +46 -0
  118. package/src/react/utils/entityDisplay.js +222 -217
  119. package/src/react/utils/fileUrl.js +201 -16
  120. package/src/react/utils/integrationPage.js +16 -0
  121. package/src/react/utils/menuNavigation.js +31 -0
  122. package/src/react/utils/orderIdentity.js +277 -0
  123. package/src/react/utils/remotePayment.js +115 -61
  124. package/src/react/utils/runtimeFooter.js +40 -22
  125. package/src/react/utils/runtimeLanguage.js +50 -9
  126. package/src/react/utils/runtimeMenu.js +190 -98
  127. package/src/react/utils/runtimeZoom.js +43 -0
  128. package/src/react/utils/shopConfig.js +72 -34
  129. package/src/react/utils/shopFranchises.js +182 -23
  130. package/src/react/utils/socketRuntimePipeline.js +14 -14
  131. package/src/react/utils/storeColumns.js +23 -4
  132. package/src/react/utils/userAvatar.js +104 -0
  133. package/src/store/categories/index.js +48 -20
  134. package/src/store/configs/index.js +2 -2
  135. package/src/store/device_config/index.js +62 -21
  136. package/src/store/entity_log/index.js +22 -1
  137. package/src/store/imports/customActions.js +51 -0
  138. package/src/store/imports/index.js +89 -88
  139. package/src/store/status/index.js +11 -11
  140. package/src/store/themes/index.js +22 -0
  141. package/src/store/timezones/index.js +3 -1
  142. package/src/tests/browser/manager/connections.spec.js +143 -0
  143. package/src/tests/browser/manager/devices-current.spec.js +343 -0
  144. package/src/tests/browser/manager/mercado-livre-integration.spec.js +268 -0
  145. package/src/tests/react/api/deviceHeaders.test.js +114 -0
  146. package/src/tests/react/api/loadSmokeIndex.test.js +75 -0
  147. package/src/tests/react/components/AddImportModal.test.js +166 -0
  148. package/src/tests/react/components/BottomNavigationBar.config.test.js +20 -0
  149. package/src/tests/react/components/UserAvatar.test.js +52 -0
  150. package/src/tests/react/config/deviceConfigBootstrap.test.js +47 -0
  151. package/src/tests/react/pages/DevicePickerStyles.test.js +47 -0
  152. package/src/tests/react/pages/Devices/deviceListHelpers.test.js +39 -0
  153. package/src/tests/react/pages/DevicesCurrentDevice.test.js +198 -0
  154. package/src/tests/react/pages/connectionsHelpers.test.js +34 -0
  155. package/src/tests/react/pages/mercadoLivreIntegrationPageContract.test.mjs +16 -0
  156. package/src/tests/react/print/localPrintProvider.test.js +1 -1
  157. package/src/tests/react/services/Cielo.test.js +190 -0
  158. package/src/tests/react/store/categoriesOrdering.test.js +26 -0
  159. package/src/tests/react/utils/appDomain.test.js +62 -0
  160. package/src/tests/react/utils/entityDisplay.test.js +2 -2
  161. package/src/tests/react/utils/fileUrl.test.js +62 -0
  162. package/src/tests/react/utils/formatter.test.mjs +33 -0
  163. package/src/tests/react/utils/importStatus.test.js +2 -2
  164. package/src/tests/react/utils/orderIdentity.test.js +139 -0
  165. package/src/tests/react/utils/remotePayment.test.js +62 -0
  166. package/src/tests/react/utils/runtimeFooter.test.js +32 -9
  167. package/src/tests/react/utils/runtimeLanguage.test.js +80 -10
  168. package/src/tests/react/utils/runtimeMenu.test.js +195 -111
  169. package/src/tests/react/utils/runtimeZoom.test.js +38 -0
  170. package/src/tests/react/utils/shopConfig.test.js +75 -0
  171. package/src/tests/react/utils/shopFranchises.test.js +122 -12
  172. package/src/tests/react/utils/translate.discovery.test.mjs +170 -0
  173. package/src/tests/react/utils/translate.test.helpers.mjs +152 -0
  174. package/src/tests/react/utils/translate.test.mjs +252 -396
  175. package/src/tests/react/utils/userAvatar.test.js +63 -0
  176. package/src/utils/appDomain.js +15 -4
  177. package/src/utils/formatter.js +122 -16
  178. package/src/utils/integrationConfigs.js +1 -0
  179. package/src/utils/translate.js +277 -398
  180. package/src/utils/translateDiscovery.js +96 -0
  181. package/src/utils/translateNormalize.js +33 -0
  182. package/src/utils/translatePending.js +92 -0
  183. package/src/utils/translateStorage.js +142 -0
  184. package/.github/agents/developer.agent.md +0 -30
  185. package/.github/agents/devops.agent.md +0 -30
  186. package/.github/agents/qa.agent.md +0 -30
  187. package/.github/agents/security.agent.md +0 -30
  188. package/.github/workflows/npmjs.yml +0 -35
@@ -1,110 +1,118 @@
1
- import {Platform, StyleSheet} from 'react-native';
2
-
3
- const withAlpha = (color, alphaHex) => {
4
- const raw = String(color || '').trim().replace('#', '');
5
- if (/^[0-9a-fA-F]{6}$/.test(raw)) {
6
- return `#${raw}${alphaHex}`;
7
- }
8
-
9
- if (/^[0-9a-fA-F]{8}$/.test(raw)) {
10
- return `#${raw.slice(0, 6)}${alphaHex}`;
11
- }
12
-
13
- return color || '#1B5587';
14
- };
15
-
16
- const createStyles = ({
17
- primaryColor,
18
- dockBackground,
19
- borderColor,
20
- inactiveText,
21
- activeBg,
22
- activeBorder,
23
- }) =>
24
- StyleSheet.create({
25
- host: {
26
- position: Platform.OS === 'web' ? 'fixed' : 'absolute',
27
- left: 0,
28
- right: 0,
29
- bottom: 0,
30
- zIndex: 1000,
31
- backgroundColor: 'transparent',
32
- alignItems: 'stretch',
33
- },
34
- stack: {
35
- width: '100%',
36
- alignItems: 'stretch',
37
- },
38
- dock: {
39
- flexDirection: 'row',
40
- alignItems: 'center',
41
- justifyContent: 'space-between',
42
- minHeight: 64,
43
- paddingHorizontal: 8,
44
- paddingTop: 8,
45
- paddingBottom: 8,
46
- borderWidth: 1,
47
- borderBottomWidth: 0,
48
- borderColor,
49
- borderTopLeftRadius: 24,
50
- borderTopRightRadius: 24,
51
- borderBottomLeftRadius: 0,
52
- borderBottomRightRadius: 0,
53
- backgroundColor: dockBackground,
54
- overflow: 'hidden',
55
- ...(Platform.OS === 'android'
56
- ? {elevation: 10}
57
- : {
58
- shadowColor: '#0F172A',
59
- shadowOpacity: 0.12,
60
- shadowOffset: {width: 0, height: -6},
61
- shadowRadius: 14,
62
- }),
63
- },
64
- item: {
65
- flex: 1,
66
- minHeight: 44,
67
- alignItems: 'center',
68
- justifyContent: 'center',
69
- paddingVertical: 6,
70
- paddingHorizontal: 4,
71
- borderWidth: 1,
72
- borderColor: 'transparent',
73
- borderRadius: 18,
74
- },
75
- itemActive: {
76
- backgroundColor: activeBg,
77
- borderColor: activeBorder,
78
- },
79
- itemPressed: {
80
- opacity: 0.92,
81
- transform: [{scale: 0.99}],
82
- },
83
- itemDisabled: {
84
- opacity: 0.45,
85
- },
86
- iconWrap: {
87
- width: 24,
88
- height: 24,
89
- borderRadius: 999,
90
- alignItems: 'center',
91
- justifyContent: 'center',
92
- marginBottom: 4,
93
- backgroundColor: 'transparent',
94
- },
95
- iconWrapActive: {
96
- backgroundColor: withAlpha(primaryColor, '18'),
97
- },
98
- itemLabel: {
99
- fontSize: 12,
100
- fontWeight: '600',
101
- color: inactiveText,
102
- textAlign: 'center',
103
- },
104
- itemLabelActive: {
105
- color: primaryColor,
106
- fontWeight: '800',
107
- },
108
- });
109
-
110
- export default createStyles;
1
+ import {Platform, StyleSheet} from 'react-native';
2
+
3
+ const resolveWebShadowColor = shadowColor => {
4
+ if (typeof shadowColor !== 'string') {
5
+ return 'rgba(0, 0, 0, 0.12)';
6
+ }
7
+
8
+ const normalized = shadowColor.trim();
9
+ if (!normalized) {
10
+ return 'rgba(0, 0, 0, 0.12)';
11
+ }
12
+
13
+ if (/^#[0-9a-f]{3}$/i.test(normalized)) {
14
+ return `${normalized[0]}${normalized[1]}${normalized[1]}${normalized[2]}${normalized[2]}${normalized[3]}${normalized[3]}1f`;
15
+ }
16
+
17
+ if (/^#[0-9a-f]{6}$/i.test(normalized)) {
18
+ return `${normalized}1f`;
19
+ }
20
+
21
+ if (/^#[0-9a-f]{4}$/i.test(normalized) || /^#[0-9a-f]{8}$/i.test(normalized)) {
22
+ return normalized;
23
+ }
24
+
25
+ return normalized;
26
+ };
27
+
28
+ const createStyles = ({
29
+ activeBackground,
30
+ dockBackground,
31
+ dockBorder,
32
+ dockShadow,
33
+ activeBorder,
34
+ useModernWebChromeProps = false,
35
+ }) =>
36
+ StyleSheet.create({
37
+ host: {
38
+ position: Platform.OS === 'web' ? 'fixed' : 'absolute',
39
+ left: 0,
40
+ right: 0,
41
+ bottom: 0,
42
+ zIndex: 1000,
43
+ backgroundColor: 'transparent',
44
+ alignItems: 'stretch',
45
+ },
46
+ hostPointerEventsBoxNone: {
47
+ pointerEvents: 'box-none',
48
+ },
49
+ stack: {
50
+ width: '100%',
51
+ alignItems: 'stretch',
52
+ },
53
+ dock: {
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ justifyContent: 'space-between',
57
+ minHeight: 64,
58
+ paddingHorizontal: 8,
59
+ paddingTop: 8,
60
+ paddingBottom: 8,
61
+ borderWidth: 1,
62
+ borderBottomWidth: 0,
63
+ borderColor: dockBorder,
64
+ borderTopLeftRadius: 24,
65
+ borderTopRightRadius: 24,
66
+ borderBottomLeftRadius: 0,
67
+ borderBottomRightRadius: 0,
68
+ backgroundColor: dockBackground,
69
+ overflow: 'hidden',
70
+ ...(Platform.OS === 'android'
71
+ ? {elevation: 10}
72
+ : Platform.OS === 'web' && useModernWebChromeProps
73
+ ? {
74
+ boxShadow: `0px -6px 14px ${resolveWebShadowColor(dockShadow)}`,
75
+ }
76
+ : {
77
+ shadowColor: dockShadow,
78
+ shadowOpacity: 0.12,
79
+ shadowOffset: {width: 0, height: -6},
80
+ shadowRadius: 14,
81
+ }),
82
+ },
83
+ item: {
84
+ flex: 1,
85
+ minHeight: 44,
86
+ alignItems: 'center',
87
+ justifyContent: 'center',
88
+ paddingVertical: 6,
89
+ paddingHorizontal: 4,
90
+ borderWidth: 1,
91
+ borderColor: 'transparent',
92
+ borderRadius: 18,
93
+ },
94
+ itemActive: {
95
+ backgroundColor: activeBackground,
96
+ borderColor: activeBorder,
97
+ },
98
+ itemPressed: {
99
+ transform: [{scale: 0.99}],
100
+ },
101
+ itemDisabled: {},
102
+ iconWrap: {
103
+ width: 24,
104
+ height: 24,
105
+ borderRadius: 999,
106
+ alignItems: 'center',
107
+ justifyContent: 'center',
108
+ marginBottom: 4,
109
+ backgroundColor: 'transparent',
110
+ },
111
+ itemLabel: {
112
+ fontSize: 12,
113
+ fontWeight: '600',
114
+ textAlign: 'center',
115
+ },
116
+ });
117
+
118
+ export default createStyles;
@@ -10,10 +10,12 @@ import {
10
10
  Modal,
11
11
  } from 'react-native';
12
12
 
13
- import { MaterialCommunityIcons } from '@expo/vector-icons';
14
- import { useStore } from '@store';
15
- import styles from './CategoryForm.styles';
16
- import { inlineStyle_240_75 } from './CategoryForm.styles';
13
+ import { MaterialCommunityIcons } from '@expo/vector-icons';
14
+ import { useStore } from '@store';
15
+ import { colors } from '@controleonline/../../src/styles/colors';
16
+ import { resolveThemePalette } from '@controleonline/../../src/styles/branding';
17
+ import styles from './CategoryForm.styles';
18
+ import { inlineStyle_240_75 } from './CategoryForm.styles';
17
19
 
18
20
  /* ─── Paleta de cores predefinidas ─── */
19
21
  const PRESET_COLORS = [
@@ -131,11 +133,11 @@ const BottomModal = ({ visible, onClose, title, children }) => (
131
133
  );
132
134
 
133
135
  /* ─── Seletor de cor ─── */
134
- const ColorPicker = ({ value, onChange }) => {
135
- const [open, setOpen] = useState(false);
136
- const [hexInput, setHexInput] = useState(value || '#000000');
137
-
138
- useEffect(() => { setHexInput(value || '#000000'); }, [value]);
136
+ const ColorPicker = ({ defaultColor = '#CBD5E1', value, onChange }) => {
137
+ const [open, setOpen] = useState(false);
138
+ const [hexInput, setHexInput] = useState(value || defaultColor);
139
+
140
+ useEffect(() => { setHexInput(value || defaultColor); }, [defaultColor, value]);
139
141
 
140
142
  const applyHex = () => {
141
143
  const v = hexInput.startsWith('#') ? hexInput : `#${hexInput}`;
@@ -152,8 +154,8 @@ const ColorPicker = ({ value, onChange }) => {
152
154
  onPress={() => setOpen(true)}
153
155
  activeOpacity={0.7}
154
156
  >
155
- <View style={[styles.colorSwatch, { backgroundColor: value || '#000000' }]} />
156
- <Text style={styles.colorButtonText}>{value || '#000000'}</Text>
157
+ <View style={[styles.colorSwatch, { backgroundColor: value || defaultColor }]} />
158
+ <Text style={styles.colorButtonText}>{value || defaultColor}</Text>
157
159
  <MaterialCommunityIcons name="palette-outline" size={18} color="#94A3B8" />
158
160
  </TouchableOpacity>
159
161
 
@@ -443,9 +445,17 @@ const CategoryForm = forwardRef(({ category, context = 'products', onClose, onSa
443
445
  const categoriesStore = useStore('categories');
444
446
  const categoryActions = categoriesStore.actions;
445
447
  const categories = categoriesStore.getters.items;
446
- const peopleStore = useStore('people');
447
- const { currentCompany } = peopleStore.getters;
448
- const categoryContext = normalizeCategoryContext(context);
448
+ const peopleStore = useStore('people');
449
+ const { currentCompany } = peopleStore.getters;
450
+ const { colors: themeColors } = useStore('theme').getters;
451
+ const categoryContext = normalizeCategoryContext(context);
452
+ const defaultColor = useMemo(
453
+ () => resolveThemePalette(
454
+ { ...themeColors, ...(currentCompany?.theme?.colors || {}) },
455
+ colors,
456
+ ).primary,
457
+ [currentCompany?.theme?.colors, themeColors],
458
+ );
449
459
 
450
460
  const [name, setName] = useState('');
451
461
  const [color, setColor] = useState('#CBD5E1');
@@ -463,43 +473,48 @@ const CategoryForm = forwardRef(({ category, context = 'products', onClose, onSa
463
473
  useEffect(() => {
464
474
  if (category) {
465
475
  setName(category.name || '');
466
- setColor(category.color || '#CBD5E1');
476
+ setColor(category.color || defaultColor);
467
477
  setIcon(category.icon || '');
468
478
  setParent(category.parent?.id || null);
469
- setSortOrder(String(category?.extraData?.sortOrder || ''));
479
+ setSortOrder(category?.sortOrder === null || category?.sortOrder === undefined
480
+ ? ''
481
+ : String(category.sortOrder));
470
482
  setChannel(String(category?.extraData?.channel || 'default'));
471
483
  } else {
472
484
  setName('');
473
- setColor('#CBD5E1');
485
+ setColor(defaultColor);
474
486
  setIcon('');
475
487
  setParent(null);
476
488
  setSortOrder('');
477
489
  setChannel('default');
478
490
  }
479
- }, [category]);
491
+ }, [category, defaultColor]);
480
492
 
481
- const handleSubmit = async () => {
482
- const payload = {
493
+ const handleSubmit = async () => {
494
+ const categoryExtraData = { ...(category?.extraData || {}) };
495
+ delete categoryExtraData.sortOrder;
496
+ const payload = {
483
497
  ...(category?.id ? { id: category.id } : {}),
484
498
  name,
485
499
  color,
486
500
  icon: icon || '',
487
501
  context: categoryContext,
488
502
  company: companyIri,
489
- parent: parent ? `/categories/${parent}` : null,
490
- extraData: {
491
- ...(category?.extraData || {}),
492
- sortOrder: sortOrder ? parseInt(String(sortOrder).replace(/\D/g, ''), 10) || 0 : 0,
493
- channel: channel || 'default',
494
- },
503
+ parent: parent ? `/categories/${parent}` : null,
504
+ sortOrder: sortOrder === '' ? null : Number.parseInt(sortOrder, 10),
505
+ extraData: {
506
+ ...categoryExtraData,
507
+ channel: channel || 'default',
508
+ },
495
509
  };
496
510
 
497
511
  const saved = await categoryActions.save(payload);
498
512
 
499
513
  await categoryActions.getItems({
500
- context: categoryContext,
501
- 'order[name]': 'ASC',
502
- company: currentCompany.id,
514
+ context: categoryContext,
515
+ 'order[sortOrder]': 'ASC',
516
+ 'order[name]': 'ASC',
517
+ company: currentCompany.id,
503
518
  });
504
519
 
505
520
  if (onSaved) onSaved(saved);
@@ -526,7 +541,7 @@ const CategoryForm = forwardRef(({ category, context = 'products', onClose, onSa
526
541
  {/* Cor */}
527
542
  <View style={styles.field}>
528
543
  <Text style={styles.label}>Cor</Text>
529
- <ColorPicker value={color} onChange={setColor} />
544
+ <ColorPicker defaultColor={defaultColor} value={color} onChange={setColor} />
530
545
  </View>
531
546
 
532
547
  {/* Ícone */}
@@ -559,11 +574,13 @@ const CategoryForm = forwardRef(({ category, context = 'products', onClose, onSa
559
574
  />
560
575
  </View>
561
576
 
562
- {/* Canais */}
563
- <View style={styles.field}>
564
- <Text style={styles.label}>Canais de venda</Text>
565
- <ChannelPicker value={channel} onChange={setChannel} />
566
- </View>
577
+ {/* Vitrines */}
578
+ <View style={styles.field}>
579
+ <Text style={styles.label}>
580
+ {global.t?.t?.('categories', 'label', 'showcases')}
581
+ </Text>
582
+ <ChannelPicker value={channel} onChange={setChannel} />
583
+ </View>
567
584
 
568
585
  </View>
569
586
  );