@controleonline/ui-crm 1.0.67 → 1.0.69
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.
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.68",
|
|
3
3
|
"rc": 1,
|
|
4
|
-
"branch": "rc/1.0.
|
|
5
|
-
"baseMaster": "
|
|
4
|
+
"branch": "rc/1.0.68-rc.1",
|
|
5
|
+
"baseMaster": "3474e1ce7b6d3dbdf5b1e11d67e41e1fa22fbeb3",
|
|
6
6
|
"tasks": [
|
|
7
|
-
64
|
|
7
|
+
64,
|
|
8
|
+
72
|
|
8
9
|
],
|
|
9
10
|
"frozen": true,
|
|
10
11
|
"repositories": {
|
|
11
|
-
"ControleOnline/ui-crm": "
|
|
12
|
+
"ControleOnline/ui-crm": "d1666948e80d583c46e4534d21c055143d1c8c1c"
|
|
12
13
|
}
|
|
13
14
|
}
|
package/package.json
CHANGED
|
@@ -62,8 +62,8 @@ export default function McpPage() {
|
|
|
62
62
|
</View>
|
|
63
63
|
) : null;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
const
|
|
65
|
+
// With the company's own AI the chat goes straight to it; the type choice exists only without AI.
|
|
66
|
+
const options = [['support', 'Suporte'], ['relationship', 'Comercial']];
|
|
67
67
|
|
|
68
68
|
return (
|
|
69
69
|
<KeyboardAvoidingView style={styles.root} behavior={Platform.OS === 'ios' ? 'padding' : undefined} keyboardVerticalOffset={80}>
|
|
@@ -112,20 +112,19 @@ export default function McpPage() {
|
|
|
112
112
|
onContentSizeChange={() => listRef.current?.scrollToEnd?.({animated: true})}
|
|
113
113
|
ListEmptyComponent={
|
|
114
114
|
<Text style={styles.emptyText}>
|
|
115
|
-
{chat.hasAi ? '
|
|
115
|
+
{chat.hasAi ? 'Como podemos ajudar? Descreva o que precisa.' : 'Escolha Suporte ou Comercial e descreva o que precisa.'}
|
|
116
116
|
</Text>
|
|
117
117
|
}
|
|
118
118
|
/>
|
|
119
119
|
)}
|
|
120
|
-
{isNew ? (
|
|
120
|
+
{isNew && !chat.hasAi ? (
|
|
121
121
|
<View style={styles.ticketTypeRow}>
|
|
122
122
|
{options.map(([value, label]) => (
|
|
123
123
|
<TouchableOpacity
|
|
124
124
|
key={value}
|
|
125
|
-
disabled={chat.hasAi}
|
|
126
125
|
onPress={() => chat.setTicketType(value)}
|
|
127
|
-
style={[styles.providerChip,
|
|
128
|
-
<Text style={[styles.providerChipText,
|
|
126
|
+
style={[styles.providerChip, chat.ticketType === value && styles.providerChipActive]}>
|
|
127
|
+
<Text style={[styles.providerChipText, chat.ticketType === value && styles.providerChipTextActive]}>{label}</Text>
|
|
129
128
|
</TouchableOpacity>
|
|
130
129
|
))}
|
|
131
130
|
</View>
|
|
@@ -64,7 +64,8 @@ export default function useMcpChat() {
|
|
|
64
64
|
const res = await api.fetch('/mcp/chat/providers', {params: companyId ? {company_id: companyId} : {}});
|
|
65
65
|
const list = Array.isArray(res?.providers) ? res.providers : [];
|
|
66
66
|
setProviders(list);
|
|
67
|
-
|
|
67
|
+
// The company's chosen AI (General settings → IA); otherwise the first connected one.
|
|
68
|
+
setProvider(prev => prev || res?.default || list.find(p => p.default)?.provider || list[0]?.provider || null);
|
|
68
69
|
} catch (e) {
|
|
69
70
|
showError(e?.message || 'Falha ao carregar providers de IA');
|
|
70
71
|
}
|
|
@@ -31,6 +31,7 @@ import MapsSection from './sections/MapsSection';
|
|
|
31
31
|
import ShopSettingsSection from './sections/shop/ShopSettingsSection';
|
|
32
32
|
import LogSection from './sections/LogSection';
|
|
33
33
|
import MaintenanceSection from './sections/MaintenanceSection';
|
|
34
|
+
import AiDefaultSection from './sections/AiDefaultSection';
|
|
34
35
|
|
|
35
36
|
const MAIN_COMPANY_ONLY_TABS = new Set(['shop']);
|
|
36
37
|
const TECHNICAL_TABS = new Set(['logs', 'maintenance']);
|
|
@@ -99,6 +100,13 @@ const SETTINGS_TABS = [
|
|
|
99
100
|
stores: ['configs'],
|
|
100
101
|
Component: CrmSection,
|
|
101
102
|
},
|
|
103
|
+
{
|
|
104
|
+
key: 'ai',
|
|
105
|
+
label: 'IA',
|
|
106
|
+
icon: 'chat',
|
|
107
|
+
stores: ['configs'],
|
|
108
|
+
Component: AiDefaultSection,
|
|
109
|
+
},
|
|
102
110
|
{
|
|
103
111
|
key: 'loyalty',
|
|
104
112
|
label: 'Fidelidade',
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents General settings → IA: lists the AIs already connected to the company (keys are configured in
|
|
3
|
+
* Integrações) and chooses which one the /ai chat uses (POST /mcp/chat/default, api-platform-mcp#86).
|
|
4
|
+
*/
|
|
5
|
+
import React, {useCallback, useEffect, useState} from 'react';
|
|
6
|
+
import {ActivityIndicator, Text, TouchableOpacity, View} from 'react-native';
|
|
7
|
+
import {useNavigation} from '@react-navigation/native';
|
|
8
|
+
|
|
9
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
10
|
+
import useToastMessage from '@controleonline/ui-crm/src/react/hooks/useToastMessage';
|
|
11
|
+
|
|
12
|
+
import {useGeneralSettingsPalette, useGeneralSettingsStyles} from '../GeneralSettings.styles';
|
|
13
|
+
import GeneralSettingsSection from '../GeneralSettingsSection';
|
|
14
|
+
import {useGeneralSettingsConfig} from '../GeneralSettings.shared';
|
|
15
|
+
|
|
16
|
+
const TITLES = {grok: 'Grok (xAI)', openai: 'Codex / OpenAI', gemini: 'Gemini', claude: 'Claude'};
|
|
17
|
+
|
|
18
|
+
const AiDefaultSection = () => {
|
|
19
|
+
const navigation = useNavigation();
|
|
20
|
+
const localStyles = useGeneralSettingsStyles();
|
|
21
|
+
const palette = useGeneralSettingsPalette();
|
|
22
|
+
const {showError, showSuccess} = useToastMessage();
|
|
23
|
+
const {currentCompany, mainCompany} = useGeneralSettingsConfig();
|
|
24
|
+
const companyId = Number(currentCompany?.id || mainCompany?.id || 0) || null;
|
|
25
|
+
|
|
26
|
+
const [loading, setLoading] = useState(true);
|
|
27
|
+
const [saving, setSaving] = useState(null);
|
|
28
|
+
const [providers, setProviders] = useState([]);
|
|
29
|
+
const [selected, setSelected] = useState(null);
|
|
30
|
+
|
|
31
|
+
const load = useCallback(async () => {
|
|
32
|
+
if (!companyId) return;
|
|
33
|
+
setLoading(true);
|
|
34
|
+
try {
|
|
35
|
+
const res = await api.fetch('/mcp/chat/providers', {params: {company_id: companyId}});
|
|
36
|
+
const list = Array.isArray(res?.providers) ? res.providers : [];
|
|
37
|
+
setProviders(list);
|
|
38
|
+
setSelected(res?.default || list.find(p => p.default)?.provider || list[0]?.provider || null);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
showError(e?.message || 'Não foi possível carregar as IAs conectadas.');
|
|
41
|
+
} finally {
|
|
42
|
+
setLoading(false);
|
|
43
|
+
}
|
|
44
|
+
}, [companyId, showError]);
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
load();
|
|
48
|
+
}, [load]);
|
|
49
|
+
|
|
50
|
+
const choose = async provider => {
|
|
51
|
+
if (provider === selected || saving) return;
|
|
52
|
+
setSaving(provider);
|
|
53
|
+
try {
|
|
54
|
+
await api.post('/mcp/chat/default', {provider, company_id: companyId});
|
|
55
|
+
setSelected(provider);
|
|
56
|
+
showSuccess(`${TITLES[provider] || provider} será usada no atendimento.`);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
showError(e?.message || 'Não foi possível salvar a IA padrão.');
|
|
59
|
+
} finally {
|
|
60
|
+
setSaving(null);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<GeneralSettingsSection
|
|
66
|
+
title="Inteligência Artificial"
|
|
67
|
+
description="Escolha qual das IAs conectadas atende no /ai. As chaves e modelos de cada IA são configurados em Integrações.">
|
|
68
|
+
{loading ? (
|
|
69
|
+
<ActivityIndicator style={{marginTop: 12}} />
|
|
70
|
+
) : providers.length === 0 ? (
|
|
71
|
+
<View>
|
|
72
|
+
<Text style={localStyles.helperText}>Nenhuma IA conectada nesta empresa.</Text>
|
|
73
|
+
<TouchableOpacity onPress={() => navigation.navigate('IntegrationsPage')} style={{marginTop: 8}}>
|
|
74
|
+
<Text style={{color: palette?.primary || '#1976d2', fontWeight: '600'}}>Conectar uma IA em Integrações</Text>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
</View>
|
|
77
|
+
) : (
|
|
78
|
+
<View>
|
|
79
|
+
{providers.map(p => {
|
|
80
|
+
const active = p.provider === selected;
|
|
81
|
+
return (
|
|
82
|
+
<TouchableOpacity
|
|
83
|
+
key={p.provider}
|
|
84
|
+
onPress={() => choose(p.provider)}
|
|
85
|
+
disabled={!!saving}
|
|
86
|
+
style={{
|
|
87
|
+
flexDirection: 'row',
|
|
88
|
+
alignItems: 'center',
|
|
89
|
+
paddingVertical: 12,
|
|
90
|
+
paddingHorizontal: 12,
|
|
91
|
+
marginBottom: 8,
|
|
92
|
+
borderRadius: 10,
|
|
93
|
+
borderWidth: 1,
|
|
94
|
+
borderColor: active ? palette?.primary || '#1976d2' : palette?.border || '#e2e8f0',
|
|
95
|
+
backgroundColor: palette?.surface || palette?.background || 'transparent',
|
|
96
|
+
}}>
|
|
97
|
+
<View
|
|
98
|
+
style={{
|
|
99
|
+
width: 18,
|
|
100
|
+
height: 18,
|
|
101
|
+
borderRadius: 9,
|
|
102
|
+
borderWidth: 2,
|
|
103
|
+
marginRight: 12,
|
|
104
|
+
borderColor: palette?.primary || '#1976d2',
|
|
105
|
+
backgroundColor: active ? palette?.primary || '#1976d2' : 'transparent',
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
<View style={{flex: 1}}>
|
|
109
|
+
<Text style={localStyles.sectionTitle}>{TITLES[p.provider] || p.label || p.provider}</Text>
|
|
110
|
+
<Text style={localStyles.helperText}>{p.model ? `Modelo: ${p.model}` : 'Modelo padrão'}</Text>
|
|
111
|
+
</View>
|
|
112
|
+
{saving === p.provider ? <ActivityIndicator /> : active ? <Text style={localStyles.helperText}>Em uso</Text> : null}
|
|
113
|
+
</TouchableOpacity>
|
|
114
|
+
);
|
|
115
|
+
})}
|
|
116
|
+
</View>
|
|
117
|
+
)}
|
|
118
|
+
</GeneralSettingsSection>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default AiDefaultSection;
|