@controleonline/ui-common 1.2.134 → 1.2.135

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 (66) hide show
  1. package/.release/rc-manifest.json +12 -5
  2. package/package.json +6 -2
  3. package/src/react/components/CategoryForm.js +539 -539
  4. package/src/react/components/DefaultProvider.native.js +2 -2
  5. package/src/react/components/DefaultProvider.web.js +2 -2
  6. package/src/react/components/LinkedOrderProductsTab.js +17 -8
  7. package/src/react/components/LinkedOrderProductsTab.styles.js +15 -0
  8. package/src/react/components/documentDetails/DocumentDetailsShell.js +147 -0
  9. package/src/react/components/documentDetails/DocumentDetailsShell.styles.js +163 -0
  10. package/src/react/components/documentDetails/DocumentSheet.js +87 -0
  11. package/src/react/components/integrations/IntegrationHero/index.js +1 -1
  12. package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
  13. package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
  14. package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
  15. package/src/react/hooks/useLinkedOrderSummary.js +41 -0
  16. package/src/react/pages/Connections.styles.js +72 -72
  17. package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
  18. package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
  19. package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
  20. package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
  21. package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
  22. package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
  23. package/src/react/pages/Devices.js +2 -2
  24. package/src/react/pages/Devices.styles.js +353 -353
  25. package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
  26. package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
  27. package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
  28. package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
  29. package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
  30. package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
  31. package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
  32. package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
  33. package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
  34. package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
  35. package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
  36. package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
  37. package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
  38. package/src/react/pages/Imports.js +1 -1
  39. package/src/react/pages/Imports.styles.js +223 -223
  40. package/src/react/pages/IntegrationConfigPage.js +2 -2
  41. package/src/react/pages/Integrations.js +2 -15
  42. package/src/react/pages/Integrations.styles.js +130 -130
  43. package/src/react/pages/LinkedInIntegrationPage.js +2 -2
  44. package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
  45. package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
  46. package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
  47. package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
  48. package/src/react/pages/PrinterDeviceFormPage.js +2 -2
  49. package/src/react/pages/WhatsAppConnectionPage.styles.js +315 -279
  50. package/src/react/pages/WhatsAppProviderForm.js +1 -1
  51. package/src/react/pages/whatsAppConnectionHelpers.js +38 -10
  52. package/src/react/router/__tests__/publicRoutes.test.js +12 -0
  53. package/src/react/router/publicRoutes.js +3 -0
  54. package/src/react/utils/clientPortfolioParams.js +42 -0
  55. package/src/react/utils/commercialDocumentOrders.js +13 -20
  56. package/src/react/utils/documentFileContent.js +61 -0
  57. package/src/react/utils/fileUrl.js +1 -1
  58. package/src/react/utils/linkedOrderPayload.js +43 -0
  59. package/src/react/utils/orderProductsSummary.js +28 -0
  60. package/src/react/utils/peopleDisplay.js +8 -13
  61. package/src/store/connections/customActions.js +16 -14
  62. package/src/store/connections/index.js +109 -105
  63. package/src/tests/react/utils/clientPortfolioParams.test.js +30 -0
  64. package/src/tests/react/utils/documentFileContent.test.js +29 -0
  65. package/src/tests/react/utils/linkedOrderPayload.test.js +46 -0
  66. package/src/tests/react/utils/orderProductsSummary.test.js +24 -0
@@ -1,61 +1,61 @@
1
1
  import React from 'react';
2
2
  import { ActivityIndicator, Text, TextInput, TouchableOpacity, View } from 'react-native';
3
3
  import Icon from 'react-native-vector-icons/Feather';
4
- import { colors } from '@controleonline/../../src/styles/colors';
4
+ import { colors } from '@controleonline/ui-layout/src/styles/colors';
5
5
 
6
- import { withOpacity } from '@controleonline/../../src/styles/branding';
7
-
8
- import styles from '../styles';
9
- import { calcEndTime, DAY_LABELS, DAY_ORDER, formatDateTimeLabel } from '../utils';
10
-
11
- // Aba com operação diária: disponibilidade e horários da loja.
12
- export default function IFoodOperationsTab({
13
- shadowStyle,
14
- connected,
15
- storeStatus,
16
- activeInterruptions,
17
- actionLoading,
18
- interruptionDraft,
19
- interruptionRemoving,
20
- onInterruptionDraftChange,
21
- onRemoveInterruption,
22
- onStoreOpen,
23
- onStoreClose,
24
- onRefreshStatus,
25
- hours,
26
- hoursLoading,
27
- hoursEditing,
28
- onStartEditHours,
29
- hoursDraft,
30
- onUpdateHoursDraft,
31
- onAddHoursShift,
6
+ import { withOpacity } from '@controleonline/ui-layout/src/styles/branding';
7
+
8
+ import styles from '../styles';
9
+ import { calcEndTime, DAY_LABELS, DAY_ORDER, formatDateTimeLabel } from '../utils';
10
+
11
+ // Aba com operação diária: disponibilidade e horários da loja.
12
+ export default function IFoodOperationsTab({
13
+ shadowStyle,
14
+ connected,
15
+ storeStatus,
16
+ activeInterruptions,
17
+ actionLoading,
18
+ interruptionDraft,
19
+ interruptionRemoving,
20
+ onInterruptionDraftChange,
21
+ onRemoveInterruption,
22
+ onStoreOpen,
23
+ onStoreClose,
24
+ onRefreshStatus,
25
+ hours,
26
+ hoursLoading,
27
+ hoursEditing,
28
+ onStartEditHours,
29
+ hoursDraft,
30
+ onUpdateHoursDraft,
31
+ onAddHoursShift,
32
32
  onRemoveHoursShift,
33
33
  hoursSaving,
34
34
  onSaveHours,
35
35
  onCancelEditHours,
36
36
  palette = colors,
37
37
  }) {
38
- if (!connected) {
39
- return (
40
- <View style={[styles.sectionCard, shadowStyle]}>
41
- <Text style={styles.sectionTitle}>Operacao da loja</Text>
42
- <View style={styles.helperRow}>
43
- <Text style={styles.helperText}>
44
- Conecte a loja primeiro para consultar disponibilidade, pausas ativas e horários do iFood.
45
- </Text>
46
- </View>
47
- </View>
48
- );
49
- }
50
-
51
- return (
52
- <>
53
- <View style={[styles.sectionCard, shadowStyle]}>
54
- <View style={styles.statusRow}>
55
- <Text style={styles.sectionTitle}>Disponibilidade da loja</Text>
56
- {storeStatus?.data != null && (
57
- <View
58
- style={[
38
+ if (!connected) {
39
+ return (
40
+ <View style={[styles.sectionCard, shadowStyle]}>
41
+ <Text style={styles.sectionTitle}>Operacao da loja</Text>
42
+ <View style={styles.helperRow}>
43
+ <Text style={styles.helperText}>
44
+ Conecte a loja primeiro para consultar disponibilidade, pausas ativas e horários do iFood.
45
+ </Text>
46
+ </View>
47
+ </View>
48
+ );
49
+ }
50
+
51
+ return (
52
+ <>
53
+ <View style={[styles.sectionCard, shadowStyle]}>
54
+ <View style={styles.statusRow}>
55
+ <Text style={styles.sectionTitle}>Disponibilidade da loja</Text>
56
+ {storeStatus?.data != null && (
57
+ <View
58
+ style={[
59
59
  styles.availBadge,
60
60
  {
61
61
  backgroundColor: withOpacity(storeStatus.data.online ? palette.success : palette.error, 0.12),
@@ -74,30 +74,30 @@ export default function IFoodOperationsTab({
74
74
  ]}>
75
75
  {storeStatus.data.online ? 'Online' : 'Offline'}
76
76
  </Text>
77
- </View>
78
- )}
79
- </View>
80
-
81
- <Text style={styles.helperText}>
82
- {storeStatus?.data != null
83
- ? storeStatus.data.online
84
- ? 'A loja esta aceitando pedidos no iFood.'
85
- : `A loja esta fechada para novos pedidos.${activeInterruptions.length > 0 ? ` ${activeInterruptions.length} interrupcao(oes) ativa(s).` : ''}`
86
- : 'Consulte ou altere a disponibilidade da loja para receber pedidos.'}
87
- </Text>
88
-
89
- {activeInterruptions.length > 0 && (
90
- <View style={styles.interruptionsBox}>
91
- <Text style={styles.interruptionsTitle}>Pausas ativas</Text>
92
- {activeInterruptions.map((interruption, index) => (
93
- <View key={String(interruption?.id || index)} style={styles.interruptionItem}>
94
- <View style={styles.interruptionHeader}>
95
- <Text style={styles.interruptionText}>
96
- {interruption?.description || 'Interrupcao ativa'}
97
- </Text>
98
- <TouchableOpacity
99
- activeOpacity={0.9}
100
- style={styles.interruptionRemoveButton}
77
+ </View>
78
+ )}
79
+ </View>
80
+
81
+ <Text style={styles.helperText}>
82
+ {storeStatus?.data != null
83
+ ? storeStatus.data.online
84
+ ? 'A loja esta aceitando pedidos no iFood.'
85
+ : `A loja esta fechada para novos pedidos.${activeInterruptions.length > 0 ? ` ${activeInterruptions.length} interrupcao(oes) ativa(s).` : ''}`
86
+ : 'Consulte ou altere a disponibilidade da loja para receber pedidos.'}
87
+ </Text>
88
+
89
+ {activeInterruptions.length > 0 && (
90
+ <View style={styles.interruptionsBox}>
91
+ <Text style={styles.interruptionsTitle}>Pausas ativas</Text>
92
+ {activeInterruptions.map((interruption, index) => (
93
+ <View key={String(interruption?.id || index)} style={styles.interruptionItem}>
94
+ <View style={styles.interruptionHeader}>
95
+ <Text style={styles.interruptionText}>
96
+ {interruption?.description || 'Interrupcao ativa'}
97
+ </Text>
98
+ <TouchableOpacity
99
+ activeOpacity={0.9}
100
+ style={styles.interruptionRemoveButton}
101
101
  onPress={() => onRemoveInterruption(interruption)}
102
102
  disabled={actionLoading !== null || interruptionRemoving?.has?.(String(interruption?.id || ''))}>
103
103
  {interruptionRemoving?.has?.(String(interruption?.id || '')) ? (
@@ -107,109 +107,109 @@ export default function IFoodOperationsTab({
107
107
  )}
108
108
  </TouchableOpacity>
109
109
  </View>
110
- <Text style={styles.interruptionMeta}>
111
- Inicio: {formatDateTimeLabel(interruption?.start)}
112
- </Text>
113
- <Text style={styles.interruptionMeta}>
114
- Fim: {formatDateTimeLabel(interruption?.end)}
115
- </Text>
116
- </View>
117
- ))}
118
- </View>
119
- )}
120
-
121
- <View style={styles.interruptionForm}>
122
- <Text style={styles.interruptionsTitle}>Nova pausa</Text>
123
- <TextInput
124
- value={interruptionDraft?.description || ''}
110
+ <Text style={styles.interruptionMeta}>
111
+ Inicio: {formatDateTimeLabel(interruption?.start)}
112
+ </Text>
113
+ <Text style={styles.interruptionMeta}>
114
+ Fim: {formatDateTimeLabel(interruption?.end)}
115
+ </Text>
116
+ </View>
117
+ ))}
118
+ </View>
119
+ )}
120
+
121
+ <View style={styles.interruptionForm}>
122
+ <Text style={styles.interruptionsTitle}>Nova pausa</Text>
123
+ <TextInput
124
+ value={interruptionDraft?.description || ''}
125
125
  onChangeText={value => onInterruptionDraftChange('description', value)}
126
126
  style={styles.input}
127
127
  placeholder="Motivo da pausa"
128
128
  placeholderTextColor={palette.textSecondary}
129
129
  editable={actionLoading === null}
130
130
  />
131
- <View style={styles.interruptionDateRow}>
132
- <View style={styles.interruptionDateField}>
133
- <Text style={styles.inputLabel}>Inicio</Text>
134
- <TextInput
135
- value={interruptionDraft?.start || ''}
136
- onChangeText={value => onInterruptionDraftChange('start', value)}
131
+ <View style={styles.interruptionDateRow}>
132
+ <View style={styles.interruptionDateField}>
133
+ <Text style={styles.inputLabel}>Inicio</Text>
134
+ <TextInput
135
+ value={interruptionDraft?.start || ''}
136
+ onChangeText={value => onInterruptionDraftChange('start', value)}
137
137
  style={styles.input}
138
138
  placeholder="AAAA-MM-DDTHH:MM"
139
139
  placeholderTextColor={palette.textSecondary}
140
140
  keyboardType="numbers-and-punctuation"
141
141
  editable={actionLoading === null}
142
142
  />
143
- </View>
144
- <View style={styles.interruptionDateField}>
145
- <Text style={styles.inputLabel}>Fim</Text>
146
- <TextInput
147
- value={interruptionDraft?.end || ''}
148
- onChangeText={value => onInterruptionDraftChange('end', value)}
143
+ </View>
144
+ <View style={styles.interruptionDateField}>
145
+ <Text style={styles.inputLabel}>Fim</Text>
146
+ <TextInput
147
+ value={interruptionDraft?.end || ''}
148
+ onChangeText={value => onInterruptionDraftChange('end', value)}
149
149
  style={styles.input}
150
150
  placeholder="AAAA-MM-DDTHH:MM"
151
151
  placeholderTextColor={palette.textSecondary}
152
152
  keyboardType="numbers-and-punctuation"
153
153
  editable={actionLoading === null}
154
154
  />
155
- </View>
156
- </View>
157
- <Text style={styles.interruptionMeta}>
158
- Formato: AAAA-MM-DDTHH:MM. O iFood limita pausas a no maximo 7 dias e nao permite sobreposicao.
159
- </Text>
160
- </View>
161
-
162
- {Array.isArray(storeStatus?.data?.operations) && (() => {
163
- const storeOnline = storeStatus.data.online === true;
164
- const visibleOperations = storeStatus.data.operations.filter(
165
- operation => storeOnline || operation.state !== 'ERROR',
166
- );
167
-
168
- if (visibleOperations.length === 0) return null;
169
-
170
- return (
171
- <View style={styles.opsGrid}>
172
- {visibleOperations.map((operation, index) => {
173
- const online = operation.state === 'OK' || operation.state === 'WARNING';
155
+ </View>
156
+ </View>
157
+ <Text style={styles.interruptionMeta}>
158
+ Formato: AAAA-MM-DDTHH:MM. O iFood limita pausas a no maximo 7 dias e nao permite sobreposicao.
159
+ </Text>
160
+ </View>
161
+
162
+ {Array.isArray(storeStatus?.data?.operations) && (() => {
163
+ const storeOnline = storeStatus.data.online === true;
164
+ const visibleOperations = storeStatus.data.operations.filter(
165
+ operation => storeOnline || operation.state !== 'ERROR',
166
+ );
167
+
168
+ if (visibleOperations.length === 0) return null;
169
+
170
+ return (
171
+ <View style={styles.opsGrid}>
172
+ {visibleOperations.map((operation, index) => {
173
+ const online = operation.state === 'OK' || operation.state === 'WARNING';
174
174
  const tone =
175
175
  operation.state === 'OK'
176
176
  ? palette.success
177
177
  : operation.state === 'WARNING'
178
178
  ? palette.warning
179
179
  : palette.error;
180
-
181
- return (
182
- <View
183
- key={`${operation?.operation || 'operation'}-${index}`}
184
- style={[
185
- styles.opChip,
186
- {
187
- borderColor: withOpacity(tone, 0.3),
188
- backgroundColor: withOpacity(tone, 0.08),
189
- },
190
- ]}>
191
- <Icon name={online ? 'check-circle' : 'x-circle'} size={12} color={tone} />
192
- <Text style={[styles.opChipText, { color: tone }]}>
193
- {operation.operation}
194
- {operation.sales_channel ? ` · ${operation.sales_channel}` : ''}
195
- {`: ${operation.state_label}`}
196
- </Text>
197
- </View>
198
- );
199
- })}
200
- </View>
201
- );
202
- })()}
203
-
204
- <View style={styles.availRow}>
205
- <TouchableOpacity
206
- activeOpacity={0.9}
180
+
181
+ return (
182
+ <View
183
+ key={`${operation?.operation || 'operation'}-${index}`}
184
+ style={[
185
+ styles.opChip,
186
+ {
187
+ borderColor: withOpacity(tone, 0.3),
188
+ backgroundColor: withOpacity(tone, 0.08),
189
+ },
190
+ ]}>
191
+ <Icon name={online ? 'check-circle' : 'x-circle'} size={12} color={tone} />
192
+ <Text style={[styles.opChipText, { color: tone }]}>
193
+ {operation.operation}
194
+ {operation.sales_channel ? ` · ${operation.sales_channel}` : ''}
195
+ {`: ${operation.state_label}`}
196
+ </Text>
197
+ </View>
198
+ );
199
+ })}
200
+ </View>
201
+ );
202
+ })()}
203
+
204
+ <View style={styles.availRow}>
205
+ <TouchableOpacity
206
+ activeOpacity={0.9}
207
207
  style={[
208
208
  styles.availButton,
209
209
  { backgroundColor: palette.success },
210
210
  (actionLoading === 'store_open' || storeStatus?.data?.online === true) && styles.availButtonDisabled,
211
211
  ]}
212
- onPress={onStoreOpen}
212
+ onPress={onStoreOpen}
213
213
  disabled={actionLoading !== null || storeStatus?.data?.online === true}>
214
214
  {actionLoading === 'store_open' ? (
215
215
  <ActivityIndicator color={palette.white} size="small" />
@@ -219,16 +219,16 @@ export default function IFoodOperationsTab({
219
219
  <Text style={styles.availButtonText}>Abrir loja</Text>
220
220
  </>
221
221
  )}
222
- </TouchableOpacity>
223
-
224
- <TouchableOpacity
225
- activeOpacity={0.9}
222
+ </TouchableOpacity>
223
+
224
+ <TouchableOpacity
225
+ activeOpacity={0.9}
226
226
  style={[
227
227
  styles.availButton,
228
228
  { backgroundColor: palette.error },
229
229
  (actionLoading === 'store_close' || storeStatus?.data?.online === false) && styles.availButtonDisabled,
230
230
  ]}
231
- onPress={onStoreClose}
231
+ onPress={onStoreClose}
232
232
  disabled={actionLoading !== null || storeStatus?.data?.online === false}>
233
233
  {actionLoading === 'store_close' ? (
234
234
  <ActivityIndicator color={palette.white} size="small" />
@@ -238,30 +238,30 @@ export default function IFoodOperationsTab({
238
238
  <Text style={styles.availButtonText}>Fechar loja</Text>
239
239
  </>
240
240
  )}
241
- </TouchableOpacity>
242
-
243
- <TouchableOpacity
244
- activeOpacity={0.9}
241
+ </TouchableOpacity>
242
+
243
+ <TouchableOpacity
244
+ activeOpacity={0.9}
245
245
  style={styles.availRefreshButton}
246
246
  onPress={onRefreshStatus}
247
247
  disabled={actionLoading !== null}>
248
248
  <Icon name="refresh-cw" size={15} color={palette.textSecondary} />
249
249
  </TouchableOpacity>
250
250
  </View>
251
-
252
- {storeStatus?.errno !== 0 && storeStatus?.errno != null && (
253
- <View style={styles.errorBox}>
254
- <Text style={styles.errorTitle}>Erro ao consultar disponibilidade</Text>
255
- <Text style={styles.errorText}>{storeStatus.errmsg}</Text>
256
- </View>
257
- )}
258
- </View>
259
-
260
- <View style={[styles.sectionCard, shadowStyle]}>
261
- <View style={styles.statusRow}>
262
- <Text style={styles.sectionTitle}>Horarios de funcionamento</Text>
263
- {!hoursEditing && (
264
- <TouchableOpacity
251
+
252
+ {storeStatus?.errno !== 0 && storeStatus?.errno != null && (
253
+ <View style={styles.errorBox}>
254
+ <Text style={styles.errorTitle}>Erro ao consultar disponibilidade</Text>
255
+ <Text style={styles.errorText}>{storeStatus.errmsg}</Text>
256
+ </View>
257
+ )}
258
+ </View>
259
+
260
+ <View style={[styles.sectionCard, shadowStyle]}>
261
+ <View style={styles.statusRow}>
262
+ <Text style={styles.sectionTitle}>Horarios de funcionamento</Text>
263
+ {!hoursEditing && (
264
+ <TouchableOpacity
265
265
  onPress={onStartEditHours}
266
266
  style={styles.hoursEditBtn}
267
267
  disabled={hoursLoading}>
@@ -272,69 +272,69 @@ export default function IFoodOperationsTab({
272
272
  </View>
273
273
 
274
274
  {hoursLoading && <ActivityIndicator size="small" color={palette.info} />}
275
-
276
- {!hoursLoading && !hoursEditing && (
277
- Array.isArray(hours) && hours.length > 0 ? (
278
- <View style={styles.hoursList}>
279
- {DAY_ORDER.map(day => {
280
- const entry = hours.find(item => item.dayOfWeek === day);
281
- const isOpen = !!entry && (entry.shifts || []).length > 0;
282
-
275
+
276
+ {!hoursLoading && !hoursEditing && (
277
+ Array.isArray(hours) && hours.length > 0 ? (
278
+ <View style={styles.hoursList}>
279
+ {DAY_ORDER.map(day => {
280
+ const entry = hours.find(item => item.dayOfWeek === day);
281
+ const isOpen = !!entry && (entry.shifts || []).length > 0;
282
+
283
283
  return (
284
284
  <View key={day} style={styles.hoursDayRow}>
285
285
  <Text style={[styles.hoursDayLabel, !isOpen && { color: palette.textSecondary }]}>
286
286
  {DAY_LABELS[day]}
287
287
  </Text>
288
- <View style={styles.hoursValues}>
289
- {isOpen ? (
290
- (entry.shifts || []).map((shift, index) => (
291
- <Text key={`${day}-${index}`} style={styles.hoursValue}>
292
- {shift.start} – {calcEndTime(shift.start, shift.duration)}
293
- </Text>
294
- ))
295
- ) : (
296
- <Text style={styles.hoursClosed}>Fechado</Text>
297
- )}
298
- </View>
299
- </View>
300
- );
301
- })}
302
- </View>
303
- ) : (
304
- <Text style={styles.helperText}>Nenhum horario configurado. Toque em Editar para definir.</Text>
305
- )
306
- )}
307
-
308
- {hoursEditing && Array.isArray(hoursDraft) && (
309
- hoursDraft.length > 0 ? (
310
- <View style={styles.hoursEditList}>
311
- {DAY_ORDER.map(day => {
312
- const entry =
313
- hoursDraft.find(item => item.dayOfWeek === day) || {
314
- dayOfWeek: day,
315
- open: false,
316
- shifts: [{ start: '09:00', duration: 840 }],
317
- };
318
-
319
- return (
320
- <View key={day} style={[styles.hoursDayRow, { alignItems: 'center' }]}>
321
- <TouchableOpacity
322
- onPress={() => onUpdateHoursDraft(day, null, 'open', !entry.open)}
323
- disabled={hoursSaving}
324
- style={[styles.dayToggle, entry.open && styles.dayToggleOn]}>
325
- <View style={[styles.dayToggleThumb, entry.open && styles.dayToggleThumbOn]} />
326
- </TouchableOpacity>
288
+ <View style={styles.hoursValues}>
289
+ {isOpen ? (
290
+ (entry.shifts || []).map((shift, index) => (
291
+ <Text key={`${day}-${index}`} style={styles.hoursValue}>
292
+ {shift.start} – {calcEndTime(shift.start, shift.duration)}
293
+ </Text>
294
+ ))
295
+ ) : (
296
+ <Text style={styles.hoursClosed}>Fechado</Text>
297
+ )}
298
+ </View>
299
+ </View>
300
+ );
301
+ })}
302
+ </View>
303
+ ) : (
304
+ <Text style={styles.helperText}>Nenhum horario configurado. Toque em Editar para definir.</Text>
305
+ )
306
+ )}
307
+
308
+ {hoursEditing && Array.isArray(hoursDraft) && (
309
+ hoursDraft.length > 0 ? (
310
+ <View style={styles.hoursEditList}>
311
+ {DAY_ORDER.map(day => {
312
+ const entry =
313
+ hoursDraft.find(item => item.dayOfWeek === day) || {
314
+ dayOfWeek: day,
315
+ open: false,
316
+ shifts: [{ start: '09:00', duration: 840 }],
317
+ };
318
+
319
+ return (
320
+ <View key={day} style={[styles.hoursDayRow, { alignItems: 'center' }]}>
321
+ <TouchableOpacity
322
+ onPress={() => onUpdateHoursDraft(day, null, 'open', !entry.open)}
323
+ disabled={hoursSaving}
324
+ style={[styles.dayToggle, entry.open && styles.dayToggleOn]}>
325
+ <View style={[styles.dayToggleThumb, entry.open && styles.dayToggleThumbOn]} />
326
+ </TouchableOpacity>
327
327
 
328
328
  <Text style={[styles.hoursDayLabel, !entry.open && { color: palette.textSecondary }]}>
329
329
  {DAY_LABELS[day]}
330
330
  </Text>
331
-
332
- {entry.open ? (
333
- <View style={styles.hoursEditContent}>
334
- {(entry.shifts || []).map((shift, index) => (
335
- <View key={`${day}-shift-${index}`} style={styles.hoursInputRow}>
336
- <TextInput
337
- value={shift.start}
331
+
332
+ {entry.open ? (
333
+ <View style={styles.hoursEditContent}>
334
+ {(entry.shifts || []).map((shift, index) => (
335
+ <View key={`${day}-shift-${index}`} style={styles.hoursInputRow}>
336
+ <TextInput
337
+ value={shift.start}
338
338
  onChangeText={value => onUpdateHoursDraft(day, index, 'start', value)}
339
339
  style={styles.hoursInput}
340
340
  placeholder="HH:MM"
@@ -342,9 +342,9 @@ export default function IFoodOperationsTab({
342
342
  keyboardType="numbers-and-punctuation"
343
343
  editable={!hoursSaving}
344
344
  />
345
- <Text style={styles.hoursSep}>–</Text>
346
- <TextInput
347
- value={calcEndTime(shift.start, shift.duration)}
345
+ <Text style={styles.hoursSep}>–</Text>
346
+ <TextInput
347
+ value={calcEndTime(shift.start, shift.duration)}
348
348
  onChangeText={value => onUpdateHoursDraft(day, index, 'end', value)}
349
349
  style={styles.hoursInput}
350
350
  placeholder="HH:MM"
@@ -352,8 +352,8 @@ export default function IFoodOperationsTab({
352
352
  keyboardType="numbers-and-punctuation"
353
353
  editable={!hoursSaving}
354
354
  />
355
- {(entry.shifts || []).length > 1 && (
356
- <TouchableOpacity
355
+ {(entry.shifts || []).length > 1 && (
356
+ <TouchableOpacity
357
357
  onPress={() => onRemoveHoursShift(day, index)}
358
358
  disabled={hoursSaving}
359
359
  style={styles.hoursShiftRemoveBtn}>
@@ -361,23 +361,23 @@ export default function IFoodOperationsTab({
361
361
  </TouchableOpacity>
362
362
  )}
363
363
  </View>
364
- ))}
365
- <TouchableOpacity
364
+ ))}
365
+ <TouchableOpacity
366
366
  onPress={() => onAddHoursShift(day)}
367
367
  disabled={hoursSaving}
368
368
  style={styles.hoursShiftAddBtn}>
369
369
  <Icon name="plus" size={14} color={palette.info} />
370
370
  <Text style={styles.hoursShiftAddText}>Adicionar turno</Text>
371
371
  </TouchableOpacity>
372
- </View>
373
- ) : (
374
- <Text style={styles.hoursClosed}>Fechado</Text>
375
- )}
376
- </View>
377
- );
378
- })}
379
-
380
- <View style={styles.availRow}>
372
+ </View>
373
+ ) : (
374
+ <Text style={styles.hoursClosed}>Fechado</Text>
375
+ )}
376
+ </View>
377
+ );
378
+ })}
379
+
380
+ <View style={styles.availRow}>
381
381
  <TouchableOpacity
382
382
  onPress={onSaveHours}
383
383
  disabled={hoursSaving}
@@ -390,31 +390,31 @@ export default function IFoodOperationsTab({
390
390
  <Text style={styles.actionButtonText}>Salvar horarios</Text>
391
391
  </>
392
392
  )}
393
- </TouchableOpacity>
394
-
395
- <TouchableOpacity
396
- onPress={onCancelEditHours}
397
- disabled={hoursSaving}
398
- style={styles.hoursCancelBtn}>
399
- <Text style={styles.hoursCancelText}>Cancelar</Text>
400
- </TouchableOpacity>
401
- </View>
402
- </View>
403
- ) : (
404
- <View style={styles.hoursEditList}>
405
- <View style={styles.helperRow}>
406
- <Text style={styles.helperText}>
407
- Nenhum horario retornado pelo iFood. Sincronize o catalogo e tente novamente.
408
- </Text>
409
- </View>
410
-
411
- <TouchableOpacity onPress={onCancelEditHours} style={styles.hoursCancelBtn}>
412
- <Text style={styles.hoursCancelText}>Fechar</Text>
413
- </TouchableOpacity>
414
- </View>
415
- )
416
- )}
417
- </View>
418
- </>
419
- );
420
- }
393
+ </TouchableOpacity>
394
+
395
+ <TouchableOpacity
396
+ onPress={onCancelEditHours}
397
+ disabled={hoursSaving}
398
+ style={styles.hoursCancelBtn}>
399
+ <Text style={styles.hoursCancelText}>Cancelar</Text>
400
+ </TouchableOpacity>
401
+ </View>
402
+ </View>
403
+ ) : (
404
+ <View style={styles.hoursEditList}>
405
+ <View style={styles.helperRow}>
406
+ <Text style={styles.helperText}>
407
+ Nenhum horario retornado pelo iFood. Sincronize o catalogo e tente novamente.
408
+ </Text>
409
+ </View>
410
+
411
+ <TouchableOpacity onPress={onCancelEditHours} style={styles.hoursCancelBtn}>
412
+ <Text style={styles.hoursCancelText}>Fechar</Text>
413
+ </TouchableOpacity>
414
+ </View>
415
+ )
416
+ )}
417
+ </View>
418
+ </>
419
+ );
420
+ }