@controleonline/ui-crm 1.0.42
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/actions/workers/manager/action.yml +147 -0
- package/.github/actions/workers/qa/action.yml +44 -0
- package/.github/actions/workers/security/action.yml +44 -0
- package/.github/actions/workers/technical-documenter/action.yml +51 -0
- package/.github/workflows/manager-worker.yml +167 -0
- package/.github/workflows/publish-npm.yml +40 -0
- package/.github/workflows/pull-request-checks.yml +29 -0
- package/.scrutinizer.yml +24 -0
- package/AGENTS.md +56 -0
- package/FUNDING.yml +1 -0
- package/docs/technical/Cliente-Vendedor-Vinculo-e-Permissoes.md +121 -0
- package/docs/technical/Income-Statements-Demonstrativo.md +38 -0
- package/docs/technical/Oportunidades-Ordenacao-por-Data-de-Retorno.md +134 -0
- package/docs/technical/Propostas-Filtro-de-Status.md +147 -0
- package/docs/technical/Royalties-a-pagar-Franqueado.md +51 -0
- package/docs/technical/Visao-Vendedor-Comissoes.md +58 -0
- package/docs/wiki.md +1 -0
- package/package.json +43 -0
- package/scripts/validate-wiki-pointer.cjs +13 -0
- package/src/react/components/AnimatedModal.js +149 -0
- package/src/react/components/AnimatedModal.styles.js +21 -0
- package/src/react/components/CreateContractModal.js +151 -0
- package/src/react/components/CreateContractModal.styles.js +43 -0
- package/src/react/hooks/useToastMessage.js +59 -0
- package/src/react/index.js +4 -0
- package/src/react/pages/ModelTemplatesPage.js +1461 -0
- package/src/react/pages/ModelTemplatesPage.styles.js +441 -0
- package/src/react/pages/comissions/IncomeStatementDetailsModal.js +102 -0
- package/src/react/pages/comissions/IncomeStatementsFilters.js +120 -0
- package/src/react/pages/comissions/SellerCommissionsPage.js +368 -0
- package/src/react/pages/comissions/SellerCommissionsPage.styles.js +219 -0
- package/src/react/pages/comissions/incomeStatementsHelpers.js +233 -0
- package/src/react/pages/comissions/index.js +309 -0
- package/src/react/pages/comissions/index.styles.js +381 -0
- package/src/react/pages/comissions/sellerCommissionsHelpers.js +222 -0
- package/src/react/pages/crm/components/CrmHeader.js +117 -0
- package/src/react/pages/crm/components/MarketingEventsSection.js +142 -0
- package/src/react/pages/crm/components/MarketingEventsSection.styles.js +105 -0
- package/src/react/pages/crm/components/OpportunityCard.js +138 -0
- package/src/react/pages/crm/components/OpportunityFormModal.js +279 -0
- package/src/react/pages/crm/components/OpportunityList.js +113 -0
- package/src/react/pages/crm/components/OpportunitySkeletons.js +53 -0
- package/src/react/pages/crm/components/ProviderSelectModal.js +166 -0
- package/src/react/pages/crm/components/SelectModal.js +178 -0
- package/src/react/pages/crm/conversation.js +342 -0
- package/src/react/pages/crm/conversation.styles.js +206 -0
- package/src/react/pages/crm/hooks/useCrmData.js +494 -0
- package/src/react/pages/crm/hooks/useOpportunityForms.js +306 -0
- package/src/react/pages/crm/index.js +262 -0
- package/src/react/pages/crm/index.styles.js +13 -0
- package/src/react/pages/crm/marketingEventsHelpers.js +41 -0
- package/src/react/pages/crm/styles/card.styles.js +178 -0
- package/src/react/pages/crm/styles/layout.styles.js +184 -0
- package/src/react/pages/crm/styles/modal.styles.js +347 -0
- package/src/react/pages/home/index.js +559 -0
- package/src/react/pages/home/index.styles.js +268 -0
- package/src/react/pages/proposals/CreateProposalsModal.js +466 -0
- package/src/react/pages/proposals/CreateProposalsModal.styles.js +344 -0
- package/src/react/pages/proposals/CreateProposalsPickers.js +187 -0
- package/src/react/pages/proposals/CreateProposalsProductSection.js +117 -0
- package/src/react/pages/proposals/ProposalCard.js +112 -0
- package/src/react/pages/proposals/ProposalDetails.js +263 -0
- package/src/react/pages/proposals/ProposalDetails.styles.js +195 -0
- package/src/react/pages/proposals/index.js +488 -0
- package/src/react/pages/proposals/index.styles.js +248 -0
- package/src/react/pages/proposals/proposalListHelpers.js +216 -0
- package/src/react/pages/proposals/proposalNavigation.js +26 -0
- package/src/react/pages/royalties/ReceivablePage.js +233 -0
- package/src/react/pages/royalties/RoyaltiesPayablePage.js +260 -0
- package/src/react/pages/royalties/index.js +2 -0
- package/src/react/pages/royalties/royaltiesReceivableHelpers.js +68 -0
- package/src/react/pages/settings/GeneralSettings.js +317 -0
- package/src/react/pages/settings/GeneralSettings.shared.js +490 -0
- package/src/react/pages/settings/GeneralSettings.styles.js +746 -0
- package/src/react/pages/settings/GeneralSettingsSection.js +57 -0
- package/src/react/pages/settings/generalSettingsActiveTab.js +85 -0
- package/src/react/pages/settings/sections/CrmSection.js +281 -0
- package/src/react/pages/settings/sections/DeviceRuntimeFooterSection.js +128 -0
- package/src/react/pages/settings/sections/DisplayPreparationSection.js +155 -0
- package/src/react/pages/settings/sections/IntegrationsSection.js +392 -0
- package/src/react/pages/settings/sections/LogSection.js +322 -0
- package/src/react/pages/settings/sections/LoginSection.js +137 -0
- package/src/react/pages/settings/sections/LoyaltyProductPicker.js +230 -0
- package/src/react/pages/settings/sections/LoyaltySection.js +451 -0
- package/src/react/pages/settings/sections/MaintenanceSection.js +205 -0
- package/src/react/pages/settings/sections/MapsSection.js +629 -0
- package/src/react/pages/settings/sections/MenuCatalogSection.js +405 -0
- package/src/react/pages/settings/sections/OperationsSection.js +303 -0
- package/src/react/pages/settings/sections/OrderPaymentSection.js +379 -0
- package/src/react/pages/settings/sections/OrderPrintSection.js +308 -0
- package/src/react/pages/settings/sections/ShopSection.js +490 -0
- package/src/react/pages/settings/sections/shop/FranchiseMapPreview.js +124 -0
- package/src/react/pages/settings/sections/shop/ShopDomainCreateForm.js +57 -0
- package/src/react/pages/settings/sections/shop/ShopDomainPanel.js +184 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.js +237 -0
- package/src/react/pages/settings/sections/shop/ShopDomainShowcasesSection.styles.js +256 -0
- package/src/react/pages/settings/sections/shop/ShopDomainTabs.js +61 -0
- package/src/react/pages/settings/sections/shop/ShopFranchiseLocatorSection.js +526 -0
- package/src/react/pages/settings/sections/shop/ShopLoyaltySection.js +426 -0
- package/src/react/pages/settings/sections/shop/ShopSettingsSection.js +10 -0
- package/src/react/pages/settings/sections/shop/mapsFranchiseMapHelpers.js +163 -0
- package/src/react/pages/settings/sections/shop/shopDomainShowcasesUtils.js +68 -0
- package/src/react/pages/settings/sections/shop/shopFranchiseVisibility.js +158 -0
- package/src/react/pages/settings/sections/shop/shopSettingsShared.js +427 -0
- package/src/react/router/routes.js +135 -0
- package/src/react/utils/opportunityDate.js +82 -0
- package/src/react/utils/opportunityEditorReferences.js +76 -0
- package/src/react/utils/opportunityEmptyState.js +20 -0
- package/src/react/utils/opportunityPeople.js +111 -0
- package/src/react/utils/opportunityPhone.js +82 -0
- package/src/react/utils/opportunityStage.js +30 -0
- package/src/react/utils/opportunityStatusFilter.js +54 -0
- package/src/react/utils/proposalCreateHelpers.js +61 -0
- package/src/react/utils/proposalProductSelection.js +71 -0
- package/src/react/utils/royaltiesPayableParams.js +37 -0
- package/src/react/utils/translateWithFallback.js +42 -0
- package/src/store/crm/index.js +2 -0
- package/src/store/model/index.js +104 -0
- package/src/tests/browser/crm/create-proposal-product-category-filter.spec.js +149 -0
- package/src/tests/browser/crm/crm-index-status-filter.spec.js +263 -0
- package/src/tests/browser/crm/crm-opportunity-category-editor.spec.js +269 -0
- package/src/tests/browser/crm/royalties-payable.spec.js +122 -0
- package/src/tests/browser/crm/royalties-receivable.spec.js +121 -0
- package/src/tests/browser/crm/seller-commissions.spec.js +214 -0
- package/src/tests/browser/manager/general-settings-maps.spec.js +400 -0
- package/src/tests/react/pages/comissions/incomeStatementsHelpers.test.js +181 -0
- package/src/tests/react/pages/comissions/sellerCommissionsHelpers.test.js +132 -0
- package/src/tests/react/pages/crm/marketingEventsHelpers.test.cjs +53 -0
- package/src/tests/react/pages/crm/opportunitySearchParams.test.cjs +44 -0
- package/src/tests/react/pages/proposals/navigation.test.js +71 -0
- package/src/tests/react/pages/proposals/proposalListHelpers.test.js +42 -0
- package/src/tests/react/pages/royalties/royaltiesReceivableHelpers.test.js +60 -0
- package/src/tests/react/pages/settings/generalSettings.shared.test.js +102 -0
- package/src/tests/react/pages/settings/sections/shop/shopDomainShowcasesUtils.test.js +60 -0
- package/src/tests/react/pages/settings/sections/shop/shopFranchiseVisibility.test.js +80 -0
- package/src/tests/react/utils/opportunityEditorReferences.test.js +70 -0
- package/src/tests/react/utils/opportunityEmptyState.test.js +39 -0
- package/src/tests/react/utils/opportunityStatusFilter.test.cjs +81 -0
- package/src/tests/react/utils/proposalCreateHelpers.test.js +25 -0
- package/src/tests/react/utils/proposalProductSelection.test.js +76 -0
- package/src/tests/react/utils/royaltiesPayableParams.test.js +44 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
|
|
2
|
+
import { KeyboardAvoidingView, Platform, ScrollView, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import {Text} from 'react-native-animatable';
|
|
4
|
+
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
5
|
+
import IconMaterial from 'react-native-vector-icons/MaterialIcons';
|
|
6
|
+
import {useNavigation, useRoute} from '@react-navigation/native';
|
|
7
|
+
import {useStore} from '@store';
|
|
8
|
+
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
9
|
+
import useToastMessage from '../../hooks/useToastMessage';
|
|
10
|
+
import {colors} from '@controleonline/../../src/styles/colors';
|
|
11
|
+
import styles from './conversation.styles';
|
|
12
|
+
import MarketingEventsSection from './components/MarketingEventsSection';
|
|
13
|
+
|
|
14
|
+
export default function CrmConversation() {
|
|
15
|
+
const [message, setMessage] = useState('');
|
|
16
|
+
const [messages, setMessages] = useState([]);
|
|
17
|
+
const scrollViewRef = useRef(null);
|
|
18
|
+
const navigation = useNavigation();
|
|
19
|
+
const route = useRoute();
|
|
20
|
+
const insets = useSafeAreaInsets();
|
|
21
|
+
const {showError} = useToastMessage();
|
|
22
|
+
|
|
23
|
+
const opportunity = route.params?.opportunity || null;
|
|
24
|
+
const taskInteractionsStore = useStore('tasksInterations');
|
|
25
|
+
const getters = taskInteractionsStore?.getters || {};
|
|
26
|
+
const actions = taskInteractionsStore?.actions || {};
|
|
27
|
+
const items = getters?.items || [];
|
|
28
|
+
const peopleStore = useStore('people');
|
|
29
|
+
const peopleGetters = peopleStore?.getters || {};
|
|
30
|
+
const people = peopleGetters?.items || [];
|
|
31
|
+
|
|
32
|
+
const taskResource =
|
|
33
|
+
opportunity?.['@id'] || (opportunity?.id ? `/tasks/${opportunity.id}` : null);
|
|
34
|
+
|
|
35
|
+
const canSend = !!message.trim() && !!taskResource;
|
|
36
|
+
const primaryColor = colors.primary;
|
|
37
|
+
|
|
38
|
+
const normalizePeopleReference = value => {
|
|
39
|
+
if (!value) {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const rawValue = typeof value === 'object' ? value['@id'] ?? value.id : value;
|
|
44
|
+
if (rawValue == null) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const normalized = String(rawValue).trim();
|
|
49
|
+
if (!normalized) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (normalized.startsWith('/people/') || normalized.startsWith('/peoples/')) {
|
|
54
|
+
return normalized;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (normalized.startsWith('/')) {
|
|
58
|
+
return normalized;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (/^\d+$/.test(normalized)) {
|
|
62
|
+
return `/people/${normalized}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return normalized;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const clientName = useMemo(() => {
|
|
69
|
+
const directName =
|
|
70
|
+
opportunity?.client?.name ||
|
|
71
|
+
opportunity?.client?.realname ||
|
|
72
|
+
opportunity?.client?.alias ||
|
|
73
|
+
opportunity?.clientName ||
|
|
74
|
+
opportunity?.people?.name;
|
|
75
|
+
|
|
76
|
+
if (directName) {
|
|
77
|
+
return directName;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const clientRef = normalizePeopleReference(opportunity?.client);
|
|
81
|
+
if (!clientRef || !Array.isArray(people)) {
|
|
82
|
+
return global.t?.t('users','label', 'client', 'Cliente');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const linkedPerson = people.find(
|
|
86
|
+
person => normalizePeopleReference(person) === clientRef,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return linkedPerson?.name || linkedPerson?.realname || global.t?.t('users','label', 'client', 'Cliente');
|
|
90
|
+
}, [opportunity, people]);
|
|
91
|
+
|
|
92
|
+
const clientPeopleRef = useMemo(() => {
|
|
93
|
+
return (
|
|
94
|
+
normalizePeopleReference(opportunity?.client) ||
|
|
95
|
+
normalizePeopleReference(opportunity?.people) ||
|
|
96
|
+
''
|
|
97
|
+
);
|
|
98
|
+
}, [opportunity]);
|
|
99
|
+
|
|
100
|
+
const formatTime = timestamp =>
|
|
101
|
+
timestamp.toLocaleTimeString('pt-br', {
|
|
102
|
+
hour: '2-digit',
|
|
103
|
+
minute: '2-digit',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!opportunity) {
|
|
108
|
+
showError(global.t?.t('users','error', 'opportunityNotFound', 'Oportunidade nao encontrada para abrir a conversa.'));
|
|
109
|
+
navigation.goBack();
|
|
110
|
+
}
|
|
111
|
+
}, [opportunity, navigation, showError]);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!taskResource || typeof actions.getItems !== 'function') {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
actions.getItems({task: taskResource}).catch(error => {
|
|
119
|
+
console.error('Erro ao carregar conversa:', error);
|
|
120
|
+
showError(global.t?.t('users','error', 'loadMessages', 'Nao foi possivel carregar as mensagens da conversa.'));
|
|
121
|
+
});
|
|
122
|
+
}, [taskResource, actions, showError]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
126
|
+
setMessages([]);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const transformedMessages = items
|
|
131
|
+
.filter(item => item?.body && item.body !== 'null')
|
|
132
|
+
.map(item => ({
|
|
133
|
+
id: item.id,
|
|
134
|
+
text: String(item.body).replace(/"/g, ''),
|
|
135
|
+
timestamp: new Date(item.createdAt),
|
|
136
|
+
isFromUser: item.visibility === 'private',
|
|
137
|
+
}))
|
|
138
|
+
.sort((a, b) => a.timestamp - b.timestamp);
|
|
139
|
+
|
|
140
|
+
setMessages(transformedMessages);
|
|
141
|
+
}, [items]);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (messages.length > 0) {
|
|
145
|
+
requestAnimationFrame(() => {
|
|
146
|
+
scrollViewRef.current?.scrollToEnd({animated: true});
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}, [messages]);
|
|
150
|
+
|
|
151
|
+
const formatDate = timestamp => {
|
|
152
|
+
const today = new Date();
|
|
153
|
+
const messageDate = new Date(timestamp);
|
|
154
|
+
|
|
155
|
+
if (messageDate.toDateString() === today.toDateString()) {
|
|
156
|
+
return global.t?.t('users','date', 'today', 'Hoje');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const yesterday = new Date(today);
|
|
160
|
+
yesterday.setDate(yesterday.getDate() - 1);
|
|
161
|
+
|
|
162
|
+
if (messageDate.toDateString() === yesterday.toDateString()) {
|
|
163
|
+
return global.t?.t('users','date', 'yesterday', 'Ontem');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return messageDate.toLocaleDateString('pt-br', {
|
|
167
|
+
day: '2-digit',
|
|
168
|
+
month: '2-digit',
|
|
169
|
+
year: 'numeric',
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const sendMessage = async () => {
|
|
174
|
+
if (!canSend || typeof actions.save !== 'function') {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
await actions.save({
|
|
180
|
+
body: message.trim(),
|
|
181
|
+
file: null,
|
|
182
|
+
task: taskResource,
|
|
183
|
+
type: 'comment',
|
|
184
|
+
visibility: 'public',
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
setMessage('');
|
|
188
|
+
await actions.getItems?.({task: taskResource});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.error('Erro ao enviar mensagem:', error);
|
|
191
|
+
showError(global.t?.t('users','error', 'sendMessage', 'Nao foi possivel enviar a mensagem.'));
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const handleInputKeyPress = event => {
|
|
196
|
+
const key = event?.nativeEvent?.key;
|
|
197
|
+
const shift = !!event?.nativeEvent?.shiftKey;
|
|
198
|
+
|
|
199
|
+
if (key === 'Enter' && !shift) {
|
|
200
|
+
event?.preventDefault?.();
|
|
201
|
+
sendMessage();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const renderMessage = (msg, index) => {
|
|
206
|
+
const showDate =
|
|
207
|
+
index === 0 ||
|
|
208
|
+
formatDate(msg.timestamp) !== formatDate(messages[index - 1].timestamp);
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<View key={msg.id || `${msg.timestamp}-${index}`}>
|
|
212
|
+
{showDate && (
|
|
213
|
+
<View style={styles.dateContainer}>
|
|
214
|
+
<Text style={styles.dateText}>{formatDate(msg.timestamp)}</Text>
|
|
215
|
+
</View>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
<View
|
|
219
|
+
style={[
|
|
220
|
+
styles.messageContainer,
|
|
221
|
+
msg.isFromUser ? styles.userMessage : styles.otherMessage,
|
|
222
|
+
]}>
|
|
223
|
+
<View
|
|
224
|
+
style={[
|
|
225
|
+
styles.messageBubble,
|
|
226
|
+
msg.isFromUser ? styles.userBubble : styles.otherBubble,
|
|
227
|
+
]}>
|
|
228
|
+
<Text
|
|
229
|
+
style={[
|
|
230
|
+
styles.messageText,
|
|
231
|
+
msg.isFromUser
|
|
232
|
+
? styles.userMessageText
|
|
233
|
+
: styles.otherMessageText,
|
|
234
|
+
]}>
|
|
235
|
+
{msg.text}
|
|
236
|
+
</Text>
|
|
237
|
+
<Text
|
|
238
|
+
style={[
|
|
239
|
+
styles.messageTime,
|
|
240
|
+
msg.isFromUser
|
|
241
|
+
? styles.userMessageTime
|
|
242
|
+
: styles.otherMessageTime,
|
|
243
|
+
]}>
|
|
244
|
+
{formatTime(msg.timestamp)}
|
|
245
|
+
</Text>
|
|
246
|
+
</View>
|
|
247
|
+
</View>
|
|
248
|
+
</View>
|
|
249
|
+
);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<KeyboardAvoidingView
|
|
254
|
+
style={styles.container}
|
|
255
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
|
|
256
|
+
<View
|
|
257
|
+
style={[
|
|
258
|
+
styles.header,
|
|
259
|
+
{
|
|
260
|
+
paddingTop: Math.max(insets.top, 10),
|
|
261
|
+
backgroundColor: primaryColor,
|
|
262
|
+
},
|
|
263
|
+
]}>
|
|
264
|
+
<TouchableOpacity
|
|
265
|
+
style={styles.backButton}
|
|
266
|
+
onPress={() => navigation.goBack()}>
|
|
267
|
+
<Icon name="arrow-left" size={22} color="#FFFFFF" />
|
|
268
|
+
</TouchableOpacity>
|
|
269
|
+
|
|
270
|
+
<View style={styles.headerInfo}>
|
|
271
|
+
<View style={styles.avatar}>
|
|
272
|
+
<Icon name="user" size={18} color="#FFFFFF" />
|
|
273
|
+
</View>
|
|
274
|
+
<View style={styles.headerText}>
|
|
275
|
+
<Text style={styles.headerName}>
|
|
276
|
+
{clientName}
|
|
277
|
+
</Text>
|
|
278
|
+
</View>
|
|
279
|
+
</View>
|
|
280
|
+
</View>
|
|
281
|
+
|
|
282
|
+
<MarketingEventsSection peopleRef={clientPeopleRef} peopleName={clientName} />
|
|
283
|
+
|
|
284
|
+
<ScrollView
|
|
285
|
+
ref={scrollViewRef}
|
|
286
|
+
style={styles.messagesContainer}
|
|
287
|
+
contentContainerStyle={[
|
|
288
|
+
styles.messagesContent,
|
|
289
|
+
messages.length === 0 && styles.messagesContentEmpty,
|
|
290
|
+
]}
|
|
291
|
+
showsVerticalScrollIndicator={false}>
|
|
292
|
+
{messages.length === 0 ? (
|
|
293
|
+
<View style={styles.emptyStateContainer}>
|
|
294
|
+
<View style={styles.emptyStateIconCircle}>
|
|
295
|
+
<IconMaterial name="chat-bubble-outline" size={72} color="#94A3B8" />
|
|
296
|
+
</View>
|
|
297
|
+
<Text style={styles.emptyStateTitle}>
|
|
298
|
+
{global.t?.t('users','state', 'emptyTitle', 'Nenhuma mensagem ainda')}
|
|
299
|
+
</Text>
|
|
300
|
+
<Text style={styles.emptyStateSubtitle}>
|
|
301
|
+
{global.t?.t('users','state', 'emptySubtitle', 'Inicie a conversa enviando a primeira mensagem.')}
|
|
302
|
+
</Text>
|
|
303
|
+
</View>
|
|
304
|
+
) : (
|
|
305
|
+
messages.map((msg, index) => renderMessage(msg, index))
|
|
306
|
+
)}
|
|
307
|
+
</ScrollView>
|
|
308
|
+
|
|
309
|
+
<View style={[styles.inputContainer, {paddingBottom: Math.max(insets.bottom, 8)}]}>
|
|
310
|
+
<View style={styles.inputWrapper}>
|
|
311
|
+
<TextInput
|
|
312
|
+
style={styles.textInput}
|
|
313
|
+
value={message}
|
|
314
|
+
onChangeText={setMessage}
|
|
315
|
+
placeholder={global.t?.t('users','placeholder', 'message', 'Digite uma mensagem...')}
|
|
316
|
+
placeholderTextColor="#7A8794"
|
|
317
|
+
multiline={false}
|
|
318
|
+
maxLength={1000}
|
|
319
|
+
returnKeyType="send"
|
|
320
|
+
blurOnSubmit={false}
|
|
321
|
+
onSubmitEditing={sendMessage}
|
|
322
|
+
onKeyPress={handleInputKeyPress}
|
|
323
|
+
/>
|
|
324
|
+
</View>
|
|
325
|
+
|
|
326
|
+
<TouchableOpacity
|
|
327
|
+
style={[
|
|
328
|
+
styles.sendButton,
|
|
329
|
+
canSend ? styles.sendButtonActive : styles.sendButtonInactive,
|
|
330
|
+
]}
|
|
331
|
+
onPress={sendMessage}
|
|
332
|
+
disabled={!canSend}>
|
|
333
|
+
<IconMaterial
|
|
334
|
+
name="send"
|
|
335
|
+
size={20}
|
|
336
|
+
color={canSend ? '#FFFFFF' : '#B8C2CC'}
|
|
337
|
+
/>
|
|
338
|
+
</TouchableOpacity>
|
|
339
|
+
</View>
|
|
340
|
+
</KeyboardAvoidingView>
|
|
341
|
+
);
|
|
342
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
container: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
backgroundColor: '#EEEAE5',
|
|
7
|
+
},
|
|
8
|
+
header: {
|
|
9
|
+
backgroundColor: '#26C865',
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
paddingHorizontal: 14,
|
|
13
|
+
paddingBottom: 10,
|
|
14
|
+
borderBottomWidth: 1,
|
|
15
|
+
borderBottomColor: 'rgba(0,0,0,0.04)',
|
|
16
|
+
},
|
|
17
|
+
backButton: {
|
|
18
|
+
marginRight: 12,
|
|
19
|
+
padding: 6,
|
|
20
|
+
},
|
|
21
|
+
headerInfo: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
},
|
|
26
|
+
avatar: {
|
|
27
|
+
width: 34,
|
|
28
|
+
height: 34,
|
|
29
|
+
borderRadius: 17,
|
|
30
|
+
backgroundColor: 'rgba(255, 255, 255, 0.18)',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
justifyContent: 'center',
|
|
33
|
+
marginRight: 10,
|
|
34
|
+
},
|
|
35
|
+
headerText: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
},
|
|
38
|
+
headerName: {
|
|
39
|
+
fontSize: 17,
|
|
40
|
+
fontWeight: '400',
|
|
41
|
+
color: '#FFFFFF',
|
|
42
|
+
},
|
|
43
|
+
messagesContainer: {
|
|
44
|
+
flex: 1,
|
|
45
|
+
},
|
|
46
|
+
messagesContent: {
|
|
47
|
+
paddingTop: 10,
|
|
48
|
+
paddingBottom: 14,
|
|
49
|
+
},
|
|
50
|
+
messagesContentEmpty: {
|
|
51
|
+
flexGrow: 1,
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
},
|
|
54
|
+
emptyStateContainer: {
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
paddingHorizontal: 28,
|
|
58
|
+
},
|
|
59
|
+
emptyStateIconCircle: {
|
|
60
|
+
width: 132,
|
|
61
|
+
height: 132,
|
|
62
|
+
borderRadius: 66,
|
|
63
|
+
backgroundColor: '#E7EDF3',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
marginBottom: 18,
|
|
67
|
+
},
|
|
68
|
+
emptyStateTitle: {
|
|
69
|
+
fontSize: 18,
|
|
70
|
+
color: '#334155',
|
|
71
|
+
fontWeight: '400',
|
|
72
|
+
marginBottom: 6,
|
|
73
|
+
textAlign: 'center',
|
|
74
|
+
},
|
|
75
|
+
emptyStateSubtitle: {
|
|
76
|
+
fontSize: 14,
|
|
77
|
+
color: '#64748B',
|
|
78
|
+
textAlign: 'center',
|
|
79
|
+
lineHeight: 20,
|
|
80
|
+
},
|
|
81
|
+
dateContainer: {
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
marginVertical: 14,
|
|
84
|
+
},
|
|
85
|
+
dateText: {
|
|
86
|
+
backgroundColor: '#D9D4CD',
|
|
87
|
+
color: '#73808F',
|
|
88
|
+
fontSize: 12,
|
|
89
|
+
paddingHorizontal: 11,
|
|
90
|
+
paddingVertical: 3,
|
|
91
|
+
borderRadius: 12,
|
|
92
|
+
},
|
|
93
|
+
messageContainer: {
|
|
94
|
+
marginVertical: 2,
|
|
95
|
+
marginHorizontal: 12,
|
|
96
|
+
},
|
|
97
|
+
userMessage: {
|
|
98
|
+
alignItems: 'flex-end',
|
|
99
|
+
},
|
|
100
|
+
otherMessage: {
|
|
101
|
+
alignItems: 'flex-start',
|
|
102
|
+
},
|
|
103
|
+
messageBubble: {
|
|
104
|
+
maxWidth: '80%',
|
|
105
|
+
paddingHorizontal: 11,
|
|
106
|
+
paddingTop: 8,
|
|
107
|
+
paddingBottom: 7,
|
|
108
|
+
borderRadius: 14,
|
|
109
|
+
shadowColor: '#000',
|
|
110
|
+
shadowOffset: {
|
|
111
|
+
width: 0,
|
|
112
|
+
height: 1,
|
|
113
|
+
},
|
|
114
|
+
shadowOpacity: 0.06,
|
|
115
|
+
shadowRadius: 1.5,
|
|
116
|
+
elevation: 1,
|
|
117
|
+
},
|
|
118
|
+
userBubble: {
|
|
119
|
+
backgroundColor: '#D8F3C1',
|
|
120
|
+
borderBottomRightRadius: 4,
|
|
121
|
+
},
|
|
122
|
+
otherBubble: {
|
|
123
|
+
backgroundColor: '#FFFFFF',
|
|
124
|
+
borderBottomLeftRadius: 4,
|
|
125
|
+
},
|
|
126
|
+
messageText: {
|
|
127
|
+
fontSize: 16,
|
|
128
|
+
lineHeight: 21,
|
|
129
|
+
fontWeight: '400',
|
|
130
|
+
},
|
|
131
|
+
userMessageText: {
|
|
132
|
+
color: '#111827',
|
|
133
|
+
},
|
|
134
|
+
otherMessageText: {
|
|
135
|
+
color: '#111827',
|
|
136
|
+
},
|
|
137
|
+
messageTime: {
|
|
138
|
+
fontSize: 10,
|
|
139
|
+
marginTop: 4,
|
|
140
|
+
alignSelf: 'flex-end',
|
|
141
|
+
},
|
|
142
|
+
userMessageTime: {
|
|
143
|
+
color: '#718175',
|
|
144
|
+
},
|
|
145
|
+
otherMessageTime: {
|
|
146
|
+
color: '#8893A0',
|
|
147
|
+
},
|
|
148
|
+
inputContainer: {
|
|
149
|
+
backgroundColor: '#F2F4F6',
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
paddingHorizontal: 10,
|
|
153
|
+
paddingTop: 8,
|
|
154
|
+
borderTopWidth: 1,
|
|
155
|
+
borderTopColor: '#E6EBF1',
|
|
156
|
+
},
|
|
157
|
+
inputWrapper: {
|
|
158
|
+
flex: 1,
|
|
159
|
+
backgroundColor: '#FFFFFF',
|
|
160
|
+
borderRadius: 28,
|
|
161
|
+
paddingHorizontal: 15,
|
|
162
|
+
minHeight: 48,
|
|
163
|
+
justifyContent: 'center',
|
|
164
|
+
shadowColor: '#000',
|
|
165
|
+
shadowOffset: {
|
|
166
|
+
width: 0,
|
|
167
|
+
height: 1,
|
|
168
|
+
},
|
|
169
|
+
shadowOpacity: 0.04,
|
|
170
|
+
shadowRadius: 1.5,
|
|
171
|
+
elevation: 0,
|
|
172
|
+
},
|
|
173
|
+
textInput: {
|
|
174
|
+
fontSize: 17,
|
|
175
|
+
color: '#2A3440',
|
|
176
|
+
paddingVertical: 10,
|
|
177
|
+
borderWidth: 0,
|
|
178
|
+
outlineStyle: 'none',
|
|
179
|
+
outlineWidth: 0,
|
|
180
|
+
outlineColor: 'transparent',
|
|
181
|
+
},
|
|
182
|
+
sendButton: {
|
|
183
|
+
width: 44,
|
|
184
|
+
height: 44,
|
|
185
|
+
borderRadius: 22,
|
|
186
|
+
marginLeft: 8,
|
|
187
|
+
alignItems: 'center',
|
|
188
|
+
justifyContent: 'center',
|
|
189
|
+
shadowColor: '#000',
|
|
190
|
+
shadowOffset: {
|
|
191
|
+
width: 0,
|
|
192
|
+
height: 1,
|
|
193
|
+
},
|
|
194
|
+
shadowOpacity: 0.08,
|
|
195
|
+
shadowRadius: 2,
|
|
196
|
+
elevation: 1,
|
|
197
|
+
},
|
|
198
|
+
sendButtonActive: {
|
|
199
|
+
backgroundColor: '#2ECF6E',
|
|
200
|
+
},
|
|
201
|
+
sendButtonInactive: {
|
|
202
|
+
backgroundColor: '#E7EBEF',
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
export default styles;
|