@controleonline/ui-crm 1.0.84 → 1.0.86

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,13 @@
1
1
  {
2
- "version": "1.0.83",
2
+ "version": "1.0.85",
3
3
  "rc": 1,
4
- "branch": "rc/1.0.83-rc.1",
5
- "baseMaster": "88cc75124408d23d332ad1497f2ebfe89574b386",
4
+ "branch": "rc/1.0.85-rc.1",
5
+ "baseMaster": "311dec704aa59ca6ca112fe06455114988c7e8fd",
6
6
  "tasks": [
7
- 92
7
+ 95
8
8
  ],
9
9
  "frozen": true,
10
10
  "repositories": {
11
- "ControleOnline/ui-crm": "7e1b71beb980e5963fc0cd7908c8f045145a348c"
11
+ "ControleOnline/ui-crm": "dcc46f89f3a7fed41a1700145caaf8e4fb091eef"
12
12
  }
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@controleonline/ui-crm",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "author": "ControleOnline",
5
5
  "description": "ControleOnline CRM Quasar UI Component",
6
6
  "license": "MIT",
@@ -1,18 +1,23 @@
1
1
  /*
2
- * @agents One message, WhatsApp-like: avatar + name for others, own messages on the right with
3
- * time and delivery ticks, internal notes highlighted. Text uses RichText; files use Attachment.
2
+ * @agents One message, WhatsApp group-like: requests are group conversations, so every other participant
3
+ * (customer, team member, the AI person) has an avatar (photo or initials) beside the bubble with the
4
+ * name below it, when the speaker changes. My own messages: no avatar, ticks. Internal notes highlighted.
4
5
  */
5
6
  import React from 'react';
6
7
  import {Text, View} from 'react-native';
7
8
  import Attachment from './Attachment';
9
+ import PeopleAvatar from './PeopleAvatar';
10
+ import {fileIdOf} from './fileApi';
8
11
  import RichText from './RichText';
9
12
 
10
- const {initialsOf, timeLabel} = require('./formatText');
13
+ const {timeLabel} = require('./formatText');
11
14
 
12
15
  const TICKS = {pending: '🕓', processing: '🕓', done: '✓✓', error: '⚠'};
13
16
 
14
17
  export default function MessageBubble({item, side, kind, author, showAuthor, palette}) {
15
18
  const mine = side === 'right';
19
+ // "Você" (describe) or a message still being sent: my own, no avatar.
20
+ const self = author === 'Você' || Boolean(item?.localId);
16
21
  const note = kind === 'note';
17
22
  const bg = note ? palette.noteBubble : mine ? palette.mineBubble : palette.otherBubble;
18
23
  const fg = mine && !note ? palette.mineText : palette.otherText;
@@ -21,22 +26,8 @@ export default function MessageBubble({item, side, kind, author, showAuthor, pal
21
26
  const isFileLabel = item?.file && /^Anexo(:|$)/.test(body);
22
27
 
23
28
  return (
24
- <View style={{flexDirection: 'row', justifyContent: mine ? 'flex-end' : 'flex-start', marginVertical: 2, paddingHorizontal: 8}}>
25
- {!mine ? (
26
- <View
27
- style={{
28
- width: 32,
29
- height: 32,
30
- borderRadius: 16,
31
- marginRight: 6,
32
- marginTop: 2,
33
- alignItems: 'center',
34
- justifyContent: 'center',
35
- backgroundColor: showAuthor ? palette.chipActive : 'transparent',
36
- }}>
37
- {showAuthor ? <Text style={{color: palette.chipActiveText, fontWeight: '700', fontSize: 12}}>{initialsOf(author)}</Text> : null}
38
- </View>
39
- ) : null}
29
+ <View style={{flexDirection: mine ? 'row-reverse' : 'row', alignItems: 'flex-start', gap: 4, marginVertical: 2, paddingHorizontal: 8}}>
30
+ {!self ? (showAuthor ? <PeopleAvatar peopleId={fileIdOf(item?.registeredBy)} name={author} palette={palette} /> : <View style={{width: 56}} />) : null}
40
31
  <View
41
32
  style={{
42
33
  maxWidth: '78%',
@@ -51,10 +42,8 @@ export default function MessageBubble({item, side, kind, author, showAuthor, pal
51
42
  paddingTop: 6,
52
43
  paddingBottom: 4,
53
44
  }}>
54
- {showAuthor && (!mine || note) ? (
55
- <Text style={{color: note ? palette.noteBorder : palette.chipActive, fontWeight: '700', fontSize: 12, marginBottom: 2}}>
56
- {note ? `${author} · nota interna` : author}
57
- </Text>
45
+ {showAuthor && note ? (
46
+ <Text style={{color: palette.noteBorder, fontWeight: '700', fontSize: 12, marginBottom: 2}}>nota interna</Text>
58
47
  ) : null}
59
48
  {item?.file ? <Attachment file={item.file} color={fg} /> : null}
60
49
  {body && !isFileLabel ? <RichText value={body} style={{color: fg, fontSize: 15, lineHeight: 20}} linkColor={fg} /> : null}
@@ -0,0 +1,55 @@
1
+ /*
2
+ * @agents Avatar of a conversation participant (group chat look): the person's photo (people_media,
3
+ * cached per person for the whole app) or their initials; the name goes right below.
4
+ */
5
+ import React, {useEffect, useState} from 'react';
6
+ import {Image, Text, View} from 'react-native';
7
+ import {api} from '@controleonline/ui-common/src/api';
8
+ import {fileIdOf, fileSource} from './fileApi';
9
+ import {toItems} from './requestApi';
10
+
11
+ const {initialsOf} = require('./formatText');
12
+
13
+ const photoCache = new Map();
14
+
15
+ const photoOf = peopleId => {
16
+ if (!photoCache.has(peopleId)) {
17
+ photoCache.set(
18
+ peopleId,
19
+ api
20
+ .fetch('/people_media', {params: {people: peopleId, itemsPerPage: 1, 'order[id]': 'DESC'}})
21
+ .then(res => {
22
+ const fileId = fileIdOf(toItems(res)[0]?.file);
23
+ return fileId ? fileSource(fileId) : null;
24
+ })
25
+ .catch(() => null),
26
+ );
27
+ }
28
+ return photoCache.get(peopleId);
29
+ };
30
+
31
+ export default function PeopleAvatar({peopleId, name, palette, size = 34}) {
32
+ const [source, setSource] = useState(null);
33
+ useEffect(() => {
34
+ let alive = true;
35
+ if (peopleId) photoOf(peopleId).then(s => alive && setSource(s));
36
+ return () => {
37
+ alive = false;
38
+ };
39
+ }, [peopleId]);
40
+
41
+ return (
42
+ <View style={{width: 56, alignItems: 'center'}}>
43
+ {source ? (
44
+ <Image source={source} style={{width: size, height: size, borderRadius: size / 2}} />
45
+ ) : (
46
+ <View style={{width: size, height: size, borderRadius: size / 2, alignItems: 'center', justifyContent: 'center', backgroundColor: palette.chipActive}}>
47
+ <Text style={{color: palette.chipActiveText, fontWeight: '700', fontSize: 12}}>{initialsOf(name)}</Text>
48
+ </View>
49
+ )}
50
+ <Text numberOfLines={2} style={{color: palette.muted, fontSize: 10, textAlign: 'center', marginTop: 2}}>
51
+ {name}
52
+ </Text>
53
+ </View>
54
+ );
55
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * @agents One kind of request (support / relationship): who attends first (AI by default, or a person),
3
+ * the AI's name (the AI is a person of the company, e.g. "Tião IA") and the welcome message sent in
4
+ * its name. Saved with PUT /tickets/settings {attendance: {[type]: {first, ai_name, welcome}}}.
5
+ */
6
+ import React, {useEffect, useState} from 'react';
7
+ import {Text, TextInput, TouchableOpacity, View} from 'react-native';
8
+
9
+ const FIRST = [
10
+ {value: 'ai', label: 'IA primeiro (encaminha para uma pessoa quando precisar)'},
11
+ {value: 'human', label: 'Pessoa primeiro'},
12
+ ];
13
+
14
+ export default function AttendanceSettings({type, value, onSave, palette, styles, Choice}) {
15
+ const [name, setName] = useState(value?.ai_name || '');
16
+ const [welcome, setWelcome] = useState(value?.welcome || '');
17
+ useEffect(() => {
18
+ setName(value?.ai_name || '');
19
+ setWelcome(value?.welcome || '');
20
+ }, [value?.ai_name, value?.welcome]);
21
+
22
+ const input = {
23
+ borderWidth: 1,
24
+ borderColor: palette.inputBorder || palette.cardBorder,
25
+ backgroundColor: palette.inputBackground || palette.cardBackground,
26
+ color: palette.inputText || palette.textPrimary,
27
+ borderRadius: 10,
28
+ paddingHorizontal: 12,
29
+ paddingVertical: 8,
30
+ marginBottom: 8,
31
+ };
32
+
33
+ return (
34
+ <View style={{marginBottom: 12}}>
35
+ <Text style={styles.sectionTitle}>Primeiro atendimento</Text>
36
+ {FIRST.map(o => (
37
+ <Choice key={o.value} palette={palette} active={(value?.first || 'ai') === o.value} label={o.label} onPress={() => onSave({[type]: {first: o.value}})} />
38
+ ))}
39
+ <Text style={[styles.sectionTitle, {marginTop: 8}]}>Nome da IA</Text>
40
+ <TextInput style={input} value={name} onChangeText={setName} maxLength={60} placeholder="Ex.: Tião IA" placeholderTextColor={palette.inputPlaceholderText || palette.textMuted} />
41
+ <Text style={styles.sectionTitle}>Mensagem de boas-vindas</Text>
42
+ <TextInput
43
+ style={[input, {minHeight: 70, textAlignVertical: 'top'}]}
44
+ value={welcome}
45
+ onChangeText={setWelcome}
46
+ multiline
47
+ placeholder="Enviada em nome da IA quando a solicitação começa (vazio = sem mensagem)"
48
+ placeholderTextColor={palette.inputPlaceholderText || palette.textMuted}
49
+ />
50
+ <TouchableOpacity
51
+ onPress={() => onSave({[type]: {ai_name: name, welcome}})}
52
+ style={{alignSelf: 'flex-start', paddingVertical: 8, paddingHorizontal: 14, borderRadius: 10, backgroundColor: palette.primary}}>
53
+ <Text style={{color: palette.buttonText || palette.cardBackground, fontWeight: '700'}}>Salvar nome e boas-vindas</Text>
54
+ </TouchableOpacity>
55
+ </View>
56
+ );
57
+ }
@@ -12,6 +12,7 @@ import useToastMessage from '@controleonline/ui-crm/src/react/hooks/useToastMess
12
12
  import {fetchTicketSettings, saveTicketSettings} from '../../../components/conversation/requestApi';
13
13
  import {useGeneralSettingsPalette, useGeneralSettingsStyles} from '../GeneralSettings.styles';
14
14
  import GeneralSettingsSection from '../GeneralSettingsSection';
15
+ import AttendanceSettings from './AttendanceSettings';
15
16
  import {useGeneralSettingsConfig} from '../GeneralSettings.shared';
16
17
 
17
18
  const STRATEGIES = [
@@ -41,7 +42,7 @@ const Choice = ({active, label, onPress, palette, multi}) => (
41
42
  borderWidth: 2,
42
43
  marginRight: 10,
43
44
  borderColor: palette.primary,
44
- backgroundColor: active ? palette.primary : 'transparent',
45
+ backgroundColor: active ? palette.primary : palette.cardBackground,
45
46
  }}
46
47
  />
47
48
  <Text style={{color: palette.textPrimary, flex: 1}}>{label}</Text>
@@ -90,12 +91,16 @@ export default function TicketSettingsSection() {
90
91
 
91
92
  if (!settings) return <ActivityIndicator style={{marginTop: 16}} />;
92
93
  const employees = settings.employees || [];
94
+ const attendance = type => (
95
+ <AttendanceSettings type={type} value={settings.attendance?.[type]} onSave={patch => save({attendance: patch})} palette={palette} styles={styles} Choice={Choice} />
96
+ );
93
97
 
94
98
  return (
95
99
  <View>
96
100
  <GeneralSettingsSection
97
101
  title="Suporte"
98
- description="Chamados de suporte nascem sem responsável e são distribuídos entre as pessoas marcadas abaixo. Só elas respondem e aparecem como responsáveis em Atendimento de suporte.">
102
+ description="Com IA primeiro, o chamado fica com a IA (sem responsável) até ela resolver ou encaminhar. Pessoas: distribuição entre as marcadas abaixo, que respondem e aparecem como responsáveis em Atendimento de suporte.">
103
+ {attendance('support')}
99
104
  <Text style={styles.sectionTitle}>Regra de distribuição</Text>
100
105
  {STRATEGIES.map(s => (
101
106
  <Choice key={s.value} palette={palette} active={settings.support_strategy === s.value} label={s.label} onPress={() => save({support_strategy: s.value})} />
@@ -109,8 +114,8 @@ export default function TicketSettingsSection() {
109
114
 
110
115
  <GeneralSettingsSection
111
116
  title="Comercial (CRM)"
112
- description="Solicitações comerciais seguem a distribuição de clientes do CRM: cada cliente é atendido pelo seu vendedor; clientes sem vendedor recebem um pela estratégia configurada na aba CRM.">
113
- <Text style={styles.helperText}>Nada a configurar aqui.</Text>
117
+ description="Quando vai para uma pessoa, segue a distribuição de clientes do CRM: cada cliente é atendido pelo seu vendedor; clientes sem vendedor recebem um pela estratégia da aba CRM.">
118
+ {attendance('relationship')}
114
119
  </GeneralSettingsSection>
115
120
  {saving ? <ActivityIndicator style={{marginTop: 8}} /> : null}
116
121
  </View>