@controleonline/ui-crm 1.0.62 → 1.0.65

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.61",
2
+ "version": "1.0.64",
3
3
  "rc": 1,
4
- "branch": "rc/1.0.61-rc.1",
5
- "baseMaster": "f74060050bf143d4436051cd70d688618bd01dc5",
4
+ "branch": "rc/1.0.64-rc.1",
5
+ "baseMaster": "98a8048b0e9eeac415f323f70177a10ff5b5d1ac",
6
6
  "tasks": [
7
- 1335
7
+ 64,
8
+ 1447
8
9
  ],
9
10
  "frozen": true,
10
11
  "repositories": {
11
- "ControleOnline/ui-crm": "54cacf3c5bc086cbd32a13b8b14b889df261e729"
12
+ "ControleOnline/ui-crm": "7fe6fca7d6f8d4500e2833af7449c5257bab9480"
12
13
  }
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-crm",
3
- "version": "1.0.62",
3
+ "version": "1.0.65",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline CRM Quasar UI Component",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@ const CrmHeader = ({
12
12
  getStatusFilterKey,
13
13
  getStatusFilterLabel,
14
14
  onAddOpportunity,
15
+ onOpenFunnel,
15
16
  searchText,
16
17
  selectedStatusFilterKey,
17
18
  setSearchText,
@@ -39,6 +40,11 @@ const CrmHeader = ({
39
40
  </TouchableOpacity>
40
41
  )}
41
42
  </View>
43
+ {onOpenFunnel ? (
44
+ <TouchableOpacity style={styles.addButton} onPress={onOpenFunnel} accessibilityLabel="Funil">
45
+ <Icon name="columns" size={18} color="#FFFFFF" />
46
+ </TouchableOpacity>
47
+ ) : null}
42
48
  <TouchableOpacity style={styles.addButton} onPress={onAddOpportunity}>
43
49
  <IconAdd name="add" size={24} color="#FFFFFF" />
44
50
  </TouchableOpacity>
@@ -85,6 +85,7 @@ export default function CrmIndex() {
85
85
  getStatusFilterKey={data.getStatusFilterKey}
86
86
  getStatusFilterLabel={data.getStatusFilterLabel}
87
87
  onAddOpportunity={forms.openAddOpportunity}
88
+ onOpenFunnel={() => navigation.navigate('CrmFunnel')}
88
89
  searchText={data.searchText}
89
90
  selectedStatusFilterKey={data.selectedStatusFilterKey}
90
91
  setSearchText={data.setSearchText}
@@ -1,7 +1,8 @@
1
1
  /*
2
- * @agents MCP AI chat (Task type=ia). Keep under 500 lines; API via /mcp/chat*.
2
+ * @agents /ai: employee chats with the company AI (internal data via MCP) and follows the customer
3
+ * conversations the AI is handling now. Employees answer customers in CRM / Support. Logic: useMcpChat.
3
4
  */
4
- import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
5
+ import React, {useMemo, useRef, useState} from 'react';
5
6
  import {
6
7
  ActivityIndicator,
7
8
  FlatList,
@@ -13,351 +14,172 @@ import {
13
14
  TouchableOpacity,
14
15
  View,
15
16
  } from 'react-native';
16
- import {useStore} from '@store';
17
- import {api} from '@controleonline/ui-common/src/api';
18
- import useToastMessage from '../../hooks/useToastMessage';
17
+ import useMcpChat from './useMcpChat';
19
18
  import styles from './McpPage.styles';
20
19
 
21
- const PROVIDER_LABELS = {
22
- grok: 'Grok',
23
- openai: 'Codex / OpenAI',
24
- gemini: 'Gemini',
25
- claude: 'Claude',
20
+ const {idOf, isCustomerConversation, conversationChannel, stageLabel, messageRole} = require('./mcpChatUtils');
21
+
22
+ const PROVIDER_LABELS = {grok: 'Grok', openai: 'Codex / OpenAI', gemini: 'Gemini', claude: 'Claude'};
23
+ const CHANNEL_LABELS = {whatsapp: 'WhatsApp', email: 'E-mail', web: 'Site', ai: 'IA'};
24
+ const ROLE_LABELS = {ai: 'IA', note: 'Nota interna', customer: 'Cliente', staff: 'Equipe', me: null};
25
+
26
+ const TaskRow = ({item, selected, onPress}) => {
27
+ const customer = isCustomerConversation(item);
28
+ return (
29
+ <TouchableOpacity onPress={onPress} style={[styles.taskRow, selected && styles.taskRowActive]}>
30
+ <Text numberOfLines={1} style={styles.taskRowText}>
31
+ {item.name || `Conversa #${idOf(item)}`}
32
+ </Text>
33
+ {customer ? (
34
+ <Text style={styles.taskRowMeta}>
35
+ {CHANNEL_LABELS[conversationChannel(item)]} · {stageLabel(item)}
36
+ </Text>
37
+ ) : null}
38
+ </TouchableOpacity>
39
+ );
26
40
  };
27
41
 
28
42
  export default function McpPage() {
29
- const {showError, showSuccess} = useToastMessage();
30
- const peopleStore = useStore('people');
31
- const websocketStore = useStore('websocket');
32
- const wsMessages = websocketStore?.getters?.messages || [];
33
- const company =
34
- peopleStore?.getters?.currentCompany ||
35
- peopleStore?.getters?.mainCompany ||
36
- null;
37
- const companyId = company?.id || company?.['@id']?.split('/').pop() || null;
38
-
39
- const [providers, setProviders] = useState([]);
40
- const [provider, setProvider] = useState(null);
41
- const [tasks, setTasks] = useState([]);
42
- const [activeTaskId, setActiveTaskId] = useState(null);
43
- const [messages, setMessages] = useState([]);
43
+ const chat = useMcpChat();
44
44
  const [draft, setDraft] = useState('');
45
- const [loadingList, setLoadingList] = useState(true);
46
- const [loadingChat, setLoadingChat] = useState(false);
47
- const [sending, setSending] = useState(false);
48
45
  const listRef = useRef(null);
49
- const pendingByTaskRef = useRef({}); // taskId -> userInteractionId
50
- const handledWsRef = useRef(new Set());
51
-
52
- const companyQuery = useMemo(
53
- () => (companyId ? {company_id: Number(companyId)} : {}),
54
- [companyId],
55
- );
56
-
57
- const loadProviders = useCallback(async () => {
58
- try {
59
- const res = await api.fetch('/mcp/chat/providers', {params: companyQuery});
60
- const list = res?.providers || res?.member || res || [];
61
- const arr = Array.isArray(list) ? list : [];
62
- setProviders(arr);
63
- const enabled = arr.find(p => p.enabled || p.has_key);
64
- setProvider(prev => prev || enabled?.provider || enabled?.id || enabled?.name || null);
65
- } catch (e) {
66
- showError(e?.message || 'Falha ao carregar providers de IA');
67
- }
68
- }, [companyQuery, showError]);
69
-
70
- const loadTasks = useCallback(async () => {
71
- setLoadingList(true);
72
- try {
73
- const params = {
74
- type: 'ia',
75
- order: {alterDate: 'desc'},
76
- itemsPerPage: 50,
77
- };
78
- if (companyId) {
79
- params.provider = `/people/${companyId}`;
80
- }
81
- const res = await api.fetch('/tasks', {params});
82
- const items = res?.member || res?.['hydra:member'] || res || [];
83
- setTasks(Array.isArray(items) ? items : []);
84
- } catch (e) {
85
- showError(e?.message || 'Falha ao listar chats');
86
- } finally {
87
- setLoadingList(false);
88
- }
89
- }, [companyId, showError]);
90
46
 
91
- const loadMessages = useCallback(
92
- async taskId => {
93
- if (!taskId) {
94
- setMessages([]);
95
- return;
96
- }
97
- setLoadingChat(true);
98
- try {
99
- const res = await api.fetch('/task_interations', {
100
- params: {
101
- 'task.id': taskId,
102
- type: 'comment',
103
- order: {id: 'asc'},
104
- itemsPerPage: 100,
105
- },
106
- });
107
- const items = res?.member || res?.['hydra:member'] || res || [];
108
- setMessages(Array.isArray(items) ? items : []);
109
- } catch (e) {
110
- showError(e?.message || 'Falha ao carregar mensagens');
111
- } finally {
112
- setLoadingChat(false);
113
- }
114
- },
115
- [showError],
116
- );
117
-
118
- useEffect(() => {
119
- loadProviders();
120
- loadTasks();
121
- }, [loadProviders, loadTasks]);
122
-
123
- useEffect(() => {
124
- loadMessages(activeTaskId);
125
- }, [activeTaskId, loadMessages]);
126
-
127
- const selectTask = task => {
128
- const id = task?.id || task?.['@id']?.split('/').pop();
129
- setActiveTaskId(id ? Number(id) : null);
130
- };
131
-
132
- const startNewChat = () => {
133
- setActiveTaskId(null);
134
- setMessages([]);
47
+ const [internal, tickets, customers] = useMemo(() => {
48
+ const mine = t => idOf(t.client) === Number(chat.currentPeopleId);
49
+ return [
50
+ chat.tasks.filter(t => !isCustomerConversation(t)),
51
+ chat.tasks.filter(t => isCustomerConversation(t) && mine(t)),
52
+ chat.tasks.filter(t => isCustomerConversation(t) && !mine(t)),
53
+ ];
54
+ }, [chat.tasks, chat.currentPeopleId]);
55
+ const noAi = chat.providers.length === 0;
56
+ const ticketComposer = chat.myTicket || (!chat.activeTaskId && noAi);
57
+
58
+ const submit = async () => {
59
+ const text = draft;
135
60
  setDraft('');
61
+ const ok = await chat.sendMessage(text);
62
+ if (!ok) setDraft(text);
136
63
  };
137
64
 
138
- // Realtime: apply mcp_chat_reply from websocket store (no HTTP poll)
139
- useEffect(() => {
140
- if (!Array.isArray(wsMessages) || wsMessages.length === 0) {
141
- return;
142
- }
143
- const latest = wsMessages[wsMessages.length - 1];
144
- const candidates = Array.isArray(latest) ? latest : [latest];
145
- candidates.forEach(evt => {
146
- if (!evt || typeof evt !== 'object') {
147
- return;
148
- }
149
- const eventName = String(evt.event || evt.action || '');
150
- if (eventName !== 'mcp_chat_reply') {
151
- return;
152
- }
153
- const taskId = Number(evt.task_id || evt.taskId || 0);
154
- const interactionId = Number(evt.interaction_id || evt.interactionId || 0);
155
- const key = `${taskId}:${interactionId}:${evt.status || ''}:${String(evt.body || '').slice(0, 40)}`;
156
- if (handledWsRef.current.has(key)) {
157
- return;
158
- }
159
- handledWsRef.current.add(key);
160
-
161
- if (taskId && Number(activeTaskId) === taskId) {
162
- // Refresh only the open chat once when reply arrives
163
- loadMessages(taskId);
164
- } else if (taskId && !activeTaskId) {
165
- setActiveTaskId(taskId);
166
- }
167
- if (taskId) {
168
- delete pendingByTaskRef.current[taskId];
169
- loadTasks();
170
- }
171
- if (String(evt.status || '') === 'error') {
172
- showError(evt.body || 'A IA retornou erro ao processar a mensagem');
173
- }
174
- setSending(false);
175
- });
176
- }, [wsMessages, activeTaskId, loadMessages, loadTasks, showError]);
177
-
178
- const sendMessage = async () => {
179
- const text = draft.trim();
180
- if (!text || sending) return;
181
- if (!provider) {
182
- showError('Selecione um provider de IA configurado na empresa');
183
- return;
184
- }
185
- setSending(true);
186
- try {
187
- const body = {
188
- message: text,
189
- provider,
190
- ...(activeTaskId ? {task_id: activeTaskId} : {}),
191
- ...(companyId ? {company_id: Number(companyId)} : {}),
192
- };
193
- // Optimistic local bubble while queue processes
194
- setMessages(prev => [
195
- ...prev,
196
- {
197
- id: `local-${Date.now()}`,
198
- body: text,
199
- status: 'pending',
200
- registeredBy: {id: companyId ? Number(companyId) + 1 : 0},
201
- },
202
- ]);
203
- setDraft('');
204
- const res = await api.post('/mcp/chat', body);
205
- const newTaskId = res?.task_id || res?.task?.id;
206
- const interactionId = res?.interaction_id;
207
- if (newTaskId) {
208
- pendingByTaskRef.current[Number(newTaskId)] = interactionId;
209
- if (Number(newTaskId) !== Number(activeTaskId)) {
210
- setActiveTaskId(Number(newTaskId));
211
- loadTasks();
212
- }
213
- // Single reload after persist (user message on server) — no poll loop
214
- await loadMessages(Number(newTaskId));
215
- }
216
- // sending stays true until websocket reply (or error toast)
217
- if (!(res?.async || res?.status === 'pending')) {
218
- setSending(false);
219
- if (res?.message) {
220
- await loadMessages(newTaskId || activeTaskId);
221
- }
222
- }
223
- } catch (e) {
224
- showError(e?.message || e?.error || 'Falha ao enviar mensagem');
225
- setSending(false);
226
- }
227
- };
228
-
229
- const activeTask = tasks.find(
230
- t => String(t.id) === String(activeTaskId) || t['@id']?.endsWith(`/${activeTaskId}`),
231
- );
232
-
233
65
  const renderMessage = ({item}) => {
234
- const body = item?.body || '';
235
- const byId =
236
- item?.registeredBy?.id ||
237
- item?.registeredBy?.['@id']?.split('/').pop() ||
238
- item?.registered_by_id;
239
- const isUser = companyId && String(byId) !== String(companyId);
66
+ const role = messageRole(item, {companyId: chat.companyId, task: chat.activeTask, currentPeopleId: chat.currentPeopleId});
67
+ const right = role === 'me' || role === 'staff';
240
68
  return (
241
- <View style={[styles.bubble, isUser ? styles.bubbleUser : styles.bubbleAi]}>
242
- <Text style={styles.bubbleText}>{body}</Text>
243
- {item?.status && item.status !== 'done' ? (
244
- <Text style={styles.bubbleMeta}>{String(item.status)}</Text>
245
- ) : null}
69
+ <View style={[styles.bubble, right ? styles.bubbleUser : styles.bubbleAi, role === 'note' && styles.bubbleNote, role === 'customer' && styles.bubbleCustomer]}>
70
+ {ROLE_LABELS[role] ? <Text style={styles.bubbleAuthor}>{ROLE_LABELS[role]}</Text> : null}
71
+ <Text style={styles.bubbleText}>{item?.body || ''}</Text>
72
+ {item?.status && !['done', 'pending'].includes(item.status) ? <Text style={styles.bubbleMeta}>{String(item.status)}</Text> : null}
246
73
  </View>
247
74
  );
248
75
  };
249
76
 
77
+ const typing = chat.aiStatus ? (
78
+ <View style={[styles.bubble, styles.bubbleAi]}>
79
+ <Text style={styles.bubbleMeta}>{chat.aiStatus === 'processing' ? 'IA consultando os dados…' : 'Enviado, aguardando a IA…'}</Text>
80
+ </View>
81
+ ) : null;
82
+
83
+ const renderSection = (title, items, empty) => (
84
+ <View>
85
+ <Text style={styles.sectionTitle}>{title}</Text>
86
+ {items.length === 0 ? <Text style={styles.emptyText}>{empty}</Text> : null}
87
+ {items.map(item => (
88
+ <TaskRow key={String(idOf(item))} item={item} selected={idOf(item) === Number(chat.activeTaskId)} onPress={() => chat.setActiveTaskId(idOf(item))} />
89
+ ))}
90
+ </View>
91
+ );
92
+
93
+ const task = chat.activeTask;
250
94
  return (
251
- <KeyboardAvoidingView
252
- style={styles.root}
253
- behavior={Platform.OS === 'ios' ? 'padding' : undefined}
254
- keyboardVerticalOffset={80}>
95
+ <KeyboardAvoidingView style={styles.root} behavior={Platform.OS === 'ios' ? 'padding' : undefined} keyboardVerticalOffset={80}>
255
96
  <View style={styles.sidebar}>
256
97
  <View style={styles.sidebarHeader}>
257
- <Text style={styles.sidebarTitle}>Chats IA</Text>
258
- <TouchableOpacity onPress={startNewChat} style={styles.newBtn}>
259
- <Text style={styles.newBtnText}>Novo</Text>
98
+ <Text style={styles.sidebarTitle}>IA</Text>
99
+ <TouchableOpacity onPress={chat.startNewChat} style={styles.newBtn}>
100
+ <Text style={styles.newBtnText}>Novo chat</Text>
260
101
  </TouchableOpacity>
261
102
  </View>
262
- <ScrollView
263
- horizontal
264
- style={styles.providerRow}
265
- contentContainerStyle={styles.providerRowContent}>
266
- {(providers.length ? providers : Object.keys(PROVIDER_LABELS).map(k => ({provider: k, enabled: false}))).map(
267
- p => {
268
- const key = p.provider || p.id || p.name;
269
- const selected = key === provider;
270
- const disabled = p.enabled === false && !p.has_key;
271
- return (
272
- <TouchableOpacity
273
- key={String(key)}
274
- disabled={disabled}
275
- onPress={() => setProvider(key)}
276
- style={[
277
- styles.providerChip,
278
- selected && styles.providerChipActive,
279
- disabled && styles.providerChipDisabled,
280
- ]}>
281
- <Text
282
- style={[
283
- styles.providerChipText,
284
- selected && styles.providerChipTextActive,
285
- ]}>
286
- {PROVIDER_LABELS[key] || p.label || key}
287
- </Text>
288
- </TouchableOpacity>
289
- );
290
- },
291
- )}
103
+ <ScrollView horizontal style={styles.providerRow} contentContainerStyle={styles.providerRowContent}>
104
+ {noAi ? <Text style={styles.emptyText}>Sem IA própria: suas mensagens abrem um chamado.</Text> : null}
105
+ {chat.providers.map(p => (
106
+ <TouchableOpacity key={p.provider} onPress={() => chat.setProvider(p.provider)} style={[styles.providerChip, p.provider === chat.provider && styles.providerChipActive]}>
107
+ <Text style={[styles.providerChipText, p.provider === chat.provider && styles.providerChipTextActive]}>
108
+ {PROVIDER_LABELS[p.provider] || p.label || p.provider}
109
+ </Text>
110
+ </TouchableOpacity>
111
+ ))}
292
112
  </ScrollView>
293
- {loadingList ? (
294
- <ActivityIndicator style={{marginTop: 16}} />
113
+ {chat.loadingList ? (
114
+ <ActivityIndicator style={styles.spinner} />
295
115
  ) : (
296
- <FlatList
297
- data={tasks}
298
- keyExtractor={item => String(item.id || item['@id'])}
299
- renderItem={({item}) => {
300
- const id = item.id || item['@id']?.split('/').pop();
301
- const selected = String(id) === String(activeTaskId);
302
- return (
303
- <TouchableOpacity
304
- onPress={() => selectTask(item)}
305
- style={[styles.taskRow, selected && styles.taskRowActive]}>
306
- <Text numberOfLines={1} style={styles.taskNameText}>
307
- {item.name || `Chat #${id}`}
308
- </Text>
309
- </TouchableOpacity>
310
- );
311
- }}
312
- ListEmptyComponent={
313
- <Text style={styles.emptyText}>Nenhum chat ainda. Envie uma mensagem.</Text>
314
- }
315
- />
116
+ <ScrollView>
117
+ {renderSection('Meus chats', internal, noAi ? 'Sua empresa ainda não tem IA configurada.' : 'Pergunte algo sobre a empresa.')}
118
+ {tickets.length ? renderSection('Meus chamados', tickets, '') : null}
119
+ {renderSection('IA atendendo clientes', customers, 'Nenhuma conversa com a IA agora.')}
120
+ </ScrollView>
316
121
  )}
317
122
  </View>
318
123
 
319
124
  <View style={styles.chatPane}>
320
125
  <View style={styles.chatHeader}>
321
- <Text style={styles.chatTitle}>
322
- {activeTask?.name || (activeTaskId ? `Chat #${activeTaskId}` : 'Novo chat')}
323
- </Text>
324
- <Text style={styles.chatSubtitle}>
325
- {PROVIDER_LABELS[provider] || provider || 'Selecione a IA'}
326
- </Text>
126
+ <View style={styles.chatHeaderText}>
127
+ <Text style={styles.chatTitle}>{task?.name || (chat.activeTaskId ? `Conversa #${chat.activeTaskId}` : 'Novo chat')}</Text>
128
+ <Text style={styles.chatSubtitle}>
129
+ {chat.myTicket
130
+ ? `Chamado ${stageLabel(task)} · ${task?.taskStatus?.status || 'aberto'}${task?.aiAgent ? ' · IA atendendo' : ''}`
131
+ : chat.customerChat
132
+ ? `${CHANNEL_LABELS[conversationChannel(task)]} · ${stageLabel(task)} · IA atendendo`
133
+ : ticketComposer
134
+ ? 'Novo chamado'
135
+ : PROVIDER_LABELS[chat.provider] || chat.provider || 'Selecione a IA'}
136
+ </Text>
137
+ </View>
138
+ {chat.customerChat ? (
139
+ <View style={styles.actionsRow}>
140
+ {(task?.type === 'ia' ? ['relationship', 'support'] : [task?.type]).map(type => (
141
+ <TouchableOpacity key={type} style={styles.actionBtn} onPress={() => chat.takeOver(type)}>
142
+ <Text style={styles.actionBtnText}>{`Assumir${task?.type === 'ia' ? ` (${stageLabel({type})})` : ''}`}</Text>
143
+ </TouchableOpacity>
144
+ ))}
145
+ </View>
146
+ ) : null}
327
147
  </View>
328
- {loadingChat ? (
329
- <ActivityIndicator style={{marginTop: 24}} />
148
+ {chat.loadingChat ? (
149
+ <ActivityIndicator style={styles.spinner} />
330
150
  ) : (
331
151
  <FlatList
332
152
  ref={listRef}
333
- data={messages}
153
+ data={chat.messages}
334
154
  keyExtractor={item => String(item.id || item['@id'])}
335
155
  renderItem={renderMessage}
156
+ ListFooterComponent={typing}
336
157
  contentContainerStyle={styles.messagesContent}
337
158
  onContentSizeChange={() => listRef.current?.scrollToEnd?.({animated: true})}
338
- ListEmptyComponent={
339
- <Text style={styles.emptyText}>
340
- Pergunte algo. A conversa vira uma Task type=ia.
341
- </Text>
342
- }
159
+ ListEmptyComponent={<Text style={styles.emptyText}>Pergunte sobre vendas, pedidos, clientes… A IA consulta os dados da empresa.</Text>}
343
160
  />
344
161
  )}
345
- <View style={styles.composer}>
346
- <TextInput
347
- style={styles.input}
348
- value={draft}
349
- onChangeText={setDraft}
350
- placeholder="Mensagem para a IA…"
351
- multiline
352
- editable={!sending}
353
- />
354
- <TouchableOpacity
355
- style={[styles.sendBtn, (!draft.trim() || sending) && styles.sendBtnDisabled]}
356
- disabled={!draft.trim() || sending}
357
- onPress={sendMessage}>
358
- <Text style={styles.sendBtnText}>{sending ? '…' : 'Enviar'}</Text>
359
- </TouchableOpacity>
360
- </View>
162
+ {chat.customerChat ? (
163
+ <Text style={styles.composerHint}>A IA está atendendo este cliente. Para responder você mesmo, use “Assumir” ou abra o ticket no CRM / Suporte.</Text>
164
+ ) : (
165
+ <View>
166
+ {ticketComposer && !chat.myTicket ? (
167
+ <View style={styles.ticketTypeRow}>
168
+ {[['support', 'Suporte'], ['relationship', 'Comercial']].map(([value, label]) => (
169
+ <TouchableOpacity key={value} onPress={() => chat.setTicketType(value)} style={[styles.providerChip, chat.ticketType === value && styles.providerChipActive]}>
170
+ <Text style={[styles.providerChipText, chat.ticketType === value && styles.providerChipTextActive]}>{label}</Text>
171
+ </TouchableOpacity>
172
+ ))}
173
+ </View>
174
+ ) : null}
175
+ <View style={styles.composer}>
176
+ <TextInput style={styles.input} value={draft} onChangeText={setDraft} placeholder={chat.myTicket ? 'Escreva no chamado…' : ticketComposer ? 'Descreva o que precisa; abriremos um chamado com a nossa equipe…' : 'Pergunte à IA…'} placeholderTextColor="#8b98a5" multiline editable={!chat.sending} />
177
+ <TouchableOpacity style={[styles.sendBtn, (!draft.trim() || chat.sending) && styles.sendBtnDisabled]} disabled={!draft.trim() || chat.sending} onPress={submit}>
178
+ <Text style={styles.sendBtnText}>{chat.sending ? '…' : ticketComposer && !chat.myTicket ? 'Abrir chamado' : 'Enviar'}</Text>
179
+ </TouchableOpacity>
180
+ </View>
181
+ </View>
182
+ )}
361
183
  </View>
362
184
  </KeyboardAvoidingView>
363
185
  );
@@ -58,14 +58,24 @@ export default StyleSheet.create({
58
58
  },
59
59
  taskRowActive: {backgroundColor: '#1e2732'},
60
60
  taskRowText: {color: '#e7e9ea', fontSize: 13},
61
+ taskRowMeta: {color: '#8b98a5', fontSize: 11, marginTop: 2},
62
+ sectionTitle: {color: '#8b98a5', fontSize: 11, fontWeight: '700', textTransform: 'uppercase', paddingHorizontal: 12, paddingTop: 12, paddingBottom: 4},
63
+ spinner: {marginTop: 16},
61
64
  emptyText: {color: '#8b98a5', padding: 16, fontSize: 13},
62
65
  chatPane: {flex: 1, minWidth: 0},
63
66
  chatHeader: {
67
+ flexDirection: 'row',
68
+ alignItems: 'center',
69
+ gap: 8,
64
70
  paddingHorizontal: 16,
65
71
  paddingVertical: 12,
66
72
  borderBottomWidth: 1,
67
73
  borderBottomColor: '#2a3441',
68
74
  },
75
+ chatHeaderText: {flex: 1, minWidth: 0},
76
+ actionsRow: {flexDirection: 'row', gap: 6},
77
+ actionBtn: {borderWidth: 1, borderColor: '#1d9bf0', borderRadius: 8, paddingHorizontal: 10, paddingVertical: 6},
78
+ actionBtnText: {color: '#1d9bf0', fontSize: 12, fontWeight: '600'},
69
79
  chatTitle: {color: '#e7e9ea', fontSize: 16, fontWeight: '600'},
70
80
  chatSubtitle: {color: '#8b98a5', fontSize: 12, marginTop: 2},
71
81
  messagesContent: {padding: 12, paddingBottom: 24},
@@ -84,7 +94,12 @@ export default StyleSheet.create({
84
94
  alignSelf: 'flex-start',
85
95
  backgroundColor: '#212a33',
86
96
  },
87
- bubbleMeta: {fontSize: 11, opacity: 0.7, marginTop: 4},
97
+ bubbleNote: {alignSelf: 'center', backgroundColor: '#3a2f12', borderWidth: 1, borderColor: '#8a6d1d'},
98
+ bubbleCustomer: {backgroundColor: '#1f3a2b'},
99
+ bubbleAuthor: {color: '#8b98a5', fontSize: 11, fontWeight: '700', marginBottom: 2},
100
+ bubbleMeta: {color: '#8b98a5', fontSize: 11, marginTop: 4},
101
+ ticketTypeRow: {flexDirection: 'row', gap: 6, paddingHorizontal: 10, paddingTop: 8},
102
+ composerHint: {color: '#8b98a5', fontSize: 12, padding: 12, borderTopWidth: 1, borderTopColor: '#2a3441'},
88
103
  bubbleText: {color: '#e7e9ea', fontSize: 14, lineHeight: 20},
89
104
  composer: {
90
105
  flexDirection: 'row',