@controleonline/ui-crm 1.0.69 → 1.0.71

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.
Files changed (29) hide show
  1. package/.release/rc-manifest.json +6 -6
  2. package/package.json +4 -3
  3. package/src/react/components/conversation/Attachment.js +61 -0
  4. package/src/react/components/conversation/AudioPlayer.native.js +28 -0
  5. package/src/react/components/conversation/AudioPlayer.web.js +9 -0
  6. package/src/react/components/conversation/Composer.js +134 -0
  7. package/src/react/components/conversation/ConversationView.js +91 -0
  8. package/src/react/components/conversation/MessageBubble.js +68 -0
  9. package/src/react/components/conversation/OptionPicker.js +62 -0
  10. package/src/react/components/conversation/RichText.js +34 -0
  11. package/src/react/components/conversation/fileApi.js +78 -0
  12. package/src/react/components/conversation/formatText.js +61 -0
  13. package/src/react/components/conversation/requestApi.js +91 -0
  14. package/src/react/components/conversation/useAudioRecording.native.js +31 -0
  15. package/src/react/components/conversation/useAudioRecording.web.js +54 -0
  16. package/src/react/components/conversation/useChatPalette.js +41 -0
  17. package/src/react/pages/crm/conversation.js +25 -326
  18. package/src/react/pages/mcp/McpPage.js +134 -130
  19. package/src/react/pages/mcp/useRequests.js +127 -0
  20. package/src/react/pages/settings/GeneralSettings.js +8 -0
  21. package/src/react/pages/settings/sections/TicketSettingsSection.js +124 -0
  22. package/src/react/pages/tickets/TicketConversationPage.js +5 -164
  23. package/src/react/pages/tickets/TicketFunnelPage.js +5 -1
  24. package/src/react/pages/tickets/TicketWorkspace.js +245 -0
  25. package/src/react/router/routes.js +6 -6
  26. package/src/tests/react/components/conversation/formatText.test.js +40 -0
  27. package/src/react/pages/crm/conversation.styles.js +0 -206
  28. package/src/react/pages/mcp/McpPage.styles.js +0 -132
  29. package/src/react/pages/mcp/useMcpChat.js +0 -277
@@ -1,171 +1,12 @@
1
1
  /*
2
- * @agents One customer ticket (ia triage, CRM or support): the full conversation, employee reply to the
3
- * customer (public -> goes out through the ticket's WhatsApp/e-mail connection), internal notes (private),
4
- * put the AI on the ticket or take it over. Live via websocket events.
2
+ * @agents /ticket/:taskId — one request opened from Support (or a push notification): the shared
3
+ * analyst workspace (TicketWorkspace).
5
4
  */
6
- import React, {useCallback, useEffect, useRef, useState} from 'react';
7
- import {ActivityIndicator, FlatList, KeyboardAvoidingView, Platform, Text, TextInput, TouchableOpacity, View} from 'react-native';
5
+ import React from 'react';
8
6
  import {useRoute} from '@react-navigation/native';
9
- import {useStore} from '@store';
10
- import useToastMessage from '../../hooks/useToastMessage';
11
- import AssignAiModal from './AssignAiModal';
12
- import useRealtimeReload from './useRealtimeReload';
13
- import {assignAi, fetchTicket, fetchTicketMessages, postTicketMessage, takeOverTicket} from './ticketApi';
14
- import styles from './tickets.styles';
15
-
16
- const {idOf, conversationChannel, messageRole, stageLabel} = require('../mcp/mcpChatUtils');
17
- const {personName} = require('./ticketUtils');
18
-
19
- const CHANNEL_LABELS = {whatsapp: 'WhatsApp', email: 'E-mail', web: 'Site'};
20
- const ROLE_STYLE = {customer: 'bubbleLeft', ai: 'bubbleAi', note: 'bubbleNote', staff: 'bubbleRight', me: 'bubbleRight'};
7
+ import TicketWorkspace from './TicketWorkspace';
21
8
 
22
9
  export default function TicketConversationPage() {
23
10
  const route = useRoute();
24
- const taskId = Number(route?.params?.taskId || 0);
25
- const {showError} = useToastMessage();
26
- const peopleStore = useStore('people');
27
- const authStore = useStore('auth');
28
- const companyId = idOf(peopleStore?.getters?.currentCompany || peopleStore?.getters?.mainCompany);
29
- const currentPeopleId = idOf(authStore?.getters?.user?.people);
30
-
31
- const [task, setTask] = useState(null);
32
- const [messages, setMessages] = useState([]);
33
- const [loading, setLoading] = useState(true);
34
- const [draft, setDraft] = useState('');
35
- const [mode, setMode] = useState('public');
36
- const [sending, setSending] = useState(false);
37
- const [assignOpen, setAssignOpen] = useState(false);
38
- const listRef = useRef(null);
39
-
40
- const load = useCallback(async () => {
41
- if (!taskId) return;
42
- try {
43
- const [t, m] = await Promise.all([fetchTicket(taskId), fetchTicketMessages(taskId)]);
44
- setTask(t);
45
- setMessages(m);
46
- } catch (e) {
47
- showError(e?.message || 'Falha ao carregar o ticket');
48
- } finally {
49
- setLoading(false);
50
- }
51
- }, [taskId, showError]);
52
-
53
- useEffect(() => {
54
- load();
55
- }, [load]);
56
- const isThisTask = useCallback(evt => Number(evt.task_id) === taskId, [taskId]);
57
- useRealtimeReload(load, {filter: isThisTask, delay: 200});
58
-
59
- const send = async () => {
60
- const body = draft.trim();
61
- if (!body || sending) return;
62
- setSending(true);
63
- try {
64
- await postTicketMessage(taskId, body, mode);
65
- setDraft('');
66
- await load();
67
- } catch (e) {
68
- showError(e?.message || 'Não foi possível enviar');
69
- } finally {
70
- setSending(false);
71
- }
72
- };
73
-
74
- const takeOver = async type => {
75
- try {
76
- await takeOverTicket(taskId, companyId, type);
77
- await load();
78
- } catch (e) {
79
- showError(e?.message || 'Não foi possível assumir');
80
- }
81
- };
82
-
83
- const confirmAssign = async instructions => {
84
- try {
85
- await assignAi(taskId, companyId, instructions);
86
- setAssignOpen(false);
87
- await load();
88
- } catch (e) {
89
- showError(e?.message || 'Não foi possível atribuir a IA');
90
- }
91
- };
92
-
93
- if (loading) return <ActivityIndicator style={styles.spinner} />;
94
- if (!task) return <Text style={styles.emptyText}>Ticket não encontrado.</Text>;
95
-
96
- const channel = CHANNEL_LABELS[conversationChannel(task)];
97
- const renderMessage = ({item}) => {
98
- const role = messageRole(item, {companyId, task, currentPeopleId});
99
- const author = role === 'ai' ? 'IA' : role === 'note' ? 'Nota interna' : personName(item.registeredBy);
100
- const isNote = item.visibility === 'private' && role !== 'ai';
101
- return (
102
- <View style={[styles.bubble, styles[isNote ? 'bubbleNote' : ROLE_STYLE[role]]]}>
103
- {author ? <Text style={styles.bubbleAuthor}>{isNote && role !== 'note' ? `${author} · interno` : author}</Text> : null}
104
- <Text style={styles.bubbleText}>{item.body}</Text>
105
- {item.createdAt ? <Text style={styles.bubbleMeta}>{new Date(item.createdAt).toLocaleString('pt-BR')}</Text> : null}
106
- </View>
107
- );
108
- };
109
-
110
- return (
111
- <KeyboardAvoidingView style={styles.root} behavior={Platform.OS === 'ios' ? 'padding' : undefined} keyboardVerticalOffset={80}>
112
- <View style={styles.header}>
113
- <View style={styles.headerText}>
114
- <Text style={styles.title} numberOfLines={1}>{task.name || `Ticket #${taskId}`}</Text>
115
- <Text style={styles.subtitle}>
116
- {[personName(task.client), stageLabel(task), task.taskStatus?.status, channel].filter(Boolean).join(' · ')}
117
- </Text>
118
- </View>
119
- </View>
120
- <View style={styles.aiBar}>
121
- <Text style={styles.aiBarText}>
122
- {task.aiAgent ? 'A IA está atendendo este cliente.' : 'Atendimento humano. Você pode colocar a IA para conduzir.'}
123
- </Text>
124
- {task.aiAgent
125
- ? (task.type === 'ia' ? ['relationship', 'support'] : [task.type]).map(type => (
126
- <TouchableOpacity key={type} style={styles.ghostBtn} onPress={() => takeOver(type)}>
127
- <Text style={styles.ghostBtnText}>{task.type === 'ia' ? `Assumir (${stageLabel({type})})` : 'Assumir'}</Text>
128
- </TouchableOpacity>
129
- ))
130
- : (
131
- <TouchableOpacity style={styles.ghostBtn} onPress={() => setAssignOpen(true)}>
132
- <Text style={styles.ghostBtnText}>Atribuir IA</Text>
133
- </TouchableOpacity>
134
- )}
135
- </View>
136
- <FlatList
137
- ref={listRef}
138
- data={messages}
139
- keyExtractor={item => String(item.id || item['@id'])}
140
- renderItem={renderMessage}
141
- contentContainerStyle={styles.messages}
142
- onContentSizeChange={() => listRef.current?.scrollToEnd?.({animated: true})}
143
- ListEmptyComponent={<Text style={styles.emptyText}>Sem mensagens ainda.</Text>}
144
- />
145
- <View style={styles.composer}>
146
- <View style={styles.modeRow}>
147
- <TouchableOpacity style={[styles.modeChip, mode === 'public' && styles.modeChipActive]} onPress={() => setMode('public')}>
148
- <Text style={styles.modeChipText}>{`Responder cliente${channel ? ` (${channel})` : ''}`}</Text>
149
- </TouchableOpacity>
150
- <TouchableOpacity style={[styles.modeChip, mode === 'private' && styles.modeChipNote]} onPress={() => setMode('private')}>
151
- <Text style={styles.modeChipText}>Nota interna</Text>
152
- </TouchableOpacity>
153
- </View>
154
- <View style={styles.composerRow}>
155
- <TextInput
156
- style={styles.input}
157
- value={draft}
158
- onChangeText={setDraft}
159
- placeholder={mode === 'public' ? 'Mensagem para o cliente (a IA sai da conversa)…' : 'Nota visível só para a equipe…'}
160
- placeholderTextColor="#8b98a5"
161
- multiline
162
- />
163
- <TouchableOpacity style={styles.primaryBtn} onPress={send} disabled={sending || !draft.trim()}>
164
- {sending ? <ActivityIndicator color="#fff" /> : <Text style={styles.primaryBtnText}>Enviar</Text>}
165
- </TouchableOpacity>
166
- </View>
167
- </View>
168
- <AssignAiModal visible={assignOpen} ticketName={task.name} onCancel={() => setAssignOpen(false)} onConfirm={confirmAssign} />
169
- </KeyboardAvoidingView>
170
- );
11
+ return <TicketWorkspace taskId={Number(route?.params?.taskId || 0)} />;
171
12
  }
@@ -101,7 +101,11 @@ export default function TicketFunnelPage({type = 'relationship'}) {
101
101
  }
102
102
  };
103
103
 
104
- const open = task => navigation.navigate('TicketConversation', {taskId: idOf(task)});
104
+ // CRM opens its own conversation (workspace + marketing events); Support opens the ticket page.
105
+ const open = task =>
106
+ type === 'relationship'
107
+ ? navigation.navigate('CrmConversation', {taskId: idOf(task), opportunity: task})
108
+ : navigation.navigate('TicketConversation', {taskId: idOf(task)});
105
109
 
106
110
  return (
107
111
  <View style={styles.root}>
@@ -0,0 +1,245 @@
1
+ /*
2
+ * @agents Analyst workspace of one request (Support /support and CRM), app-community#1599/#1600:
3
+ * WhatsApp-like conversation + actions: status, category, responsible (only the context's responders:
4
+ * CRM = salesmen/assistants, Support = Manager list), context relationship <-> support, due date,
5
+ * reply to the customer or internal note, and call the company's AI (only when one is connected).
6
+ * Who may reply mirrors the backend rule (TicketRulesService): non-responders see a notice.
7
+ */
8
+ import React, {useCallback, useEffect, useState} from 'react';
9
+ import {Text, TouchableOpacity, View} from 'react-native';
10
+ import useToastMessage from '../../hooks/useToastMessage';
11
+ import ConversationView from '../../components/conversation/ConversationView';
12
+ import OptionPicker from '../../components/conversation/OptionPicker';
13
+ import useChatPalette from '../../components/conversation/useChatPalette';
14
+ import {
15
+ assignAi,
16
+ fetchCategories,
17
+ fetchCompanyAis,
18
+ fetchMessages,
19
+ fetchResponders,
20
+ fetchStatuses,
21
+ fetchTask,
22
+ personName,
23
+ postInteraction,
24
+ REQUEST_TYPES,
25
+ takeOver,
26
+ updateTask,
27
+ } from '../../components/conversation/requestApi';
28
+ import AssignAiModal from './AssignAiModal';
29
+ import useRealtimeReload from './useRealtimeReload';
30
+ import {useStore} from '@store';
31
+
32
+ const {idOf, messageRole, conversationChannel} = require('../mcp/mcpChatUtils');
33
+
34
+ const CHANNELS = {whatsapp: 'WhatsApp', email: 'E-mail', web: 'App'};
35
+ const DUE_OPTIONS = [
36
+ {value: '', label: 'Sem previsão'},
37
+ {value: '0', label: 'Hoje'},
38
+ {value: '1', label: 'Amanhã'},
39
+ {value: '3', label: 'Em 3 dias'},
40
+ {value: '7', label: 'Em 7 dias'},
41
+ ];
42
+
43
+ export default function TicketWorkspace({taskId, extra = null}) {
44
+ const palette = useChatPalette();
45
+ const {showError, showSuccess} = useToastMessage();
46
+ const onError = useCallback(message => showError(message), [showError]);
47
+ const authStore = useStore('auth');
48
+ const meId = idOf(authStore?.getters?.user?.people);
49
+
50
+ const [task, setTask] = useState(null);
51
+ const [messages, setMessages] = useState([]);
52
+ const [loading, setLoading] = useState(true);
53
+ const [options, setOptions] = useState({statuses: [], categories: [], responders: [], canReply: false, ais: []});
54
+ const [mode, setMode] = useState('public');
55
+ const [assignOpen, setAssignOpen] = useState(false);
56
+
57
+ const providerId = idOf(task?.provider);
58
+ const type = task?.type;
59
+
60
+ const load = useCallback(
61
+ async ({quiet = false} = {}) => {
62
+ if (!taskId) return;
63
+ if (!quiet) setLoading(true);
64
+ try {
65
+ const [t, m] = await Promise.all([fetchTask(taskId), fetchMessages(taskId)]);
66
+ setTask(t);
67
+ setMessages(m);
68
+ } catch (e) {
69
+ onError(e?.message || 'Falha ao carregar a solicitação');
70
+ } finally {
71
+ setLoading(false);
72
+ }
73
+ },
74
+ [taskId, onError],
75
+ );
76
+
77
+ useEffect(() => {
78
+ load();
79
+ }, [load]);
80
+
81
+ useEffect(() => {
82
+ if (!type || !providerId) return;
83
+ Promise.all([
84
+ fetchStatuses(type).catch(() => []),
85
+ fetchCategories(type, providerId).catch(() => []),
86
+ fetchResponders(type, providerId).catch(() => ({responders: [], can_reply: false})),
87
+ fetchCompanyAis(providerId),
88
+ ]).then(([statuses, categories, responders, ais]) =>
89
+ setOptions({statuses, categories, responders: responders?.responders || [], canReply: Boolean(responders?.can_reply), ais}),
90
+ );
91
+ }, [type, providerId]);
92
+
93
+ useRealtimeReload(() => load({quiet: true}), {filter: useCallback(evt => Number(evt.task_id) === Number(taskId), [taskId]), delay: 200});
94
+
95
+ const save = async (patch, message) => {
96
+ try {
97
+ await updateTask(task, patch);
98
+ if (message) showSuccess(message);
99
+ await load({quiet: true});
100
+ } catch (e) {
101
+ onError(e?.message || 'Não foi possível salvar');
102
+ }
103
+ };
104
+
105
+ const changeContext = async newType => {
106
+ const statuses = await fetchStatuses(newType).catch(() => []);
107
+ const same = statuses.find(s => s.realStatus === task?.taskStatus?.realStatus) || statuses[0];
108
+ // The responsible person and category belong to the old context: cleared for the new one.
109
+ await save({type: newType, ...(same ? {taskStatus: same['@id'] || `/statuses/${idOf(same)}`} : {}), taskFor: null, category: null}, 'Contexto alterado');
110
+ };
111
+
112
+ const changeDue = value => {
113
+ if (value === '') return save({dueDate: null});
114
+ const d = new Date();
115
+ d.setDate(d.getDate() + Number(value));
116
+ d.setHours(18, 0, 0, 0);
117
+ return save({dueDate: d.toISOString()});
118
+ };
119
+
120
+ const describe = useCallback(
121
+ item => {
122
+ const role = messageRole(item, {companyId: providerId, task, currentPeopleId: meId});
123
+ if (role === 'customer') return {side: 'left', kind: 'msg', author: personName(item?.registeredBy) || 'Cliente'};
124
+ if (role === 'ai') return {side: 'right', kind: 'ai', author: 'IA'};
125
+ if (role === 'note' || item?.visibility === 'private') return {side: 'right', kind: 'note', author: personName(item?.registeredBy) || 'Equipe'};
126
+ return {side: 'right', kind: 'msg', author: role === 'me' ? 'Você' : personName(item?.registeredBy) || 'Equipe'};
127
+ },
128
+ [providerId, task, meId],
129
+ );
130
+
131
+ const send = async ({text, fileId}) => {
132
+ await postInteraction(taskId, {text, fileId, visibility: mode});
133
+ await load({quiet: true});
134
+ return true;
135
+ };
136
+
137
+ if (!task && !loading) return <Text style={{color: palette.muted, padding: 24}}>Solicitação não encontrada.</Text>;
138
+
139
+ const channel = CHANNELS[conversationChannel(task)] || '';
140
+ const btn = active => ({
141
+ paddingHorizontal: 12,
142
+ paddingVertical: 6,
143
+ borderRadius: 14,
144
+ marginRight: 6,
145
+ marginBottom: 6,
146
+ backgroundColor: active ? palette.chipActive : palette.chip,
147
+ });
148
+
149
+ const header = task ? (
150
+ <View style={{borderBottomWidth: 1, borderBottomColor: palette.border, backgroundColor: palette.panel, paddingHorizontal: 12, paddingTop: 10, paddingBottom: 4}}>
151
+ <Text style={{color: palette.text, fontWeight: '700', fontSize: 16}} numberOfLines={1}>
152
+ {task.name || `Solicitação #${taskId}`}
153
+ </Text>
154
+ <Text style={{color: palette.muted, fontSize: 12, marginBottom: 8}} numberOfLines={1}>
155
+ {[personName(task.client), channel, `#${taskId}`].filter(Boolean).join(' · ')}
156
+ </Text>
157
+ <View style={{flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center'}}>
158
+ <OptionPicker label="Contexto" value={task.type} options={REQUEST_TYPES} onChange={changeContext} />
159
+ <OptionPicker
160
+ label="Status"
161
+ value={idOf(task.taskStatus)}
162
+ options={options.statuses.map(s => ({value: idOf(s), label: s.status, hint: s.realStatus}))}
163
+ onChange={(_, o) => save({taskStatus: `/statuses/${o.value}`}, 'Status alterado')}
164
+ />
165
+ <OptionPicker
166
+ label="Categoria"
167
+ value={idOf(task.category) || ''}
168
+ options={[{value: '', label: 'Sem categoria'}, ...options.categories.map(c => ({value: idOf(c), label: c.name}))]}
169
+ onChange={value => save({category: value ? `/categories/${value}` : null}, 'Categoria alterada')}
170
+ />
171
+ <OptionPicker
172
+ label="Responsável"
173
+ value={idOf(task.taskFor) || ''}
174
+ options={[{value: '', label: 'Sem responsável'}, ...options.responders.map(p => ({value: p.id, label: p.alias || p.name}))]}
175
+ onChange={value => save({taskFor: value ? `/people/${value}` : null}, 'Responsável alterado')}
176
+ />
177
+ <OptionPicker
178
+ label="Previsão"
179
+ value=""
180
+ options={DUE_OPTIONS}
181
+ placeholder={task.dueDate ? new Date(task.dueDate).toLocaleDateString('pt-BR') : 'Sem previsão'}
182
+ onChange={changeDue}
183
+ />
184
+ {task.aiAgent ? (
185
+ <TouchableOpacity style={btn(true)} onPress={() => takeOver(taskId, providerId, task.type).then(() => load({quiet: true})).catch(e => onError(e?.message))}>
186
+ <Text style={{color: palette.chipActiveText, fontSize: 12, fontWeight: '700'}}>IA atendendo · Assumir</Text>
187
+ </TouchableOpacity>
188
+ ) : options.ais.length ? (
189
+ <TouchableOpacity style={btn(false)} onPress={() => setAssignOpen(true)}>
190
+ <Text style={{color: palette.chipText, fontSize: 12, fontWeight: '700'}}>Acionar IA</Text>
191
+ </TouchableOpacity>
192
+ ) : null}
193
+ </View>
194
+ </View>
195
+ ) : null;
196
+
197
+ const modeChips = (
198
+ <View style={{flexDirection: 'row', marginBottom: 6}}>
199
+ {[
200
+ ['public', `Responder cliente${channel ? ` (${channel})` : ''}`],
201
+ ['private', 'Nota interna'],
202
+ ].map(([value, label]) => (
203
+ <TouchableOpacity key={value} style={btn(mode === value)} onPress={() => setMode(value)}>
204
+ <Text style={{color: mode === value ? palette.chipActiveText : palette.chipText, fontSize: 12}}>{label}</Text>
205
+ </TouchableOpacity>
206
+ ))}
207
+ </View>
208
+ );
209
+
210
+ return (
211
+ <View style={{flex: 1, minHeight: 0}}>
212
+ <ConversationView
213
+ header={header}
214
+ messages={messages}
215
+ loading={loading}
216
+ describe={describe}
217
+ onSend={send}
218
+ uploadCompanyId={providerId}
219
+ placeholder={mode === 'public' ? 'Mensagem para o cliente' : 'Nota visível só para a equipe'}
220
+ canSend={options.canReply}
221
+ disabledText={
222
+ task?.type === 'relationship'
223
+ ? 'Somente vendedores e assistentes de vendas respondem chamados comerciais.'
224
+ : 'Somente quem atende suporte (Configurador → Atendimento) responde estes chamados.'
225
+ }
226
+ composerTop={modeChips}
227
+ footer={extra}
228
+ onError={onError}
229
+ />
230
+ <AssignAiModal
231
+ visible={assignOpen}
232
+ ticketName={task?.name}
233
+ onCancel={() => setAssignOpen(false)}
234
+ onConfirm={instructions =>
235
+ assignAi(taskId, providerId, instructions)
236
+ .then(() => {
237
+ setAssignOpen(false);
238
+ return load({quiet: true});
239
+ })
240
+ .catch(e => onError(e?.message || 'Não foi possível acionar a IA'))
241
+ }
242
+ />
243
+ </View>
244
+ );
245
+ }
@@ -54,7 +54,7 @@ const crmRoutes = [
54
54
  {
55
55
  name: 'RoyaltiesPayablePage',
56
56
  component: RoyaltiesPayablePage,
57
- path: 'royalties-a-pagar',
57
+ path: 'royalties-payable',
58
58
  options: {
59
59
  showCompanyFilter: true,
60
60
  showBottomToolBar: true,
@@ -67,7 +67,7 @@ const crmRoutes = [
67
67
  {
68
68
  name: 'RoyaltiesReceivablePage',
69
69
  component: RoyaltiesReceivablePage,
70
- path: 'royalties-a-receber',
70
+ path: 'royalties-receivable',
71
71
  options: {
72
72
  showCompanyFilter: true,
73
73
  showBottomToolBar: true,
@@ -133,7 +133,7 @@ const crmRoutes = [
133
133
  headerShown: true,
134
134
  headerBackVisible: true,
135
135
  companyFilterMode: 'icon',
136
- title: 'Chat IA / MCP',
136
+ title: 'Solicitações',
137
137
  },
138
138
  },
139
139
  {
@@ -150,7 +150,7 @@ const crmRoutes = [
150
150
  // Kanban of CRM opportunities (+ AI triage column).
151
151
  name: 'CrmFunnel',
152
152
  component: CrmFunnelPage,
153
- path: 'crm/funil',
153
+ path: 'crm/funnel',
154
154
  options: {
155
155
  showCompanyFilter: true,
156
156
  showBottomToolBar: true,
@@ -164,14 +164,14 @@ const crmRoutes = [
164
164
  // Support tickets funnel (clone of the CRM funnel for type=support).
165
165
  name: 'SupportFunnel',
166
166
  component: SupportFunnelPage,
167
- path: 'suporte',
167
+ path: 'support',
168
168
  options: {
169
169
  showCompanyFilter: true,
170
170
  showBottomToolBar: true,
171
171
  headerShown: true,
172
172
  headerBackVisible: true,
173
173
  companyFilterMode: 'icon',
174
- title: 'Suporte',
174
+ title: 'Atendimento de suporte',
175
175
  },
176
176
  },
177
177
  {
@@ -0,0 +1,40 @@
1
+ const {test} = require('node:test');
2
+ const assert = require('node:assert/strict');
3
+
4
+ const {parseRichText, dayLabel, initialsOf} = require('../../../../react/components/conversation/formatText');
5
+
6
+ test('parseRichText keeps plain text and splits lines', () => {
7
+ assert.deepEqual(parseRichText('oi\ntudo bem?'), [[{text: 'oi'}], [{text: 'tudo bem?'}]]);
8
+ });
9
+
10
+ test('parseRichText renders WhatsApp/markdown emphasis instead of raw markers', () => {
11
+ const [line] = parseRichText('A empresa teve **0** pedidos e _nenhum_ `erro` ~antigo~');
12
+ assert.deepEqual(line, [
13
+ {text: 'A empresa teve '},
14
+ {bold: true, text: '0'},
15
+ {text: ' pedidos e '},
16
+ {italic: true, text: 'nenhum'},
17
+ {text: ' '},
18
+ {code: true, text: 'erro'},
19
+ {text: ' '},
20
+ {strike: true, text: 'antigo'},
21
+ ]);
22
+ });
23
+
24
+ test('parseRichText turns bullets and links into parts', () => {
25
+ const [line] = parseRichText('- veja https://www.controleonline.com/ajuda.');
26
+ assert.deepEqual(line, [{text: '• '}, {text: 'veja '}, {link: 'https://www.controleonline.com/ajuda', text: 'https://www.controleonline.com/ajuda'}, {text: '.'}]);
27
+ });
28
+
29
+ test('dayLabel says Hoje / Ontem / date', () => {
30
+ const now = new Date(2026, 10, 17, 12);
31
+ assert.equal(dayLabel(new Date(2026, 10, 17, 8), now), 'Hoje');
32
+ assert.equal(dayLabel(new Date(2026, 10, 16, 23), now), 'Ontem');
33
+ assert.equal(dayLabel(new Date(2026, 10, 1), now), new Date(2026, 10, 1).toLocaleDateString('pt-BR'));
34
+ assert.equal(dayLabel('invalid', now), '');
35
+ });
36
+
37
+ test('initialsOf uses up to two words', () => {
38
+ assert.equal(initialsOf('Luiz Kim Dias'), 'LK');
39
+ assert.equal(initialsOf(''), '?');
40
+ });