@controleonline/ui-crm 1.0.44 → 1.0.45
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/.github/workflows/integration-source-gate.yml +1 -15
- package/.github/workflows/manager-worker.yml +155 -7
- package/.github/workflows/publish-npm.yml +22 -73
- package/AGENTS.md +0 -2
- package/package.json +2 -2
- package/src/react/pages/crm/hooks/useCrmData.js +17 -23
- package/src/react/pages/mcp/McpPage.js +301 -0
- package/src/react/pages/mcp/McpPage.styles.js +116 -0
- package/src/react/pages/proposals/CreateProposalsModal.js +0 -1
- package/src/react/pages/proposals/index.js +33 -14
- package/src/react/pages/settings/GeneralSettings.js +17 -9
- package/src/react/pages/settings/GeneralSettings.shared.js +20 -20
- package/src/react/pages/settings/GeneralSettings.styles.js +0 -2
- package/src/react/pages/settings/sections/AiProvidersSection.js +263 -0
- package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +11 -11
- package/src/react/pages/settings/sections/IntegrationsSection.js +17 -17
- package/src/react/pages/settings/sections/LogSection.js +10 -10
- package/src/react/pages/settings/sections/LoginSection.js +13 -13
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +145 -58
- package/src/react/pages/settings/sections/LoyaltySection.js +9 -35
- package/src/react/pages/settings/sections/MaintenanceSection.js +16 -16
- package/src/react/pages/settings/sections/MapsSection.js +257 -81
- package/src/react/pages/settings/sections/ShopSection.js +2 -2
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +28 -7
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +8 -54
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +11 -32
- package/src/react/router/routes.js +14 -0
- package/src/react/utils/proposalProductSelection.js +13 -103
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +0 -25
- package/src/tests/browser/manager/general-settings-maps.spec.js +347 -173
- package/src/tests/react/utils/proposalProductSelection.test.js +1 -57
- package/src/react/pages/settings/sections/MapsFranchisePreview.js +0 -102
- package/src/react/pages/settings/sections/MapsMapasControls.js +0 -262
- package/src/react/pages/settings/sections/loyaltyProductCompany.js +0 -57
- package/src/react/pages/settings/sections/mapsSectionHelpers.js +0 -137
- package/src/react/utils/clientDetailsNavigation.js +0 -56
- package/src/react/utils/clientSellerVisibility.js +0 -60
- package/src/react/utils/proposalStatus.js +0 -160
- package/src/tests/react/pages/settings/sections/loyaltyProductCompany.test.js +0 -41
- package/src/tests/react/pages/settings/sections/mapsSectionHelpers.test.js +0 -38
- package/src/tests/react/utils/clientDetailsNavigation.test.js +0 -98
- package/src/tests/react/utils/clientSellerVisibility.test.js +0 -74
- package/src/tests/react/utils/proposalStatus.test.mjs +0 -77
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @agents MCP AI chat (Task type=ia). Keep under 500 lines; API via /mcp/chat*.
|
|
3
|
+
*/
|
|
4
|
+
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
|
|
5
|
+
import {
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
FlatList,
|
|
8
|
+
KeyboardAvoidingView,
|
|
9
|
+
Platform,
|
|
10
|
+
ScrollView,
|
|
11
|
+
Text,
|
|
12
|
+
TextInput,
|
|
13
|
+
TouchableOpacity,
|
|
14
|
+
View,
|
|
15
|
+
} from 'react-native';
|
|
16
|
+
import {useStore} from '@store';
|
|
17
|
+
import {api} from '@controleonline/ui-common/src/api';
|
|
18
|
+
import useToastMessage from '../../hooks/useToastMessage';
|
|
19
|
+
import styles from './McpPage.styles';
|
|
20
|
+
|
|
21
|
+
const PROVIDER_LABELS = {
|
|
22
|
+
grok: 'Grok',
|
|
23
|
+
openai: 'Codex / OpenAI',
|
|
24
|
+
gemini: 'Gemini',
|
|
25
|
+
claude: 'Claude',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default function McpPage() {
|
|
29
|
+
const {showError, showSuccess} = useToastMessage();
|
|
30
|
+
const peopleStore = useStore('people');
|
|
31
|
+
const company =
|
|
32
|
+
peopleStore?.getters?.currentCompany ||
|
|
33
|
+
peopleStore?.getters?.defaultCompany ||
|
|
34
|
+
null;
|
|
35
|
+
const companyId = company?.id || company?.['@id']?.split('/').pop() || null;
|
|
36
|
+
|
|
37
|
+
const [providers, setProviders] = useState([]);
|
|
38
|
+
const [provider, setProvider] = useState(null);
|
|
39
|
+
const [tasks, setTasks] = useState([]);
|
|
40
|
+
const [activeTaskId, setActiveTaskId] = useState(null);
|
|
41
|
+
const [messages, setMessages] = useState([]);
|
|
42
|
+
const [draft, setDraft] = useState('');
|
|
43
|
+
const [loadingList, setLoadingList] = useState(true);
|
|
44
|
+
const [loadingChat, setLoadingChat] = useState(false);
|
|
45
|
+
const [sending, setSending] = useState(false);
|
|
46
|
+
const listRef = useRef(null);
|
|
47
|
+
|
|
48
|
+
const companyQuery = useMemo(
|
|
49
|
+
() => (companyId ? {company_id: Number(companyId)} : {}),
|
|
50
|
+
[companyId],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const loadProviders = useCallback(async () => {
|
|
54
|
+
try {
|
|
55
|
+
const res = await api.fetch('/mcp/chat/providers', {params: companyQuery});
|
|
56
|
+
const list = res?.providers || res?.member || res || [];
|
|
57
|
+
const arr = Array.isArray(list) ? list : [];
|
|
58
|
+
setProviders(arr);
|
|
59
|
+
const enabled = arr.find(p => p.enabled || p.has_key);
|
|
60
|
+
setProvider(prev => prev || enabled?.provider || enabled?.id || enabled?.name || null);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
showError(e?.message || 'Falha ao carregar providers de IA');
|
|
63
|
+
}
|
|
64
|
+
}, [companyQuery, showError]);
|
|
65
|
+
|
|
66
|
+
const loadTasks = useCallback(async () => {
|
|
67
|
+
setLoadingList(true);
|
|
68
|
+
try {
|
|
69
|
+
const params = {
|
|
70
|
+
type: 'ia',
|
|
71
|
+
order: {alterDate: 'desc'},
|
|
72
|
+
itemsPerPage: 50,
|
|
73
|
+
};
|
|
74
|
+
if (companyId) {
|
|
75
|
+
params.provider = `/people/${companyId}`;
|
|
76
|
+
}
|
|
77
|
+
const res = await api.fetch('/tasks', {params});
|
|
78
|
+
const items = res?.member || res?.['hydra:member'] || res || [];
|
|
79
|
+
setTasks(Array.isArray(items) ? items : []);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
showError(e?.message || 'Falha ao listar chats');
|
|
82
|
+
} finally {
|
|
83
|
+
setLoadingList(false);
|
|
84
|
+
}
|
|
85
|
+
}, [companyId, showError]);
|
|
86
|
+
|
|
87
|
+
const loadMessages = useCallback(
|
|
88
|
+
async taskId => {
|
|
89
|
+
if (!taskId) {
|
|
90
|
+
setMessages([]);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
setLoadingChat(true);
|
|
94
|
+
try {
|
|
95
|
+
const res = await api.fetch('/task_interations', {
|
|
96
|
+
params: {
|
|
97
|
+
'task.id': taskId,
|
|
98
|
+
type: 'comment',
|
|
99
|
+
order: {id: 'asc'},
|
|
100
|
+
itemsPerPage: 100,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
const items = res?.member || res?.['hydra:member'] || res || [];
|
|
104
|
+
setMessages(Array.isArray(items) ? items : []);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
showError(e?.message || 'Falha ao carregar mensagens');
|
|
107
|
+
} finally {
|
|
108
|
+
setLoadingChat(false);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
[showError],
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
loadProviders();
|
|
116
|
+
loadTasks();
|
|
117
|
+
}, [loadProviders, loadTasks]);
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
loadMessages(activeTaskId);
|
|
121
|
+
}, [activeTaskId, loadMessages]);
|
|
122
|
+
|
|
123
|
+
const selectTask = task => {
|
|
124
|
+
const id = task?.id || task?.['@id']?.split('/').pop();
|
|
125
|
+
setActiveTaskId(id ? Number(id) : null);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const startNewChat = () => {
|
|
129
|
+
setActiveTaskId(null);
|
|
130
|
+
setMessages([]);
|
|
131
|
+
setDraft('');
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const sendMessage = async () => {
|
|
135
|
+
const text = draft.trim();
|
|
136
|
+
if (!text || sending) return;
|
|
137
|
+
if (!provider) {
|
|
138
|
+
showError('Selecione um provider de IA configurado na empresa');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
setSending(true);
|
|
142
|
+
try {
|
|
143
|
+
const body = {
|
|
144
|
+
message: text,
|
|
145
|
+
provider,
|
|
146
|
+
...(activeTaskId ? {task_id: activeTaskId} : {}),
|
|
147
|
+
...(companyId ? {company_id: Number(companyId)} : {}),
|
|
148
|
+
};
|
|
149
|
+
const res = await api.post('/mcp/chat', body);
|
|
150
|
+
const newTaskId = res?.task?.id;
|
|
151
|
+
setDraft('');
|
|
152
|
+
if (newTaskId && newTaskId !== activeTaskId) {
|
|
153
|
+
setActiveTaskId(Number(newTaskId));
|
|
154
|
+
await loadTasks();
|
|
155
|
+
} else {
|
|
156
|
+
await loadMessages(activeTaskId || newTaskId);
|
|
157
|
+
}
|
|
158
|
+
if (res?.reply) {
|
|
159
|
+
// optimistic refresh
|
|
160
|
+
await loadMessages(newTaskId || activeTaskId);
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
showError(e?.message || e?.error || 'Falha ao enviar mensagem');
|
|
164
|
+
} finally {
|
|
165
|
+
setSending(false);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const activeTask = tasks.find(
|
|
170
|
+
t => String(t.id) === String(activeTaskId) || t['@id']?.endsWith(`/${activeTaskId}`),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const renderMessage = ({item}) => {
|
|
174
|
+
const body = item?.body || '';
|
|
175
|
+
const byId =
|
|
176
|
+
item?.registeredBy?.id ||
|
|
177
|
+
item?.registeredBy?.['@id']?.split('/').pop() ||
|
|
178
|
+
item?.registered_by_id;
|
|
179
|
+
const isUser = companyId && String(byId) !== String(companyId);
|
|
180
|
+
return (
|
|
181
|
+
<View style={[styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAi]}>
|
|
182
|
+
<Text style={styles.bubbleText}>{body}</Text>
|
|
183
|
+
</View>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return (
|
|
188
|
+
<KeyboardAvoidingView
|
|
189
|
+
style={styles.root}
|
|
190
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
191
|
+
keyboardVerticalOffset={80}>
|
|
192
|
+
<View style={styles.sidebar}>
|
|
193
|
+
<View style={styles.sidebarHeader}>
|
|
194
|
+
<Text style={styles.sidebarTitle}>Chats IA</Text>
|
|
195
|
+
<TouchableOpacity onPress={startNewChat} style={styles.newBtn}>
|
|
196
|
+
<Text style={styles.newBtnText}>Novo</Text>
|
|
197
|
+
</TouchableOpacity>
|
|
198
|
+
</View>
|
|
199
|
+
<ScrollView
|
|
200
|
+
horizontal
|
|
201
|
+
style={styles.providerRow}
|
|
202
|
+
contentContainerStyle={styles.providerRowContent}>
|
|
203
|
+
{(providers.length ? providers : Object.keys(PROVIDER_LABELS).map(k => ({provider: k, enabled: false}))).map(
|
|
204
|
+
p => {
|
|
205
|
+
const key = p.provider || p.id || p.name;
|
|
206
|
+
const selected = key === provider;
|
|
207
|
+
const disabled = p.enabled === false && !p.has_key;
|
|
208
|
+
return (
|
|
209
|
+
<TouchableOpacity
|
|
210
|
+
key={String(key)}
|
|
211
|
+
disabled={disabled}
|
|
212
|
+
onPress={() => setProvider(key)}
|
|
213
|
+
style={[
|
|
214
|
+
styles.providerChip,
|
|
215
|
+
selected && styles.providerChipActive,
|
|
216
|
+
disabled && styles.providerChipDisabled,
|
|
217
|
+
]}>
|
|
218
|
+
<Text
|
|
219
|
+
style={[
|
|
220
|
+
styles.providerChipText,
|
|
221
|
+
selected && styles.providerChipTextActive,
|
|
222
|
+
]}>
|
|
223
|
+
{PROVIDER_LABELS[key] || p.label || key}
|
|
224
|
+
</Text>
|
|
225
|
+
</TouchableOpacity>
|
|
226
|
+
);
|
|
227
|
+
},
|
|
228
|
+
)}
|
|
229
|
+
</ScrollView>
|
|
230
|
+
{loadingList ? (
|
|
231
|
+
<ActivityIndicator style={{marginTop: 16}} />
|
|
232
|
+
) : (
|
|
233
|
+
<FlatList
|
|
234
|
+
data={tasks}
|
|
235
|
+
keyExtractor={item => String(item.id || item['@id'])}
|
|
236
|
+
renderItem={({item}) => {
|
|
237
|
+
const id = item.id || item['@id']?.split('/').pop();
|
|
238
|
+
const selected = String(id) === String(activeTaskId);
|
|
239
|
+
return (
|
|
240
|
+
<TouchableOpacity
|
|
241
|
+
onPress={() => selectTask(item)}
|
|
242
|
+
style={[styles.taskRow, selected && styles.taskRowActive]}>
|
|
243
|
+
<Text numberOfLines={1} style={styles.taskNameText}>
|
|
244
|
+
{item.name || `Chat #${id}`}
|
|
245
|
+
</Text>
|
|
246
|
+
</TouchableOpacity>
|
|
247
|
+
);
|
|
248
|
+
}}
|
|
249
|
+
ListEmptyComponent={
|
|
250
|
+
<Text style={styles.emptyText}>Nenhum chat ainda. Envie uma mensagem.</Text>
|
|
251
|
+
}
|
|
252
|
+
/>
|
|
253
|
+
)}
|
|
254
|
+
</View>
|
|
255
|
+
|
|
256
|
+
<View style={styles.chatPane}>
|
|
257
|
+
<View style={styles.chatHeader}>
|
|
258
|
+
<Text style={styles.chatTitle}>
|
|
259
|
+
{activeTask?.name || (activeTaskId ? `Chat #${activeTaskId}` : 'Novo chat')}
|
|
260
|
+
</Text>
|
|
261
|
+
<Text style={styles.chatSubtitle}>
|
|
262
|
+
{PROVIDER_LABELS[provider] || provider || 'Selecione a IA'}
|
|
263
|
+
</Text>
|
|
264
|
+
</View>
|
|
265
|
+
{loadingChat ? (
|
|
266
|
+
<ActivityIndicator style={{marginTop: 24}} />
|
|
267
|
+
) : (
|
|
268
|
+
<FlatList
|
|
269
|
+
ref={listRef}
|
|
270
|
+
data={messages}
|
|
271
|
+
keyExtractor={item => String(item.id || item['@id'])}
|
|
272
|
+
renderItem={renderMessage}
|
|
273
|
+
contentContainerStyle={styles.messagesContent}
|
|
274
|
+
onContentSizeChange={() => listRef.current?.scrollToEnd?.({animated: true})}
|
|
275
|
+
ListEmptyComponent={
|
|
276
|
+
<Text style={styles.emptyText}>
|
|
277
|
+
Pergunte algo. A conversa vira uma Task type=ia.
|
|
278
|
+
</Text>
|
|
279
|
+
}
|
|
280
|
+
/>
|
|
281
|
+
)}
|
|
282
|
+
<View style={styles.composer}>
|
|
283
|
+
<TextInput
|
|
284
|
+
style={styles.input}
|
|
285
|
+
value={draft}
|
|
286
|
+
onChangeText={setDraft}
|
|
287
|
+
placeholder="Mensagem para a IA…"
|
|
288
|
+
multiline
|
|
289
|
+
editable={!sending}
|
|
290
|
+
/>
|
|
291
|
+
<TouchableOpacity
|
|
292
|
+
style={[styles.sendBtn, (!draft.trim() || sending) && styles.sendBtnDisabled]}
|
|
293
|
+
disabled={!draft.trim() || sending}
|
|
294
|
+
onPress={sendMessage}>
|
|
295
|
+
<Text style={styles.sendBtnText}>{sending ? '…' : 'Enviar'}</Text>
|
|
296
|
+
</TouchableOpacity>
|
|
297
|
+
</View>
|
|
298
|
+
</View>
|
|
299
|
+
</KeyboardAvoidingView>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default StyleSheet.create({
|
|
4
|
+
root: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
flexDirection: 'row',
|
|
7
|
+
backgroundColor: '#0f1419',
|
|
8
|
+
minHeight: 0,
|
|
9
|
+
},
|
|
10
|
+
sidebar: {
|
|
11
|
+
width: 280,
|
|
12
|
+
maxWidth: '35%',
|
|
13
|
+
borderRightWidth: 1,
|
|
14
|
+
borderRightColor: '#2a3441',
|
|
15
|
+
backgroundColor: '#15202b',
|
|
16
|
+
},
|
|
17
|
+
sidebarHeader: {
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
paddingHorizontal: 12,
|
|
22
|
+
paddingVertical: 12,
|
|
23
|
+
},
|
|
24
|
+
sidebarTitle: {
|
|
25
|
+
color: '#e7e9ea',
|
|
26
|
+
fontSize: 16,
|
|
27
|
+
fontWeight: '700',
|
|
28
|
+
},
|
|
29
|
+
newBtn: {
|
|
30
|
+
backgroundColor: '#1d9bf0',
|
|
31
|
+
paddingHorizontal: 10,
|
|
32
|
+
paddingVertical: 6,
|
|
33
|
+
borderRadius: 8,
|
|
34
|
+
},
|
|
35
|
+
newBtnText: {color: '#fff', fontWeight: '600', fontSize: 13},
|
|
36
|
+
providerRow: {maxHeight: 44, marginBottom: 4},
|
|
37
|
+
providerRowContent: {paddingHorizontal: 8, gap: 6, alignItems: 'center'},
|
|
38
|
+
providerChip: {
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: '#38444d',
|
|
41
|
+
borderRadius: 16,
|
|
42
|
+
paddingHorizontal: 10,
|
|
43
|
+
paddingVertical: 6,
|
|
44
|
+
marginRight: 6,
|
|
45
|
+
},
|
|
46
|
+
providerChipActive: {
|
|
47
|
+
backgroundColor: '#1d9bf0',
|
|
48
|
+
borderColor: '#1d9bf0',
|
|
49
|
+
},
|
|
50
|
+
providerChipDisabled: {opacity: 0.4},
|
|
51
|
+
providerChipText: {color: '#8b98a5', fontSize: 12},
|
|
52
|
+
providerChipTextActive: {color: '#fff'},
|
|
53
|
+
taskRow: {
|
|
54
|
+
paddingHorizontal: 12,
|
|
55
|
+
paddingVertical: 10,
|
|
56
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
57
|
+
borderBottomColor: '#2a3441',
|
|
58
|
+
},
|
|
59
|
+
taskRowActive: {backgroundColor: '#1e2732'},
|
|
60
|
+
taskRowText: {color: '#e7e9ea', fontSize: 13},
|
|
61
|
+
emptyText: {color: '#8b98a5', padding: 16, fontSize: 13},
|
|
62
|
+
chatPane: {flex: 1, minWidth: 0},
|
|
63
|
+
chatHeader: {
|
|
64
|
+
paddingHorizontal: 16,
|
|
65
|
+
paddingVertical: 12,
|
|
66
|
+
borderBottomWidth: 1,
|
|
67
|
+
borderBottomColor: '#2a3441',
|
|
68
|
+
},
|
|
69
|
+
chatTitle: {color: '#e7e9ea', fontSize: 16, fontWeight: '600'},
|
|
70
|
+
chatSubtitle: {color: '#8b98a5', fontSize: 12, marginTop: 2},
|
|
71
|
+
messagesContent: {padding: 12, paddingBottom: 24},
|
|
72
|
+
bubble: {
|
|
73
|
+
maxWidth: '85%',
|
|
74
|
+
borderRadius: 12,
|
|
75
|
+
paddingHorizontal: 12,
|
|
76
|
+
paddingVertical: 8,
|
|
77
|
+
marginVertical: 4,
|
|
78
|
+
},
|
|
79
|
+
bubbleUser: {
|
|
80
|
+
alignSelf: 'flex-end',
|
|
81
|
+
backgroundColor: '#1d9bf0',
|
|
82
|
+
},
|
|
83
|
+
bubbleAi: {
|
|
84
|
+
alignSelf: 'flex-start',
|
|
85
|
+
backgroundColor: '#212a33',
|
|
86
|
+
},
|
|
87
|
+
bubbleText: {color: '#e7e9ea', fontSize: 14, lineHeight: 20},
|
|
88
|
+
composer: {
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
alignItems: 'flex-end',
|
|
91
|
+
padding: 10,
|
|
92
|
+
borderTopWidth: 1,
|
|
93
|
+
borderTopColor: '#2a3441',
|
|
94
|
+
gap: 8,
|
|
95
|
+
},
|
|
96
|
+
input: {
|
|
97
|
+
flex: 1,
|
|
98
|
+
minHeight: 40,
|
|
99
|
+
maxHeight: 120,
|
|
100
|
+
borderWidth: 1,
|
|
101
|
+
borderColor: '#38444d',
|
|
102
|
+
borderRadius: 12,
|
|
103
|
+
paddingHorizontal: 12,
|
|
104
|
+
paddingVertical: 8,
|
|
105
|
+
color: '#e7e9ea',
|
|
106
|
+
backgroundColor: '#15202b',
|
|
107
|
+
},
|
|
108
|
+
sendBtn: {
|
|
109
|
+
backgroundColor: '#1d9bf0',
|
|
110
|
+
borderRadius: 12,
|
|
111
|
+
paddingHorizontal: 14,
|
|
112
|
+
paddingVertical: 10,
|
|
113
|
+
},
|
|
114
|
+
sendBtnDisabled: {opacity: 0.5},
|
|
115
|
+
sendBtnText: {color: '#fff', fontWeight: '700'},
|
|
116
|
+
});
|
|
@@ -106,7 +106,6 @@ const CreateProposalsModal = ({ visible, onClose, onSuccess }) => {
|
|
|
106
106
|
const results = await searchCompanyProducts({
|
|
107
107
|
companyId: currentCompany.id,
|
|
108
108
|
query: productQuery,
|
|
109
|
-
categoryId: selectedModelCategoryId,
|
|
110
109
|
});
|
|
111
110
|
|
|
112
111
|
const filteredResults = filterProductsByModelCategory({
|
|
@@ -7,16 +7,22 @@ import Icon from 'react-native-vector-icons/FontAwesome';
|
|
|
7
7
|
import IconAdd from 'react-native-vector-icons/MaterialIcons';
|
|
8
8
|
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
|
9
9
|
import CreateProposalsModal from './CreateProposalsModal';
|
|
10
|
+
import ProposalCard from './ProposalCard';
|
|
11
|
+
import {
|
|
12
|
+
normalizeDigits,
|
|
13
|
+
normalizeStatusKey,
|
|
14
|
+
getStatusColor,
|
|
15
|
+
getStatusLabel,
|
|
16
|
+
extractPeopleId,
|
|
17
|
+
resolvePeopleName,
|
|
18
|
+
getContractPartyCandidates,
|
|
19
|
+
isIgnoredContractPartyId,
|
|
20
|
+
getResolvedPeopleName,
|
|
21
|
+
getContractClientName as resolveContractClientName,
|
|
22
|
+
isContractClientPendingResolution as resolveContractClientPending,
|
|
23
|
+
} from './proposalListHelpers';
|
|
10
24
|
import Formatter from '@controleonline/ui-common/src/utils/formatter';
|
|
11
25
|
import { getPeopleDisplayName } from '@controleonline/ui-common/src/react/utils/peopleDisplay';
|
|
12
|
-
import {
|
|
13
|
-
normalizeProposalStatusKey,
|
|
14
|
-
getProposalStatusColor,
|
|
15
|
-
getProposalStatusLabel,
|
|
16
|
-
getProposalStatusFilterKey,
|
|
17
|
-
buildProposalStatusFilterOptions,
|
|
18
|
-
proposalMatchesStatusFilter,
|
|
19
|
-
} from '../../utils/proposalStatus';
|
|
20
26
|
import styles from './index.styles';
|
|
21
27
|
import { inlineStyle_669_129 } from './index.styles';
|
|
22
28
|
|
|
@@ -192,14 +198,27 @@ const ProposalsPage = () => {
|
|
|
192
198
|
setRefreshing(false);
|
|
193
199
|
}, [fetchContracts, searchQuery]);
|
|
194
200
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const getStatusLabel = status => getProposalStatusLabel(status, global.t?.t);
|
|
201
|
+
|
|
202
|
+
|
|
198
203
|
const getStatusFilterKey = useCallback(
|
|
199
|
-
item =>
|
|
200
|
-
|
|
201
|
-
|
|
204
|
+
item => {
|
|
205
|
+
if (!item) {
|
|
206
|
+
return '';
|
|
207
|
+
}
|
|
202
208
|
|
|
209
|
+
if (item['@id']) {
|
|
210
|
+
return item['@id'];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (item.id != null) {
|
|
214
|
+
return `/statuses/${item.id}`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const normalized = normalizeStatusKey(item.realStatus || item.status);
|
|
218
|
+
return normalized ? `realStatus:${normalized}` : '';
|
|
219
|
+
},
|
|
220
|
+
[normalizeStatusKey],
|
|
221
|
+
);
|
|
203
222
|
|
|
204
223
|
const statusFilterOptions = React.useMemo(
|
|
205
224
|
() => {
|
|
@@ -29,6 +29,7 @@ import CrmSection from './sections/CrmSection';
|
|
|
29
29
|
import LoyaltySection from './sections/LoyaltySection';
|
|
30
30
|
import MapsSection from './sections/MapsSection';
|
|
31
31
|
import ShopSettingsSection from './sections/shop/ShopSettingsSection';
|
|
32
|
+
import AiProvidersSection from './sections/AiProvidersSection';
|
|
32
33
|
import IntegrationsSection from './sections/IntegrationsSection';
|
|
33
34
|
import LogSection from './sections/LogSection';
|
|
34
35
|
import MaintenanceSection from './sections/MaintenanceSection';
|
|
@@ -51,6 +52,13 @@ const SETTINGS_TABS = [
|
|
|
51
52
|
stores: ['configs', 'people'],
|
|
52
53
|
Component: IntegrationsSection,
|
|
53
54
|
},
|
|
55
|
+
{
|
|
56
|
+
key: 'ai-providers',
|
|
57
|
+
label: 'IA / MCP',
|
|
58
|
+
icon: 'smart-toy',
|
|
59
|
+
stores: ['configs', 'people'],
|
|
60
|
+
Component: AiProvidersSection,
|
|
61
|
+
},
|
|
54
62
|
{
|
|
55
63
|
key: 'logs',
|
|
56
64
|
label: 'Logs',
|
|
@@ -136,8 +144,8 @@ const GeneralSettings = () => {
|
|
|
136
144
|
const {
|
|
137
145
|
companies,
|
|
138
146
|
currentCompany,
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
defaultCompany,
|
|
148
|
+
hasDefaultCompanyAccess,
|
|
141
149
|
isMainCompanySelected,
|
|
142
150
|
peopleActions,
|
|
143
151
|
} =
|
|
@@ -157,9 +165,9 @@ const GeneralSettings = () => {
|
|
|
157
165
|
SETTINGS_TABS.filter(
|
|
158
166
|
tab =>
|
|
159
167
|
(!MAIN_COMPANY_ONLY_TABS.has(tab.key) || isMainCompanySelected) &&
|
|
160
|
-
(!TECHNICAL_TABS.has(tab.key) ||
|
|
168
|
+
(!TECHNICAL_TABS.has(tab.key) || hasDefaultCompanyAccess),
|
|
161
169
|
),
|
|
162
|
-
[
|
|
170
|
+
[hasDefaultCompanyAccess, isMainCompanySelected],
|
|
163
171
|
);
|
|
164
172
|
|
|
165
173
|
useFocusEffect(
|
|
@@ -176,10 +184,10 @@ const GeneralSettings = () => {
|
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
|
|
179
|
-
if (!
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
requests.push(
|
|
187
|
+
if (!defaultCompany?.id) {
|
|
188
|
+
const defaultCompanyRequest = peopleActions.defaultCompany?.();
|
|
189
|
+
if (defaultCompanyRequest?.then) {
|
|
190
|
+
requests.push(defaultCompanyRequest.catch(() => {}));
|
|
183
191
|
}
|
|
184
192
|
}
|
|
185
193
|
|
|
@@ -196,7 +204,7 @@ const GeneralSettings = () => {
|
|
|
196
204
|
return () => {
|
|
197
205
|
cancelled = true;
|
|
198
206
|
};
|
|
199
|
-
}, [companies,
|
|
207
|
+
}, [companies, defaultCompany?.id, peopleActions]),
|
|
200
208
|
);
|
|
201
209
|
|
|
202
210
|
/*
|
|
@@ -204,7 +204,7 @@ const isMethodNotAllowedError = error => {
|
|
|
204
204
|
|
|
205
205
|
export const useGeneralSettingsConfig = () => {
|
|
206
206
|
const peopleStore = useStore('people');
|
|
207
|
-
const {companies, currentCompany,
|
|
207
|
+
const {companies, currentCompany, defaultCompany} = peopleStore.getters;
|
|
208
208
|
const peopleActions = peopleStore.actions;
|
|
209
209
|
|
|
210
210
|
const configsStore = useStore('configs');
|
|
@@ -228,26 +228,26 @@ export const useGeneralSettingsConfig = () => {
|
|
|
228
228
|
() => normalizeEntityId(currentCompany?.id || currentCompany?.['@id']),
|
|
229
229
|
[currentCompany?.['@id'], currentCompany?.id],
|
|
230
230
|
);
|
|
231
|
-
const
|
|
232
|
-
() => normalizeEntityId(
|
|
233
|
-
[
|
|
231
|
+
const defaultCompanyId = useMemo(
|
|
232
|
+
() => normalizeEntityId(defaultCompany?.id || defaultCompany?.['@id']),
|
|
233
|
+
[defaultCompany?.['@id'], defaultCompany?.id],
|
|
234
234
|
);
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
235
|
+
const hasDefaultCompanyAccess = useMemo(() => {
|
|
236
|
+
if (defaultCompanyId === '') {
|
|
237
237
|
return false;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
return (Array.isArray(companies) ? companies : []).some(
|
|
241
241
|
company =>
|
|
242
|
-
normalizeEntityId(company?.id || company?.['@id']) ===
|
|
242
|
+
normalizeEntityId(company?.id || company?.['@id']) === defaultCompanyId,
|
|
243
243
|
);
|
|
244
|
-
}, [companies,
|
|
244
|
+
}, [companies, defaultCompanyId]);
|
|
245
245
|
const isMainCompanySelected =
|
|
246
246
|
selectedCompanyId !== '' &&
|
|
247
|
-
|
|
248
|
-
selectedCompanyId ===
|
|
249
|
-
const
|
|
250
|
-
|
|
247
|
+
defaultCompanyId !== '' &&
|
|
248
|
+
selectedCompanyId === defaultCompanyId;
|
|
249
|
+
const defaultCompanyLabel =
|
|
250
|
+
defaultCompany?.alias || defaultCompany?.name || 'empresa principal';
|
|
251
251
|
|
|
252
252
|
const syncConfigCache = useCallback(
|
|
253
253
|
entries => {
|
|
@@ -366,9 +366,9 @@ export const useGeneralSettingsConfig = () => {
|
|
|
366
366
|
[configActions, currentCompany?.id, syncConfigCache],
|
|
367
367
|
);
|
|
368
368
|
|
|
369
|
-
const
|
|
369
|
+
const saveDefaultCompanyConfigs = useCallback(
|
|
370
370
|
entries => {
|
|
371
|
-
if (!
|
|
371
|
+
if (!defaultCompanyId) {
|
|
372
372
|
Alert.alert(
|
|
373
373
|
'Empresa principal nao selecionada',
|
|
374
374
|
'Selecione uma empresa principal para salvar as configuracoes.',
|
|
@@ -412,7 +412,7 @@ export const useGeneralSettingsConfig = () => {
|
|
|
412
412
|
try {
|
|
413
413
|
const data = await configActions.addManyConfigs({
|
|
414
414
|
configs: requestConfigItems,
|
|
415
|
-
people: '/people/' +
|
|
415
|
+
people: '/people/' + defaultCompanyId,
|
|
416
416
|
module: 4,
|
|
417
417
|
visibility: 'public',
|
|
418
418
|
});
|
|
@@ -429,7 +429,7 @@ export const useGeneralSettingsConfig = () => {
|
|
|
429
429
|
configActions.initQueue();
|
|
430
430
|
});
|
|
431
431
|
},
|
|
432
|
-
[configActions,
|
|
432
|
+
[configActions, defaultCompanyId, syncConfigCache],
|
|
433
433
|
);
|
|
434
434
|
|
|
435
435
|
const saveConfig = useCallback(
|
|
@@ -476,15 +476,15 @@ export const useGeneralSettingsConfig = () => {
|
|
|
476
476
|
companies,
|
|
477
477
|
configActions,
|
|
478
478
|
currentCompany,
|
|
479
|
-
|
|
480
|
-
|
|
479
|
+
defaultCompany,
|
|
480
|
+
defaultCompanyLabel,
|
|
481
481
|
effectiveCompanyConfigs,
|
|
482
|
-
|
|
482
|
+
hasDefaultCompanyAccess,
|
|
483
483
|
isMainCompanySelected,
|
|
484
484
|
isSaving,
|
|
485
485
|
peopleActions,
|
|
486
486
|
saveConfig,
|
|
487
487
|
saveConfigs,
|
|
488
|
-
|
|
488
|
+
saveDefaultCompanyConfigs,
|
|
489
489
|
};
|
|
490
490
|
};
|
|
@@ -393,8 +393,6 @@ export const createGeneralSettingsStyles = palette =>
|
|
|
393
393
|
primaryButton: {
|
|
394
394
|
marginTop: 16,
|
|
395
395
|
justifyContent: 'center',
|
|
396
|
-
backgroundColor: palette.buttonBackground,
|
|
397
|
-
borderColor: palette.buttonBorder,
|
|
398
396
|
},
|
|
399
397
|
secondaryButton: {
|
|
400
398
|
marginTop: 10,
|