@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.
- package/.release/rc-manifest.json +12 -5
- package/package.json +6 -2
- package/src/react/components/CategoryForm.js +539 -539
- package/src/react/components/DefaultProvider.native.js +2 -2
- package/src/react/components/DefaultProvider.web.js +2 -2
- package/src/react/components/LinkedOrderProductsTab.js +17 -8
- package/src/react/components/LinkedOrderProductsTab.styles.js +15 -0
- package/src/react/components/documentDetails/DocumentDetailsShell.js +147 -0
- package/src/react/components/documentDetails/DocumentDetailsShell.styles.js +163 -0
- package/src/react/components/documentDetails/DocumentSheet.js +87 -0
- package/src/react/components/integrations/IntegrationHero/index.js +1 -1
- package/src/react/components/integrations/IntegrationHero/styles.js +2 -2
- package/src/react/components/integrations/IntegrationTabs/index.js +1 -1
- package/src/react/components/integrations/IntegrationTabs/styles.js +1 -1
- package/src/react/hooks/useLinkedOrderSummary.js +41 -0
- package/src/react/pages/Connections.styles.js +72 -72
- package/src/react/pages/Devices/detail/DeviceDetailHeader.js +1 -1
- package/src/react/pages/Devices/detail/DeviceDetailMovementSections.js +1 -1
- package/src/react/pages/Devices/detail/useDeviceDetailStateA.js +2 -2
- package/src/react/pages/Devices/detail/useDeviceDetailStateB.js +2 -2
- package/src/react/pages/Devices/deviceTypes/DeviceGroupCard.js +1 -1
- package/src/react/pages/Devices/deviceTypes/shared.js +2 -2
- package/src/react/pages/Devices.js +2 -2
- package/src/react/pages/Devices.styles.js +353 -353
- package/src/react/pages/Food99IntegrationPage/components/Food99CatalogTab.js +219 -219
- package/src/react/pages/Food99IntegrationPage/components/Food99OverviewTab.js +134 -134
- package/src/react/pages/Food99IntegrationPage/components/Food99PreviewModal.js +173 -173
- package/src/react/pages/Food99IntegrationPage/components/Food99QuickWalletModal.js +1 -1
- package/src/react/pages/Food99IntegrationPage/components/Food99SettingsTab.js +306 -306
- package/src/react/pages/Food99IntegrationPage/components/Food99StoreTab.js +417 -417
- package/src/react/pages/Food99IntegrationPage/index.js +1530 -1530
- package/src/react/pages/Food99IntegrationPage/styles.js +792 -792
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOperationsTab.js +267 -267
- package/src/react/pages/IFoodIntegrationPage/components/IFoodOverviewTab.js +118 -118
- package/src/react/pages/IFoodIntegrationPage/components/IFoodPreviewModal.js +101 -101
- package/src/react/pages/IFoodIntegrationPage/components/IFoodStoreTab.js +150 -150
- package/src/react/pages/IFoodIntegrationPage/index.js +1298 -1298
- package/src/react/pages/Imports.js +1 -1
- package/src/react/pages/Imports.styles.js +223 -223
- package/src/react/pages/IntegrationConfigPage.js +2 -2
- package/src/react/pages/Integrations.js +2 -15
- package/src/react/pages/Integrations.styles.js +130 -130
- package/src/react/pages/LinkedInIntegrationPage.js +2 -2
- package/src/react/pages/ManagerOrderNotificationsPage.js +642 -642
- package/src/react/pages/MarketplaceIntegrationPage/components/MarketplaceProductCard.js +205 -205
- package/src/react/pages/MercadoLivreIntegrationPage.js +2 -2
- package/src/react/pages/PrinterDeviceDetailPage.js +1915 -1915
- package/src/react/pages/PrinterDeviceFormPage.js +2 -2
- package/src/react/pages/WhatsAppConnectionPage.styles.js +315 -279
- package/src/react/pages/WhatsAppProviderForm.js +1 -1
- package/src/react/pages/whatsAppConnectionHelpers.js +38 -10
- package/src/react/router/__tests__/publicRoutes.test.js +12 -0
- package/src/react/router/publicRoutes.js +3 -0
- package/src/react/utils/clientPortfolioParams.js +42 -0
- package/src/react/utils/commercialDocumentOrders.js +13 -20
- package/src/react/utils/documentFileContent.js +61 -0
- package/src/react/utils/fileUrl.js +1 -1
- package/src/react/utils/linkedOrderPayload.js +43 -0
- package/src/react/utils/orderProductsSummary.js +28 -0
- package/src/react/utils/peopleDisplay.js +8 -13
- package/src/store/connections/customActions.js +16 -14
- package/src/store/connections/index.js +109 -105
- package/src/tests/react/utils/clientPortfolioParams.test.js +30 -0
- package/src/tests/react/utils/documentFileContent.test.js +29 -0
- package/src/tests/react/utils/linkedOrderPayload.test.js +46 -0
- package/src/tests/react/utils/orderProductsSummary.test.js +24 -0
|
@@ -37,8 +37,8 @@ import {
|
|
|
37
37
|
applyPaletteToRuntimeColors,
|
|
38
38
|
applyThemeCssVariables,
|
|
39
39
|
resolveThemePalette,
|
|
40
|
-
} from '@controleonline
|
|
41
|
-
import {colors as runtimeColors} from '@controleonline
|
|
40
|
+
} from '@controleonline/ui-layout/src/styles/branding';
|
|
41
|
+
import {colors as runtimeColors} from '@controleonline/ui-layout/src/styles/colors';
|
|
42
42
|
import {
|
|
43
43
|
buildDefaultDeviceConfigs,
|
|
44
44
|
buildProviderManagedDeviceConfigs,
|
|
@@ -33,8 +33,8 @@ import {
|
|
|
33
33
|
applyPaletteToRuntimeColors,
|
|
34
34
|
applyThemeCssVariables,
|
|
35
35
|
resolveThemePalette,
|
|
36
|
-
} from '@controleonline
|
|
37
|
-
import { colors as runtimeColors } from '@controleonline
|
|
36
|
+
} from '@controleonline/ui-layout/src/styles/branding';
|
|
37
|
+
import { colors as runtimeColors } from '@controleonline/ui-layout/src/styles/colors';
|
|
38
38
|
import {
|
|
39
39
|
buildDefaultDeviceConfigs,
|
|
40
40
|
buildProviderManagedDeviceConfigs,
|
|
@@ -62,6 +62,10 @@ const LinkedOrderProductsTab = ({
|
|
|
62
62
|
emptyTitle = 'Nenhum produto adicionado.',
|
|
63
63
|
emptySubtitle = 'Você pode vincular produtos a este documento quando precisar.',
|
|
64
64
|
searchPlaceholder = 'Buscar produto para adicionar...',
|
|
65
|
+
// Called after products change so the parent can regenerate/reload the document.
|
|
66
|
+
onProductsChanged,
|
|
67
|
+
// Rendered inside a sheet that already has its own title.
|
|
68
|
+
embedded = false,
|
|
65
69
|
}) => {
|
|
66
70
|
const peopleStore = useStore('people');
|
|
67
71
|
const { currentCompany } = peopleStore.getters;
|
|
@@ -82,6 +86,9 @@ const LinkedOrderProductsTab = ({
|
|
|
82
86
|
);
|
|
83
87
|
|
|
84
88
|
const canEditProducts = !!canEdit && !!contract?.['@id'] && (!order || isOpenCommercialOrder(order));
|
|
89
|
+
// The backend only accepts products linked to the contract model category
|
|
90
|
+
// (ProposalProductCategoryGuard), so the search must use the same filter.
|
|
91
|
+
const modelCategoryId = normalizeEntityId(contract?.contractModel?.category);
|
|
85
92
|
|
|
86
93
|
const loadLinkedOrderProducts = useCallback(async () => {
|
|
87
94
|
if (!contract?.['@id']) {
|
|
@@ -128,6 +135,7 @@ const LinkedOrderProductsTab = ({
|
|
|
128
135
|
const results = await searchCompanyProducts({
|
|
129
136
|
companyId: currentCompany.id,
|
|
130
137
|
query: trimmedQuery,
|
|
138
|
+
categoryId: modelCategoryId,
|
|
131
139
|
});
|
|
132
140
|
|
|
133
141
|
if (!cancelled) {
|
|
@@ -148,7 +156,7 @@ const LinkedOrderProductsTab = ({
|
|
|
148
156
|
cancelled = true;
|
|
149
157
|
clearTimeout(timeoutId);
|
|
150
158
|
};
|
|
151
|
-
}, [canEditProducts, currentCompany?.id, searchQuery]);
|
|
159
|
+
}, [canEditProducts, currentCompany?.id, modelCategoryId, searchQuery]);
|
|
152
160
|
|
|
153
161
|
const ensureCurrentOrder = useCallback(async () => {
|
|
154
162
|
if (order) {
|
|
@@ -161,7 +169,6 @@ const LinkedOrderProductsTab = ({
|
|
|
161
169
|
client: contract?.client,
|
|
162
170
|
payer: contract?.client,
|
|
163
171
|
app: 'CRM',
|
|
164
|
-
orderType: 'sale',
|
|
165
172
|
});
|
|
166
173
|
|
|
167
174
|
setOrder(createdOrder);
|
|
@@ -188,12 +195,13 @@ const LinkedOrderProductsTab = ({
|
|
|
188
195
|
setSearchQuery('');
|
|
189
196
|
setSearchResults([]);
|
|
190
197
|
await loadLinkedOrderProducts();
|
|
198
|
+
await onProductsChanged?.();
|
|
191
199
|
} catch (error) {
|
|
192
200
|
showError?.(formatApiError(error));
|
|
193
201
|
} finally {
|
|
194
202
|
setAddingProductId(null);
|
|
195
203
|
}
|
|
196
|
-
}, [addingProductId, canEditProducts, ensureCurrentOrder, loadLinkedOrderProducts, showError]);
|
|
204
|
+
}, [addingProductId, canEditProducts, ensureCurrentOrder, loadLinkedOrderProducts, onProductsChanged, showError]);
|
|
197
205
|
|
|
198
206
|
const handleChangeQuantity = useCallback(async (orderProduct, nextQuantity) => {
|
|
199
207
|
if (updatingOrderProductId) {
|
|
@@ -217,12 +225,13 @@ const LinkedOrderProductsTab = ({
|
|
|
217
225
|
}
|
|
218
226
|
|
|
219
227
|
await loadLinkedOrderProducts();
|
|
228
|
+
await onProductsChanged?.();
|
|
220
229
|
} catch (error) {
|
|
221
230
|
showError?.(formatApiError(error));
|
|
222
231
|
} finally {
|
|
223
232
|
setUpdatingOrderProductId(null);
|
|
224
233
|
}
|
|
225
|
-
}, [loadLinkedOrderProducts, showError, updatingOrderProductId]);
|
|
234
|
+
}, [loadLinkedOrderProducts, onProductsChanged, showError, updatingOrderProductId]);
|
|
226
235
|
|
|
227
236
|
const visibleSearchResults = useMemo(() => {
|
|
228
237
|
const existingProductIds = new Set(
|
|
@@ -239,11 +248,11 @@ const LinkedOrderProductsTab = ({
|
|
|
239
248
|
return (
|
|
240
249
|
<ScrollView
|
|
241
250
|
style={styles.container}
|
|
242
|
-
contentContainerStyle={styles.content}
|
|
251
|
+
contentContainerStyle={embedded ? styles.contentEmbedded : styles.content}
|
|
243
252
|
keyboardShouldPersistTaps="handled">
|
|
244
|
-
<View style={styles.section}>
|
|
245
|
-
<View style={styles.headerRow}>
|
|
246
|
-
<View>
|
|
253
|
+
<View style={embedded ? styles.sectionEmbedded : styles.section}>
|
|
254
|
+
<View style={[styles.headerRow, embedded && styles.headerRowEmbedded]}>
|
|
255
|
+
<View style={embedded ? styles.hidden : null}>
|
|
247
256
|
<Text style={styles.title}>Produtos</Text>
|
|
248
257
|
<Text style={styles.subtitle}>
|
|
249
258
|
{orderId
|
|
@@ -8,6 +8,21 @@ const styles = StyleSheet.create({
|
|
|
8
8
|
padding: 16,
|
|
9
9
|
paddingBottom: 36,
|
|
10
10
|
},
|
|
11
|
+
contentEmbedded: {
|
|
12
|
+
paddingHorizontal: 20,
|
|
13
|
+
paddingTop: 12,
|
|
14
|
+
paddingBottom: 24,
|
|
15
|
+
},
|
|
16
|
+
sectionEmbedded: {
|
|
17
|
+
backgroundColor: 'transparent',
|
|
18
|
+
},
|
|
19
|
+
headerRowEmbedded: {
|
|
20
|
+
marginBottom: 0,
|
|
21
|
+
minHeight: 0,
|
|
22
|
+
},
|
|
23
|
+
hidden: {
|
|
24
|
+
display: 'none',
|
|
25
|
+
},
|
|
11
26
|
section: {
|
|
12
27
|
backgroundColor: '#FFFFFF',
|
|
13
28
|
borderRadius: 14,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
ScrollView,
|
|
5
|
+
Text,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
useWindowDimensions,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
11
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
12
|
+
import { createDocumentDetailsStyles, resolveDocumentDetailsTheme } from './DocumentDetailsShell.styles';
|
|
13
|
+
|
|
14
|
+
const WIDE_BREAKPOINT = 768;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Shared layout for proposal/contract details.
|
|
18
|
+
* The header and the action bar stay fixed so the seller always sees who the
|
|
19
|
+
* document is for, its value and the main action, while the document itself
|
|
20
|
+
* gets the rest of the screen. Secondary data (products, signers) open in sheets.
|
|
21
|
+
*/
|
|
22
|
+
const DocumentDetailsShell = ({
|
|
23
|
+
theme,
|
|
24
|
+
title,
|
|
25
|
+
clientName,
|
|
26
|
+
meta,
|
|
27
|
+
totalLabel,
|
|
28
|
+
statusLabel,
|
|
29
|
+
statusColor,
|
|
30
|
+
onBack,
|
|
31
|
+
loading,
|
|
32
|
+
children,
|
|
33
|
+
secondaryActions = [],
|
|
34
|
+
primaryAction,
|
|
35
|
+
footerNote,
|
|
36
|
+
}) => {
|
|
37
|
+
const { width } = useWindowDimensions();
|
|
38
|
+
const isWide = width >= WIDE_BREAKPOINT;
|
|
39
|
+
const colors = resolveDocumentDetailsTheme(theme);
|
|
40
|
+
const styles = createDocumentDetailsStyles(colors, isWide);
|
|
41
|
+
const chipColor = statusColor || colors.muted;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<SafeAreaView style={styles.container} edges={['top', 'left', 'right']}>
|
|
45
|
+
<View style={styles.header}>
|
|
46
|
+
<View style={styles.headerInner}>
|
|
47
|
+
{onBack ? (
|
|
48
|
+
<TouchableOpacity
|
|
49
|
+
accessibilityRole="button"
|
|
50
|
+
accessibilityLabel="Voltar"
|
|
51
|
+
onPress={onBack}
|
|
52
|
+
style={styles.backButton}>
|
|
53
|
+
<Icon name="arrow-back" size={20} color={colors.text} />
|
|
54
|
+
</TouchableOpacity>
|
|
55
|
+
) : null}
|
|
56
|
+
|
|
57
|
+
<View style={styles.headerText}>
|
|
58
|
+
<View style={styles.titleRow}>
|
|
59
|
+
<Text style={styles.title} numberOfLines={1}>
|
|
60
|
+
{title}
|
|
61
|
+
</Text>
|
|
62
|
+
{statusLabel ? (
|
|
63
|
+
<View style={[styles.statusChip, { borderColor: `${chipColor}55`, backgroundColor: `${chipColor}14` }]}>
|
|
64
|
+
<View style={[styles.statusDot, { backgroundColor: chipColor }]} />
|
|
65
|
+
<Text style={[styles.statusText, { color: chipColor }]} numberOfLines={1}>
|
|
66
|
+
{statusLabel}
|
|
67
|
+
</Text>
|
|
68
|
+
</View>
|
|
69
|
+
) : null}
|
|
70
|
+
</View>
|
|
71
|
+
<Text style={styles.subtitle} numberOfLines={1}>
|
|
72
|
+
{[clientName, meta].filter(Boolean).join(' · ')}
|
|
73
|
+
</Text>
|
|
74
|
+
</View>
|
|
75
|
+
|
|
76
|
+
{totalLabel ? (
|
|
77
|
+
<View style={styles.totalBox}>
|
|
78
|
+
<Text style={styles.totalCaption}>Total</Text>
|
|
79
|
+
<Text style={styles.totalValue} numberOfLines={1}>
|
|
80
|
+
{totalLabel}
|
|
81
|
+
</Text>
|
|
82
|
+
</View>
|
|
83
|
+
) : null}
|
|
84
|
+
</View>
|
|
85
|
+
</View>
|
|
86
|
+
|
|
87
|
+
<ScrollView style={styles.body} contentContainerStyle={styles.bodyContent}>
|
|
88
|
+
<View style={styles.paper}>
|
|
89
|
+
{loading ? (
|
|
90
|
+
<View style={styles.loading}>
|
|
91
|
+
<ActivityIndicator color={colors.primary} />
|
|
92
|
+
</View>
|
|
93
|
+
) : (
|
|
94
|
+
children
|
|
95
|
+
)}
|
|
96
|
+
</View>
|
|
97
|
+
</ScrollView>
|
|
98
|
+
|
|
99
|
+
<View style={styles.footer}>
|
|
100
|
+
<View style={styles.footerInner}>
|
|
101
|
+
<View style={styles.secondaryActions}>
|
|
102
|
+
{secondaryActions.map(action => (
|
|
103
|
+
<TouchableOpacity
|
|
104
|
+
key={action.key}
|
|
105
|
+
accessibilityRole="button"
|
|
106
|
+
accessibilityLabel={action.label}
|
|
107
|
+
onPress={action.onPress}
|
|
108
|
+
style={styles.secondaryButton}>
|
|
109
|
+
<Icon name={action.icon} size={18} color={colors.text} />
|
|
110
|
+
{isWide ? <Text style={styles.secondaryLabel}>{action.label}</Text> : null}
|
|
111
|
+
{Number.isFinite(action.count) ? (
|
|
112
|
+
<View style={styles.countBadge}>
|
|
113
|
+
<Text style={styles.countText}>{action.count}</Text>
|
|
114
|
+
</View>
|
|
115
|
+
) : null}
|
|
116
|
+
</TouchableOpacity>
|
|
117
|
+
))}
|
|
118
|
+
</View>
|
|
119
|
+
|
|
120
|
+
{primaryAction ? (
|
|
121
|
+
<TouchableOpacity
|
|
122
|
+
accessibilityRole="button"
|
|
123
|
+
accessibilityLabel={primaryAction.label}
|
|
124
|
+
disabled={primaryAction.disabled || primaryAction.loading}
|
|
125
|
+
onPress={primaryAction.onPress}
|
|
126
|
+
style={[
|
|
127
|
+
styles.primaryButton,
|
|
128
|
+
(primaryAction.disabled || primaryAction.loading) && styles.primaryButtonDisabled,
|
|
129
|
+
]}>
|
|
130
|
+
{primaryAction.loading ? (
|
|
131
|
+
<ActivityIndicator color={colors.onPrimary} size="small" />
|
|
132
|
+
) : (
|
|
133
|
+
<Icon name={primaryAction.icon || 'check'} size={18} color={colors.onPrimary} />
|
|
134
|
+
)}
|
|
135
|
+
<Text style={styles.primaryLabel} numberOfLines={1}>
|
|
136
|
+
{primaryAction.label}
|
|
137
|
+
</Text>
|
|
138
|
+
</TouchableOpacity>
|
|
139
|
+
) : null}
|
|
140
|
+
</View>
|
|
141
|
+
{footerNote ? <Text style={styles.footerNote}>{footerNote}</Text> : null}
|
|
142
|
+
</View>
|
|
143
|
+
</SafeAreaView>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default DocumentDetailsShell;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_THEME = {
|
|
4
|
+
primary: '#1f6feb',
|
|
5
|
+
onPrimary: '#ffffff',
|
|
6
|
+
background: '#f3f5f8',
|
|
7
|
+
surface: '#ffffff',
|
|
8
|
+
text: '#0f172a',
|
|
9
|
+
muted: '#64748b',
|
|
10
|
+
border: '#e5e9f0',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const resolveDocumentDetailsTheme = theme => ({ ...DEFAULT_THEME, ...(theme || {}) });
|
|
14
|
+
|
|
15
|
+
const softShadow = Platform.select({
|
|
16
|
+
web: { boxShadow: '0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06)' },
|
|
17
|
+
default: {
|
|
18
|
+
shadowColor: '#0f172a',
|
|
19
|
+
shadowOpacity: 0.08,
|
|
20
|
+
shadowRadius: 12,
|
|
21
|
+
shadowOffset: { width: 0, height: 4 },
|
|
22
|
+
elevation: 2,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const MAX_CONTENT_WIDTH = 920;
|
|
27
|
+
|
|
28
|
+
export const createDocumentDetailsStyles = (colors, isWide) =>
|
|
29
|
+
StyleSheet.create({
|
|
30
|
+
container: { flex: 1, backgroundColor: colors.background },
|
|
31
|
+
|
|
32
|
+
header: {
|
|
33
|
+
backgroundColor: colors.surface,
|
|
34
|
+
borderBottomWidth: 1,
|
|
35
|
+
borderBottomColor: colors.border,
|
|
36
|
+
paddingHorizontal: isWide ? 24 : 12,
|
|
37
|
+
paddingVertical: isWide ? 12 : 10,
|
|
38
|
+
},
|
|
39
|
+
headerInner: {
|
|
40
|
+
flexDirection: 'row',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
width: '100%',
|
|
43
|
+
maxWidth: MAX_CONTENT_WIDTH,
|
|
44
|
+
alignSelf: 'center',
|
|
45
|
+
},
|
|
46
|
+
backButton: {
|
|
47
|
+
width: 36,
|
|
48
|
+
height: 36,
|
|
49
|
+
borderRadius: 18,
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
justifyContent: 'center',
|
|
52
|
+
backgroundColor: colors.background,
|
|
53
|
+
marginRight: 12,
|
|
54
|
+
},
|
|
55
|
+
headerText: { flex: 1, minWidth: 0 },
|
|
56
|
+
titleRow: { flexDirection: 'row', alignItems: 'center' },
|
|
57
|
+
title: {
|
|
58
|
+
flexShrink: 1,
|
|
59
|
+
fontSize: isWide ? 17 : 15,
|
|
60
|
+
fontWeight: '700',
|
|
61
|
+
color: colors.text,
|
|
62
|
+
letterSpacing: -0.2,
|
|
63
|
+
},
|
|
64
|
+
subtitle: { marginTop: 2, fontSize: 12.5, color: colors.muted },
|
|
65
|
+
statusChip: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
marginLeft: 8,
|
|
69
|
+
paddingHorizontal: 8,
|
|
70
|
+
paddingVertical: 2,
|
|
71
|
+
borderRadius: 999,
|
|
72
|
+
borderWidth: 1,
|
|
73
|
+
},
|
|
74
|
+
statusDot: { width: 6, height: 6, borderRadius: 3, marginRight: 5 },
|
|
75
|
+
statusText: { fontSize: 11.5, fontWeight: '700' },
|
|
76
|
+
totalBox: { marginLeft: 12, alignItems: 'flex-end' },
|
|
77
|
+
totalCaption: {
|
|
78
|
+
fontSize: 10.5,
|
|
79
|
+
fontWeight: '600',
|
|
80
|
+
color: colors.muted,
|
|
81
|
+
textTransform: 'uppercase',
|
|
82
|
+
letterSpacing: 0.6,
|
|
83
|
+
},
|
|
84
|
+
totalValue: { fontSize: isWide ? 18 : 15, fontWeight: '800', color: colors.text },
|
|
85
|
+
|
|
86
|
+
body: { flex: 1 },
|
|
87
|
+
bodyContent: {
|
|
88
|
+
paddingHorizontal: isWide ? 24 : 0,
|
|
89
|
+
paddingVertical: isWide ? 24 : 0,
|
|
90
|
+
paddingBottom: isWide ? 32 : 16,
|
|
91
|
+
},
|
|
92
|
+
paper: {
|
|
93
|
+
width: '100%',
|
|
94
|
+
maxWidth: MAX_CONTENT_WIDTH,
|
|
95
|
+
alignSelf: 'center',
|
|
96
|
+
backgroundColor: colors.surface,
|
|
97
|
+
borderRadius: isWide ? 14 : 0,
|
|
98
|
+
paddingHorizontal: isWide ? 40 : 16,
|
|
99
|
+
paddingVertical: isWide ? 36 : 16,
|
|
100
|
+
minHeight: 240,
|
|
101
|
+
...(isWide ? softShadow : {}),
|
|
102
|
+
},
|
|
103
|
+
loading: { paddingVertical: 48, alignItems: 'center' },
|
|
104
|
+
|
|
105
|
+
footer: {
|
|
106
|
+
backgroundColor: colors.surface,
|
|
107
|
+
borderTopWidth: 1,
|
|
108
|
+
borderTopColor: colors.border,
|
|
109
|
+
paddingHorizontal: isWide ? 24 : 12,
|
|
110
|
+
paddingTop: 10,
|
|
111
|
+
paddingBottom: Platform.OS === 'ios' ? 28 : 10,
|
|
112
|
+
},
|
|
113
|
+
footerInner: {
|
|
114
|
+
flexDirection: 'row',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
width: '100%',
|
|
117
|
+
maxWidth: MAX_CONTENT_WIDTH,
|
|
118
|
+
alignSelf: 'center',
|
|
119
|
+
},
|
|
120
|
+
secondaryActions: { flexDirection: 'row', alignItems: 'center', flexShrink: 0 },
|
|
121
|
+
secondaryButton: {
|
|
122
|
+
flexDirection: 'row',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
height: 42,
|
|
125
|
+
paddingHorizontal: isWide ? 14 : 12,
|
|
126
|
+
marginRight: 8,
|
|
127
|
+
borderRadius: 10,
|
|
128
|
+
borderWidth: 1,
|
|
129
|
+
borderColor: colors.border,
|
|
130
|
+
backgroundColor: colors.surface,
|
|
131
|
+
},
|
|
132
|
+
secondaryLabel: { marginLeft: 6, fontSize: 14, fontWeight: '600', color: colors.text },
|
|
133
|
+
countBadge: {
|
|
134
|
+
minWidth: 20,
|
|
135
|
+
height: 20,
|
|
136
|
+
paddingHorizontal: 6,
|
|
137
|
+
marginLeft: 6,
|
|
138
|
+
borderRadius: 10,
|
|
139
|
+
alignItems: 'center',
|
|
140
|
+
justifyContent: 'center',
|
|
141
|
+
backgroundColor: colors.background,
|
|
142
|
+
},
|
|
143
|
+
countText: { fontSize: 11.5, fontWeight: '700', color: colors.text },
|
|
144
|
+
primaryButton: {
|
|
145
|
+
flex: 1,
|
|
146
|
+
flexDirection: 'row',
|
|
147
|
+
alignItems: 'center',
|
|
148
|
+
justifyContent: 'center',
|
|
149
|
+
height: 44,
|
|
150
|
+
paddingHorizontal: 18,
|
|
151
|
+
borderRadius: 10,
|
|
152
|
+
backgroundColor: colors.primary,
|
|
153
|
+
...(isWide ? { flex: 0, minWidth: 220, marginLeft: 'auto' } : {}),
|
|
154
|
+
},
|
|
155
|
+
primaryButtonDisabled: { opacity: 0.5 },
|
|
156
|
+
primaryLabel: { marginLeft: 8, fontSize: 15, fontWeight: '700', color: colors.onPrimary },
|
|
157
|
+
footerNote: {
|
|
158
|
+
marginTop: 6,
|
|
159
|
+
fontSize: 12,
|
|
160
|
+
color: colors.muted,
|
|
161
|
+
textAlign: 'center',
|
|
162
|
+
},
|
|
163
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, Pressable, StyleSheet, Text, TouchableOpacity, useWindowDimensions, View } from 'react-native';
|
|
3
|
+
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
4
|
+
import AnimatedModal from '@controleonline/ui-common/src/react/components/AnimatedModal';
|
|
5
|
+
import { resolveDocumentDetailsTheme } from './DocumentDetailsShell.styles';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Bottom sheet (centered panel on wide screens) for secondary document data,
|
|
9
|
+
* such as products and signers, so they don't take space from the document.
|
|
10
|
+
*/
|
|
11
|
+
const DocumentSheet = ({ visible, onClose, title, subtitle, theme, children }) => {
|
|
12
|
+
const { width, height } = useWindowDimensions();
|
|
13
|
+
const isWide = width >= 768;
|
|
14
|
+
const colors = resolveDocumentDetailsTheme(theme);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<AnimatedModal visible={visible} onRequestClose={onClose}>
|
|
18
|
+
<Pressable style={styles.backdrop} onPress={onClose} accessibilityLabel="Fechar" />
|
|
19
|
+
<View
|
|
20
|
+
style={[
|
|
21
|
+
styles.sheet,
|
|
22
|
+
{
|
|
23
|
+
backgroundColor: colors.surface,
|
|
24
|
+
maxHeight: Math.round(height * (isWide ? 0.8 : 0.86)),
|
|
25
|
+
},
|
|
26
|
+
isWide ? styles.sheetWide : null,
|
|
27
|
+
]}>
|
|
28
|
+
<View style={styles.handleWrap}>
|
|
29
|
+
<View style={[styles.handle, { backgroundColor: colors.border }]} />
|
|
30
|
+
</View>
|
|
31
|
+
<View style={[styles.header, { borderBottomColor: colors.border }]}>
|
|
32
|
+
<View style={styles.headerText}>
|
|
33
|
+
<Text style={[styles.title, { color: colors.text }]} numberOfLines={1}>
|
|
34
|
+
{title}
|
|
35
|
+
</Text>
|
|
36
|
+
{subtitle ? (
|
|
37
|
+
<Text style={[styles.subtitle, { color: colors.muted }]} numberOfLines={1}>
|
|
38
|
+
{subtitle}
|
|
39
|
+
</Text>
|
|
40
|
+
) : null}
|
|
41
|
+
</View>
|
|
42
|
+
<TouchableOpacity
|
|
43
|
+
accessibilityRole="button"
|
|
44
|
+
accessibilityLabel="Fechar"
|
|
45
|
+
onPress={onClose}
|
|
46
|
+
style={[styles.close, { backgroundColor: colors.background }]}>
|
|
47
|
+
<Icon name="close" size={20} color={colors.text} />
|
|
48
|
+
</TouchableOpacity>
|
|
49
|
+
</View>
|
|
50
|
+
<View style={styles.body}>{children}</View>
|
|
51
|
+
</View>
|
|
52
|
+
</AnimatedModal>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const styles = StyleSheet.create({
|
|
57
|
+
backdrop: { flex: 1 },
|
|
58
|
+
sheet: {
|
|
59
|
+
width: '100%',
|
|
60
|
+
borderTopLeftRadius: 18,
|
|
61
|
+
borderTopRightRadius: 18,
|
|
62
|
+
overflow: 'hidden',
|
|
63
|
+
paddingBottom: Platform.OS === 'ios' ? 24 : 8,
|
|
64
|
+
},
|
|
65
|
+
sheetWide: {
|
|
66
|
+
maxWidth: 760,
|
|
67
|
+
alignSelf: 'center',
|
|
68
|
+
borderRadius: 18,
|
|
69
|
+
marginBottom: 32,
|
|
70
|
+
},
|
|
71
|
+
handleWrap: { alignItems: 'center', paddingTop: 8 },
|
|
72
|
+
handle: { width: 40, height: 4, borderRadius: 2 },
|
|
73
|
+
header: {
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
paddingHorizontal: 20,
|
|
77
|
+
paddingVertical: 12,
|
|
78
|
+
borderBottomWidth: 1,
|
|
79
|
+
},
|
|
80
|
+
headerText: { flex: 1, minWidth: 0 },
|
|
81
|
+
title: { fontSize: 17, fontWeight: '700', letterSpacing: -0.2 },
|
|
82
|
+
subtitle: { fontSize: 12.5, marginTop: 2 },
|
|
83
|
+
close: { width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center' },
|
|
84
|
+
body: { flexShrink: 1 },
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export default DocumentSheet;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Image, Text, View } from 'react-native';
|
|
3
3
|
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
-
import { colors } from '@controleonline
|
|
4
|
+
import { colors } from '@controleonline/ui-layout/src/styles/colors';
|
|
5
5
|
|
|
6
6
|
import createStyles from './styles';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {colors} from '@controleonline
|
|
3
|
-
import {withOpacity} from '@controleonline
|
|
2
|
+
import {colors} from '@controleonline/ui-layout/src/styles/colors';
|
|
3
|
+
import {withOpacity} from '@controleonline/ui-layout/src/styles/branding';
|
|
4
4
|
|
|
5
5
|
const createStyles = (palette = colors) =>
|
|
6
6
|
StyleSheet.create({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import { colors } from '@controleonline
|
|
4
|
+
import { colors } from '@controleonline/ui-layout/src/styles/colors';
|
|
5
5
|
|
|
6
6
|
import createStyles from './styles';
|
|
7
7
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
fetchLinkedOrder,
|
|
4
|
+
fetchOrderProducts,
|
|
5
|
+
} from '@controleonline/ui-common/src/react/utils/commercialDocumentOrders';
|
|
6
|
+
import { formatBRL, summarizeOrderProducts } from '@controleonline/ui-common/src/react/utils/orderProductsSummary';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Product count and total of the order linked to a proposal/contract, for the
|
|
10
|
+
* fixed document header. Call `reload` after products change.
|
|
11
|
+
*/
|
|
12
|
+
const useLinkedOrderSummary = contractRef => {
|
|
13
|
+
const [summary, setSummary] = useState({ count: 0, total: 0, loaded: false });
|
|
14
|
+
|
|
15
|
+
const reload = useCallback(async () => {
|
|
16
|
+
if (!contractRef) {
|
|
17
|
+
setSummary({ count: 0, total: 0, loaded: true });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const order = await fetchLinkedOrder(contractRef);
|
|
23
|
+
const items = order ? await fetchOrderProducts(order['@id'] || order.id) : [];
|
|
24
|
+
setSummary({ ...summarizeOrderProducts(items), loaded: true });
|
|
25
|
+
} catch {
|
|
26
|
+
setSummary(current => ({ ...current, loaded: true }));
|
|
27
|
+
}
|
|
28
|
+
}, [contractRef]);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
reload();
|
|
32
|
+
}, [reload]);
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...summary,
|
|
36
|
+
totalLabel: summary.loaded && summary.count > 0 ? formatBRL(summary.total) : null,
|
|
37
|
+
reload,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default useLinkedOrderSummary;
|