@controleonline/ui-common 1.2.111 → 1.2.113
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 +6 -6
- package/package.json +1 -1
- 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/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/pages/AiProviderConfigPage.js +304 -0
- package/src/react/pages/Connections.js +96 -18
- 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 +15 -2
- 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.js +364 -280
- package/src/react/pages/WhatsAppConnectionPage.styles.js +279 -315
- package/src/react/pages/WhatsAppProviderForm.js +1 -1
- package/src/react/pages/integrationsCatalog.js +32 -0
- package/src/react/pages/whatsAppConnectionHelpers.js +10 -38
- package/src/react/router/publicRoutes.js +0 -3
- package/src/react/utils/fileUrl.js +1 -1
- package/src/store/connections/customActions.js +14 -16
- package/src/store/connections/index.js +105 -109
- package/src/react/router/__tests__/publicRoutes.test.js +0 -12
|
@@ -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/../../src/styles/branding';
|
|
41
|
+
import {colors as runtimeColors} from '@controleonline/../../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/../../src/styles/branding';
|
|
37
|
+
import { colors as runtimeColors } from '@controleonline/../../src/styles/colors';
|
|
38
38
|
import {
|
|
39
39
|
buildDefaultDeviceConfigs,
|
|
40
40
|
buildProviderManagedDeviceConfigs,
|
|
@@ -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/../../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/../../src/styles/colors';
|
|
3
|
+
import {withOpacity} from '@controleonline/../../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/../../src/styles/colors';
|
|
5
5
|
|
|
6
6
|
import createStyles from './styles';
|
|
7
7
|
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agents Single AI provider config (Grok/OpenAI/Gemini/Claude) for Integrations hub.
|
|
3
|
+
* Uses /mcp/chat/config; keys stay server-side (masked on GET).
|
|
4
|
+
*/
|
|
5
|
+
import React, {useCallback, useEffect, useMemo, useState} from 'react';
|
|
6
|
+
import {
|
|
7
|
+
ActivityIndicator,
|
|
8
|
+
ScrollView,
|
|
9
|
+
Switch,
|
|
10
|
+
Text,
|
|
11
|
+
TextInput,
|
|
12
|
+
TouchableOpacity,
|
|
13
|
+
View,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import {SafeAreaView} from 'react-native-safe-area-context';
|
|
16
|
+
import {useFocusEffect} from '@react-navigation/native';
|
|
17
|
+
|
|
18
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
19
|
+
import useToastMessage from '@controleonline/ui-crm/src/react/hooks/useToastMessage';
|
|
20
|
+
import {useStore} from '@store';
|
|
21
|
+
import {colors} from '@controleonline/../../src/styles/colors';
|
|
22
|
+
import {resolveThemePalette} from '@controleonline/../../src/styles/branding';
|
|
23
|
+
|
|
24
|
+
const PROVIDER_TITLES = {
|
|
25
|
+
grok: 'Grok (xAI)',
|
|
26
|
+
openai: 'Codex / OpenAI',
|
|
27
|
+
gemini: 'Gemini',
|
|
28
|
+
claude: 'Claude',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ALL_KEYS = ['grok', 'openai', 'gemini', 'claude'];
|
|
32
|
+
|
|
33
|
+
const emptyProvider = () => ({
|
|
34
|
+
enabled: false,
|
|
35
|
+
model: '',
|
|
36
|
+
base_url: '',
|
|
37
|
+
system_prompt: '',
|
|
38
|
+
api_key: '',
|
|
39
|
+
has_key: false,
|
|
40
|
+
api_key_masked: null,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export default function AiProviderConfigPage({route}) {
|
|
44
|
+
const providerKey = String(
|
|
45
|
+
route?.params?.providerKey || route?.params?.provider || '',
|
|
46
|
+
)
|
|
47
|
+
.trim()
|
|
48
|
+
.toLowerCase();
|
|
49
|
+
|
|
50
|
+
const peopleStore = useStore('people');
|
|
51
|
+
const themeStore = useStore('theme');
|
|
52
|
+
const {currentCompany} = peopleStore.getters || {};
|
|
53
|
+
const {colors: themeColors} = themeStore.getters || {};
|
|
54
|
+
const brand = resolveThemePalette(themeColors || colors || {});
|
|
55
|
+
const {showError, showSuccess} = useToastMessage();
|
|
56
|
+
|
|
57
|
+
const companyId = currentCompany?.id || null;
|
|
58
|
+
const title = PROVIDER_TITLES[providerKey] || providerKey || 'IA';
|
|
59
|
+
|
|
60
|
+
const [loading, setLoading] = useState(true);
|
|
61
|
+
const [saving, setSaving] = useState(false);
|
|
62
|
+
const [allProviders, setAllProviders] = useState(() => {
|
|
63
|
+
const init = {};
|
|
64
|
+
ALL_KEYS.forEach(k => {
|
|
65
|
+
init[k] = emptyProvider();
|
|
66
|
+
});
|
|
67
|
+
return init;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const provider = allProviders[providerKey] || emptyProvider();
|
|
71
|
+
|
|
72
|
+
const styles = useMemo(
|
|
73
|
+
() => ({
|
|
74
|
+
container: {flex: 1, backgroundColor: brand.background || '#F8FAFC'},
|
|
75
|
+
scroll: {padding: 16, paddingBottom: 40},
|
|
76
|
+
card: {
|
|
77
|
+
backgroundColor: brand.surface || '#FFF',
|
|
78
|
+
borderRadius: 12,
|
|
79
|
+
borderWidth: 1,
|
|
80
|
+
borderColor: brand.border || '#E2E8F0',
|
|
81
|
+
padding: 16,
|
|
82
|
+
marginBottom: 12,
|
|
83
|
+
},
|
|
84
|
+
title: {
|
|
85
|
+
fontSize: 18,
|
|
86
|
+
fontWeight: '700',
|
|
87
|
+
color: brand.text || '#0F172A',
|
|
88
|
+
marginBottom: 4,
|
|
89
|
+
},
|
|
90
|
+
helper: {fontSize: 13, color: brand.textSecondary || '#64748B', marginBottom: 16},
|
|
91
|
+
label: {
|
|
92
|
+
fontSize: 13,
|
|
93
|
+
fontWeight: '600',
|
|
94
|
+
color: brand.textSecondary || '#64748B',
|
|
95
|
+
marginBottom: 6,
|
|
96
|
+
marginTop: 12,
|
|
97
|
+
},
|
|
98
|
+
input: {
|
|
99
|
+
borderWidth: 1,
|
|
100
|
+
borderColor: brand.border || '#E2E8F0',
|
|
101
|
+
borderRadius: 8,
|
|
102
|
+
paddingHorizontal: 12,
|
|
103
|
+
paddingVertical: 10,
|
|
104
|
+
color: brand.text || '#0F172A',
|
|
105
|
+
backgroundColor: brand.inputBackground || '#FFF',
|
|
106
|
+
},
|
|
107
|
+
row: {
|
|
108
|
+
flexDirection: 'row',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
justifyContent: 'space-between',
|
|
111
|
+
marginBottom: 8,
|
|
112
|
+
},
|
|
113
|
+
button: {
|
|
114
|
+
marginTop: 20,
|
|
115
|
+
backgroundColor: brand.primary || '#2563EB',
|
|
116
|
+
borderRadius: 10,
|
|
117
|
+
paddingVertical: 14,
|
|
118
|
+
alignItems: 'center',
|
|
119
|
+
},
|
|
120
|
+
buttonText: {color: '#FFF', fontWeight: '700', fontSize: 15},
|
|
121
|
+
center: {flex: 1, justifyContent: 'center', alignItems: 'center', padding: 24},
|
|
122
|
+
}),
|
|
123
|
+
[brand],
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const load = useCallback(async () => {
|
|
127
|
+
if (!companyId || !providerKey || !ALL_KEYS.includes(providerKey)) {
|
|
128
|
+
setLoading(false);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
setLoading(true);
|
|
132
|
+
try {
|
|
133
|
+
const res = await api.fetch('/mcp/chat/config', {
|
|
134
|
+
params: {company_id: Number(companyId)},
|
|
135
|
+
});
|
|
136
|
+
const remote = res?.providers || {};
|
|
137
|
+
const next = {};
|
|
138
|
+
ALL_KEYS.forEach(k => {
|
|
139
|
+
const r = remote[k] || {};
|
|
140
|
+
next[k] = {
|
|
141
|
+
enabled: !!r.enabled,
|
|
142
|
+
model: String(r.model || ''),
|
|
143
|
+
base_url: String(r.base_url || ''),
|
|
144
|
+
system_prompt: String(r.system_prompt || ''),
|
|
145
|
+
api_key: '',
|
|
146
|
+
has_key: !!r.has_key,
|
|
147
|
+
api_key_masked: r.api_key_masked || null,
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
setAllProviders(next);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
showError(e?.message || 'Falha ao carregar configuracao de IA');
|
|
153
|
+
} finally {
|
|
154
|
+
setLoading(false);
|
|
155
|
+
}
|
|
156
|
+
}, [companyId, providerKey, showError]);
|
|
157
|
+
|
|
158
|
+
useFocusEffect(
|
|
159
|
+
useCallback(() => {
|
|
160
|
+
load();
|
|
161
|
+
}, [load]),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const updateField = (field, value) => {
|
|
165
|
+
setAllProviders(prev => ({
|
|
166
|
+
...prev,
|
|
167
|
+
[providerKey]: {...(prev[providerKey] || emptyProvider()), [field]: value},
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const save = useCallback(async () => {
|
|
172
|
+
if (!companyId || !providerKey) {
|
|
173
|
+
showError('Empresa ou provider invalido.');
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
setSaving(true);
|
|
177
|
+
try {
|
|
178
|
+
const payload = {};
|
|
179
|
+
ALL_KEYS.forEach(k => {
|
|
180
|
+
const p = allProviders[k] || emptyProvider();
|
|
181
|
+
payload[k] = {
|
|
182
|
+
enabled: !!p.enabled,
|
|
183
|
+
model: String(p.model || '').trim(),
|
|
184
|
+
base_url: String(p.base_url || '').trim(),
|
|
185
|
+
system_prompt: String(p.system_prompt || ''),
|
|
186
|
+
api_key: String(p.api_key || '').trim(),
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
await api.put('/mcp/chat/config', {
|
|
190
|
+
company_id: Number(companyId),
|
|
191
|
+
providers: payload,
|
|
192
|
+
});
|
|
193
|
+
showSuccess(`${title} salvo.`);
|
|
194
|
+
await load();
|
|
195
|
+
} catch (e) {
|
|
196
|
+
showError(e?.message || 'Falha ao salvar');
|
|
197
|
+
} finally {
|
|
198
|
+
setSaving(false);
|
|
199
|
+
}
|
|
200
|
+
}, [allProviders, companyId, load, providerKey, showError, showSuccess, title]);
|
|
201
|
+
|
|
202
|
+
if (!providerKey || !ALL_KEYS.includes(providerKey)) {
|
|
203
|
+
return (
|
|
204
|
+
<SafeAreaView style={styles.container} edges={['bottom']}>
|
|
205
|
+
<View style={styles.center}>
|
|
206
|
+
<Text style={styles.title}>Provider de IA invalido</Text>
|
|
207
|
+
</View>
|
|
208
|
+
</SafeAreaView>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (!companyId) {
|
|
213
|
+
return (
|
|
214
|
+
<SafeAreaView style={styles.container} edges={['bottom']}>
|
|
215
|
+
<View style={styles.center}>
|
|
216
|
+
<Text style={styles.title}>Selecione uma empresa</Text>
|
|
217
|
+
<Text style={styles.helper}>A configuracao de IA e por empresa ativa.</Text>
|
|
218
|
+
</View>
|
|
219
|
+
</SafeAreaView>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (loading) {
|
|
224
|
+
return (
|
|
225
|
+
<SafeAreaView style={styles.container} edges={['bottom']}>
|
|
226
|
+
<View style={styles.center}>
|
|
227
|
+
<ActivityIndicator size="large" color={brand.primary || '#2563EB'} />
|
|
228
|
+
</View>
|
|
229
|
+
</SafeAreaView>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<SafeAreaView style={styles.container} edges={['bottom']}>
|
|
235
|
+
<ScrollView contentContainerStyle={styles.scroll}>
|
|
236
|
+
<View style={styles.card}>
|
|
237
|
+
<View style={styles.row}>
|
|
238
|
+
<Text style={styles.title}>{title}</Text>
|
|
239
|
+
<Switch
|
|
240
|
+
value={!!provider.enabled}
|
|
241
|
+
onValueChange={v => updateField('enabled', v)}
|
|
242
|
+
disabled={saving}
|
|
243
|
+
/>
|
|
244
|
+
</View>
|
|
245
|
+
<Text style={styles.helper}>
|
|
246
|
+
Chave e prompt usados no chat /ai. A chave nao retorna em claro apos salvar.
|
|
247
|
+
</Text>
|
|
248
|
+
|
|
249
|
+
<Text style={styles.label}>API key</Text>
|
|
250
|
+
<TextInput
|
|
251
|
+
style={styles.input}
|
|
252
|
+
value={provider.api_key}
|
|
253
|
+
onChangeText={v => updateField('api_key', v)}
|
|
254
|
+
placeholder={
|
|
255
|
+
provider.has_key
|
|
256
|
+
? provider.api_key_masked || '•••• (cadastrada)'
|
|
257
|
+
: 'Cole a API key'
|
|
258
|
+
}
|
|
259
|
+
secureTextEntry
|
|
260
|
+
autoCapitalize="none"
|
|
261
|
+
editable={!saving}
|
|
262
|
+
/>
|
|
263
|
+
|
|
264
|
+
<Text style={styles.label}>Modelo</Text>
|
|
265
|
+
<TextInput
|
|
266
|
+
style={styles.input}
|
|
267
|
+
value={provider.model}
|
|
268
|
+
onChangeText={v => updateField('model', v)}
|
|
269
|
+
placeholder="ex.: grok-4, gpt-4.1, gemini-2.0-flash"
|
|
270
|
+
autoCapitalize="none"
|
|
271
|
+
editable={!saving}
|
|
272
|
+
/>
|
|
273
|
+
|
|
274
|
+
<Text style={styles.label}>Base URL (opcional)</Text>
|
|
275
|
+
<TextInput
|
|
276
|
+
style={styles.input}
|
|
277
|
+
value={provider.base_url}
|
|
278
|
+
onChangeText={v => updateField('base_url', v)}
|
|
279
|
+
placeholder="https://..."
|
|
280
|
+
autoCapitalize="none"
|
|
281
|
+
editable={!saving}
|
|
282
|
+
/>
|
|
283
|
+
|
|
284
|
+
<Text style={styles.label}>Prompt inicial (system)</Text>
|
|
285
|
+
<TextInput
|
|
286
|
+
style={[styles.input, {minHeight: 100, textAlignVertical: 'top'}]}
|
|
287
|
+
value={provider.system_prompt}
|
|
288
|
+
onChangeText={v => updateField('system_prompt', v)}
|
|
289
|
+
placeholder="Instrucoes enviadas em toda conversa"
|
|
290
|
+
multiline
|
|
291
|
+
editable={!saving}
|
|
292
|
+
/>
|
|
293
|
+
|
|
294
|
+
<TouchableOpacity
|
|
295
|
+
style={[styles.button, saving && {opacity: 0.6}]}
|
|
296
|
+
onPress={save}
|
|
297
|
+
disabled={saving}>
|
|
298
|
+
<Text style={styles.buttonText}>{saving ? 'Salvando...' : 'Salvar'}</Text>
|
|
299
|
+
</TouchableOpacity>
|
|
300
|
+
</View>
|
|
301
|
+
</ScrollView>
|
|
302
|
+
</SafeAreaView>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
|
2
|
-
import { Text, View } from 'react-native';
|
|
2
|
+
import { Platform, Text, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
4
4
|
import { useFocusEffect, useNavigation } from '@react-navigation/native';
|
|
5
5
|
import Icon from 'react-native-vector-icons/Feather';
|
|
6
6
|
|
|
7
7
|
import { useStore } from '@store';
|
|
8
|
-
import { colors } from '@controleonline
|
|
8
|
+
import { colors } from '@controleonline/../../src/styles/colors';
|
|
9
9
|
import { createStyles } from './Connections.styles';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
resolveThemePalette,
|
|
12
|
+
withOpacity,
|
|
13
|
+
} from '@controleonline/../../src/styles/branding';
|
|
11
14
|
import DefaultTable from '@controleonline/ui-default/src/react/components/table/DefaultTable';
|
|
12
15
|
|
|
13
16
|
const tt = (type, key) => global.t?.t('configs', type, key);
|
|
14
17
|
|
|
18
|
+
const resolveShadowStyle = textColor =>
|
|
19
|
+
Platform.select({
|
|
20
|
+
ios: {
|
|
21
|
+
shadowColor: textColor,
|
|
22
|
+
shadowOffset: { width: 0, height: 8 },
|
|
23
|
+
shadowOpacity: 0.08,
|
|
24
|
+
shadowRadius: 16,
|
|
25
|
+
},
|
|
26
|
+
android: { elevation: 3 },
|
|
27
|
+
web: { boxShadow: `0 10px 24px ${withOpacity(textColor, 0.08)}` },
|
|
28
|
+
});
|
|
29
|
+
|
|
15
30
|
const formatPhoneLabel = phone => {
|
|
16
31
|
if (!phone) return tt('connections_label', 'notProvided') || 'Nao informado';
|
|
17
32
|
if (typeof phone === 'string') return phone;
|
|
@@ -26,17 +41,11 @@ const formatPhoneLabel = phone => {
|
|
|
26
41
|
};
|
|
27
42
|
|
|
28
43
|
const formatStatusLabel = status => {
|
|
29
|
-
if (!status) return '—';
|
|
44
|
+
if (!status) return tt('connections_status', 'unknown') || '—';
|
|
30
45
|
if (typeof status === 'string') return status;
|
|
31
46
|
return status?.status || status?.name || '—';
|
|
32
47
|
};
|
|
33
48
|
|
|
34
|
-
const formatChannelLabel = channel => {
|
|
35
|
-
if (channel === 'whatsapp_official') return 'WhatsApp Oficial';
|
|
36
|
-
if (channel === 'whatsapp') return 'WhatsApp';
|
|
37
|
-
return channel || '—';
|
|
38
|
-
};
|
|
39
|
-
|
|
40
49
|
export default function Connections() {
|
|
41
50
|
const navigation = useNavigation();
|
|
42
51
|
const peopleStore = useStore('people');
|
|
@@ -45,6 +54,8 @@ export default function Connections() {
|
|
|
45
54
|
|
|
46
55
|
const { currentCompany } = peopleStore.getters || {};
|
|
47
56
|
const { colors: themeColors } = themeStore.getters || {};
|
|
57
|
+
const items = connectionsStore.getters?.items;
|
|
58
|
+
const totalItems = connectionsStore.getters?.totalItems;
|
|
48
59
|
|
|
49
60
|
const brandColors = useMemo(
|
|
50
61
|
() =>
|
|
@@ -52,10 +63,13 @@ export default function Connections() {
|
|
|
52
63
|
{ ...themeColors, ...(currentCompany?.theme?.colors || {}) },
|
|
53
64
|
colors,
|
|
54
65
|
),
|
|
55
|
-
[themeColors, currentCompany],
|
|
66
|
+
[themeColors, currentCompany?.id],
|
|
56
67
|
);
|
|
57
|
-
|
|
58
68
|
const styles = useMemo(() => createStyles(brandColors), [brandColors]);
|
|
69
|
+
const shadowStyle = useMemo(
|
|
70
|
+
() => resolveShadowStyle(brandColors.text),
|
|
71
|
+
[brandColors.text],
|
|
72
|
+
);
|
|
59
73
|
|
|
60
74
|
const providerId = currentCompany?.id;
|
|
61
75
|
const peopleIri = useMemo(
|
|
@@ -68,6 +82,11 @@ export default function Connections() {
|
|
|
68
82
|
[peopleIri],
|
|
69
83
|
);
|
|
70
84
|
|
|
85
|
+
const connectionCount = useMemo(() => {
|
|
86
|
+
if (typeof totalItems === 'number' && totalItems > 0) return totalItems;
|
|
87
|
+
return Array.isArray(items) ? items.length : 0;
|
|
88
|
+
}, [items, totalItems]);
|
|
89
|
+
|
|
71
90
|
useFocusEffect(
|
|
72
91
|
useCallback(() => {
|
|
73
92
|
if (!peopleIri || typeof connectionsStore.actions?.getItems !== 'function') {
|
|
@@ -90,9 +109,7 @@ export default function Connections() {
|
|
|
90
109
|
{item.name || tt('connections_label', 'unnamed') || 'Sem nome'}
|
|
91
110
|
</Text>
|
|
92
111
|
<Text style={styles.previewPhone}>{formatPhoneLabel(item.phone)}</Text>
|
|
93
|
-
<Text style={styles.previewStatus}>
|
|
94
|
-
{formatChannelLabel(item.channel)} · {formatStatusLabel(item.status)}
|
|
95
|
-
</Text>
|
|
112
|
+
<Text style={styles.previewStatus}>{formatStatusLabel(item.status)}</Text>
|
|
96
113
|
</View>
|
|
97
114
|
);
|
|
98
115
|
},
|
|
@@ -120,11 +137,72 @@ export default function Connections() {
|
|
|
120
137
|
<SafeAreaView
|
|
121
138
|
style={[styles.container, { backgroundColor: brandColors.background }]}
|
|
122
139
|
edges={['bottom']}>
|
|
123
|
-
<View style={
|
|
140
|
+
<View style={[styles.heroCard, shadowStyle, { backgroundColor: brandColors.primary }]}>
|
|
141
|
+
<View style={styles.heroCopy}>
|
|
142
|
+
<Text style={styles.heroEyebrow}>
|
|
143
|
+
{tt('connections_eyebrow', 'communication') || 'COMUNICACAO'}
|
|
144
|
+
</Text>
|
|
145
|
+
<Text style={styles.heroTitle}>
|
|
146
|
+
{tt('connections_title', 'connections') || 'Conexoes'}
|
|
147
|
+
</Text>
|
|
148
|
+
<Text style={styles.heroText}>
|
|
149
|
+
{tt('connections_text', 'hero') ||
|
|
150
|
+
'Gerencie os canais de comunicacao conectados com a sua operacao.'}
|
|
151
|
+
</Text>
|
|
152
|
+
</View>
|
|
153
|
+
<View style={styles.heroBadge}>
|
|
154
|
+
<Icon name="radio" size={22} color={brandColors.primary} />
|
|
155
|
+
</View>
|
|
156
|
+
</View>
|
|
157
|
+
|
|
158
|
+
<View style={styles.companyRow}>
|
|
159
|
+
<View style={styles.companyBadge}>
|
|
160
|
+
<Text style={styles.companyBadgeText}>
|
|
161
|
+
{`${connectionCount} ${tt('connections_label', 'connections') || 'conexoes'}`}
|
|
162
|
+
</Text>
|
|
163
|
+
</View>
|
|
164
|
+
</View>
|
|
165
|
+
|
|
166
|
+
<TouchableOpacity
|
|
167
|
+
activeOpacity={0.92}
|
|
168
|
+
onPress={openWhatsAppChannel}
|
|
169
|
+
style={[styles.channelCard, shadowStyle]}>
|
|
170
|
+
<View style={styles.channelTopRow}>
|
|
171
|
+
<View
|
|
172
|
+
style={[
|
|
173
|
+
styles.channelIconWrap,
|
|
174
|
+
{ backgroundColor: withOpacity(brandColors.success, 0.12) },
|
|
175
|
+
]}>
|
|
176
|
+
<Icon name="message-circle" size={20} color={brandColors.success} />
|
|
177
|
+
</View>
|
|
178
|
+
<View style={styles.channelStatusPill}>
|
|
179
|
+
<Text style={styles.channelStatusText}>
|
|
180
|
+
{connectionCount > 0
|
|
181
|
+
? `${connectionCount} ${tt('connections_status', 'configured') || 'configurada(s)'}`
|
|
182
|
+
: tt('connections_status', 'readyToConfigure') || 'Pronta para configurar'}
|
|
183
|
+
</Text>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
<Text style={styles.channelTitle}>
|
|
187
|
+
{tt('connections_label', 'whatsApp') || 'WhatsApp'}
|
|
188
|
+
</Text>
|
|
189
|
+
<Text style={styles.channelDescription}>
|
|
190
|
+
{tt('connections_text', 'whatsApp') ||
|
|
191
|
+
'Conecte numeros, acompanhe status e gere o QR Code de autenticacao.'}
|
|
192
|
+
</Text>
|
|
193
|
+
<View style={styles.actionRow}>
|
|
194
|
+
<Text style={styles.actionText}>
|
|
195
|
+
{tt('connections_button', 'openChannel') || 'Abrir canal'}
|
|
196
|
+
</Text>
|
|
197
|
+
<Icon name="arrow-right" size={18} color={brandColors.primary} />
|
|
198
|
+
</View>
|
|
199
|
+
</TouchableOpacity>
|
|
200
|
+
|
|
201
|
+
<View style={{ flex: 1, marginTop: 12 }}>
|
|
124
202
|
<DefaultTable
|
|
125
203
|
storeName="connections"
|
|
126
204
|
requestParams={requestParams}
|
|
127
|
-
initialViewMode="
|
|
205
|
+
initialViewMode="cards"
|
|
128
206
|
forceCardsOnCompact
|
|
129
207
|
showToolbar
|
|
130
208
|
showRowActions={false}
|
|
@@ -141,7 +219,7 @@ export default function Connections() {
|
|
|
141
219
|
accentColor={brandColors.primary}
|
|
142
220
|
onAdd={openWhatsAppChannel}
|
|
143
221
|
add
|
|
144
|
-
addLabel={tt('connections_button', 'openChannel') || '
|
|
222
|
+
addLabel={tt('connections_button', 'openChannel') || 'Abrir canal'}
|
|
145
223
|
/>
|
|
146
224
|
</View>
|
|
147
225
|
</SafeAreaView>
|