rn-erxes-sdk 0.1.13 → 0.1.15
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/README.md +17 -17
- package/lib/commonjs/App.js +60 -17
- package/lib/commonjs/App.js.map +1 -1
- package/lib/commonjs/Widget.js +36 -29
- package/lib/commonjs/Widget.js.map +1 -1
- package/lib/commonjs/assets/images/index.js +2 -1
- package/lib/commonjs/assets/images/index.js.map +1 -1
- package/lib/commonjs/assets/images/logo.png +0 -0
- package/lib/commonjs/components/Avatar.js +60 -0
- package/lib/commonjs/components/Avatar.js.map +1 -0
- package/lib/commonjs/components/InputTools.js +4 -1
- package/lib/commonjs/components/InputTools.js.map +1 -1
- package/lib/commonjs/context/Context.js +11 -0
- package/lib/commonjs/context/Context.js.map +1 -0
- package/lib/commonjs/graphql/apolloClient.js +2 -0
- package/lib/commonjs/graphql/apolloClient.js.map +1 -1
- package/lib/commonjs/graphql/mutation.js +150 -1
- package/lib/commonjs/graphql/mutation.js.map +1 -1
- package/lib/commonjs/graphql/query.js +0 -9
- package/lib/commonjs/graphql/query.js.map +1 -1
- package/lib/commonjs/icons/icons.js +96 -0
- package/lib/commonjs/icons/icons.js.map +1 -0
- package/lib/commonjs/screen/conversation/ConversationDetail.js +106 -69
- package/lib/commonjs/screen/conversation/ConversationDetail.js.map +1 -1
- package/lib/commonjs/screen/conversation/Conversations.js +22 -41
- package/lib/commonjs/screen/conversation/Conversations.js.map +1 -1
- package/lib/commonjs/screen/conversation/Message.js +5 -17
- package/lib/commonjs/screen/conversation/Message.js.map +1 -1
- package/lib/commonjs/screen/greetings/Greetings.js +27 -10
- package/lib/commonjs/screen/greetings/Greetings.js.map +1 -1
- package/lib/commonjs/screen/greetings/Social.js +1 -1
- package/lib/commonjs/screen/greetings/Social.js.map +1 -1
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/utils/utils.js +11 -1
- package/lib/commonjs/utils/utils.js.map +1 -1
- package/lib/module/App.js +60 -17
- package/lib/module/App.js.map +1 -1
- package/lib/module/Widget.js +36 -29
- package/lib/module/Widget.js.map +1 -1
- package/lib/module/assets/images/index.js +2 -1
- package/lib/module/assets/images/index.js.map +1 -1
- package/lib/module/assets/images/logo.png +0 -0
- package/lib/module/components/Avatar.js +52 -0
- package/lib/module/components/Avatar.js.map +1 -0
- package/lib/module/components/InputTools.js +5 -2
- package/lib/module/components/InputTools.js.map +1 -1
- package/lib/module/context/Context.js +4 -0
- package/lib/module/context/Context.js.map +1 -0
- package/lib/module/graphql/apolloClient.js +2 -0
- package/lib/module/graphql/apolloClient.js.map +1 -1
- package/lib/module/graphql/mutation.js +148 -1
- package/lib/module/graphql/mutation.js.map +1 -1
- package/lib/module/graphql/query.js +0 -9
- package/lib/module/graphql/query.js.map +1 -1
- package/lib/module/icons/icons.js +85 -0
- package/lib/module/icons/icons.js.map +1 -0
- package/lib/module/screen/conversation/ConversationDetail.js +109 -72
- package/lib/module/screen/conversation/ConversationDetail.js.map +1 -1
- package/lib/module/screen/conversation/Conversations.js +21 -42
- package/lib/module/screen/conversation/Conversations.js.map +1 -1
- package/lib/module/screen/conversation/Message.js +7 -19
- package/lib/module/screen/conversation/Message.js.map +1 -1
- package/lib/module/screen/greetings/Greetings.js +25 -10
- package/lib/module/screen/greetings/Greetings.js.map +1 -1
- package/lib/module/screen/greetings/Social.js +1 -1
- package/lib/module/screen/greetings/Social.js.map +1 -1
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/utils.js +9 -0
- package/lib/module/utils/utils.js.map +1 -1
- package/lib/typescript/App.d.ts +1 -3
- package/lib/typescript/App.d.ts.map +1 -1
- package/lib/typescript/Widget.d.ts.map +1 -1
- package/lib/typescript/assets/images/index.d.ts +1 -0
- package/lib/typescript/assets/images/index.d.ts.map +1 -1
- package/lib/typescript/components/Avatar.d.ts +4 -0
- package/lib/typescript/components/Avatar.d.ts.map +1 -0
- package/lib/typescript/components/InputTools.d.ts.map +1 -1
- package/lib/typescript/context/Context.d.ts +4 -0
- package/lib/typescript/context/Context.d.ts.map +1 -0
- package/lib/typescript/graphql/apolloClient.d.ts.map +1 -1
- package/lib/typescript/graphql/mutation.d.ts +3 -1
- package/lib/typescript/graphql/mutation.d.ts.map +1 -1
- package/lib/typescript/graphql/query.d.ts.map +1 -1
- package/lib/typescript/icons/icons.d.ts +28 -0
- package/lib/typescript/icons/icons.d.ts.map +1 -0
- package/lib/typescript/screen/conversation/ConversationDetail.d.ts +1 -1
- package/lib/typescript/screen/conversation/ConversationDetail.d.ts.map +1 -1
- package/lib/typescript/screen/conversation/Conversations.d.ts +1 -1
- package/lib/typescript/screen/conversation/Conversations.d.ts.map +1 -1
- package/lib/typescript/screen/conversation/Message.d.ts.map +1 -1
- package/lib/typescript/screen/greetings/Greetings.d.ts +1 -1
- package/lib/typescript/screen/greetings/Greetings.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +12 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/utils.d.ts +1 -0
- package/lib/typescript/utils/utils.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/App.tsx +63 -20
- package/src/Widget.tsx +52 -33
- package/src/assets/images/index.ts +1 -0
- package/src/assets/images/logo.png +0 -0
- package/src/components/Avatar.tsx +56 -0
- package/src/components/InputTools.tsx +3 -8
- package/src/context/Context.ts +5 -0
- package/src/graphql/apolloClient.ts +1 -0
- package/src/graphql/mutation.ts +158 -1
- package/src/graphql/query.ts +0 -9
- package/src/icons/icons.tsx +106 -0
- package/src/screen/conversation/ConversationDetail.tsx +142 -100
- package/src/screen/conversation/Conversations.tsx +14 -36
- package/src/screen/conversation/Message.tsx +6 -23
- package/src/screen/greetings/Greetings.tsx +30 -10
- package/src/screen/greetings/Social.tsx +1 -1
- package/src/types.ts +11 -0
- package/src/utils/utils.tsx +9 -0
- package/lib/commonjs/FAQ.js +0 -177
- package/lib/commonjs/FAQ.js.map +0 -1
- package/lib/module/FAQ.js +0 -167
- package/lib/module/FAQ.js.map +0 -1
- package/lib/typescript/FAQ.d.ts +0 -4
- package/lib/typescript/FAQ.d.ts.map +0 -1
- package/src/FAQ.tsx +0 -171
package/src/graphql/mutation.ts
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
2
|
|
|
3
|
+
const userDetailFields = `
|
|
4
|
+
avatar
|
|
5
|
+
fullName
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
const messageFields = `
|
|
9
|
+
_id
|
|
10
|
+
conversationId
|
|
11
|
+
customerId
|
|
12
|
+
user {
|
|
13
|
+
_id
|
|
14
|
+
details {
|
|
15
|
+
${userDetailFields}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
content
|
|
19
|
+
createdAt
|
|
20
|
+
internal
|
|
21
|
+
fromBot
|
|
22
|
+
contentType
|
|
23
|
+
videoCallData {
|
|
24
|
+
url
|
|
25
|
+
status
|
|
26
|
+
}
|
|
27
|
+
engageData {
|
|
28
|
+
content
|
|
29
|
+
kind
|
|
30
|
+
sentAs
|
|
31
|
+
messageId
|
|
32
|
+
brandId
|
|
33
|
+
}
|
|
34
|
+
botData
|
|
35
|
+
messengerAppData
|
|
36
|
+
attachments {
|
|
37
|
+
url
|
|
38
|
+
name
|
|
39
|
+
size
|
|
40
|
+
type
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
3
44
|
const connect = gql`
|
|
4
45
|
mutation connect(
|
|
5
46
|
$brandCode: String!
|
|
@@ -120,4 +161,120 @@ const widgetsSaveCustomerGetNotified = gql`
|
|
|
120
161
|
}
|
|
121
162
|
`;
|
|
122
163
|
|
|
123
|
-
|
|
164
|
+
const saveBrowserInfo = `
|
|
165
|
+
mutation widgetsSaveBrowserInfo($customerId: String $visitorId: String $browserInfo: JSON!) {
|
|
166
|
+
widgetsSaveBrowserInfo(customerId: $customerId visitorId: $visitorId browserInfo: $browserInfo) {
|
|
167
|
+
${messageFields}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
|
|
172
|
+
const customersAdd = gql`
|
|
173
|
+
mutation customersAdd(
|
|
174
|
+
$state: String
|
|
175
|
+
$avatar: String
|
|
176
|
+
$firstName: String
|
|
177
|
+
$lastName: String
|
|
178
|
+
$middleName: String
|
|
179
|
+
$sex: Int
|
|
180
|
+
$birthDate: Date
|
|
181
|
+
$primaryEmail: String
|
|
182
|
+
$primaryPhone: String
|
|
183
|
+
$phones: [String]
|
|
184
|
+
$emails: [String]
|
|
185
|
+
$ownerId: String
|
|
186
|
+
$position: String
|
|
187
|
+
$department: String
|
|
188
|
+
$leadStatus: String
|
|
189
|
+
$hasAuthority: String
|
|
190
|
+
$description: String
|
|
191
|
+
$isSubscribed: String
|
|
192
|
+
$links: JSON
|
|
193
|
+
$customFieldsData: JSON
|
|
194
|
+
$code: String
|
|
195
|
+
$emailValidationStatus: String
|
|
196
|
+
$phoneValidationStatus: String
|
|
197
|
+
) {
|
|
198
|
+
customersAdd(
|
|
199
|
+
state: $state
|
|
200
|
+
avatar: $avatar
|
|
201
|
+
firstName: $firstName
|
|
202
|
+
lastName: $lastName
|
|
203
|
+
middleName: $middleName
|
|
204
|
+
sex: $sex
|
|
205
|
+
birthDate: $birthDate
|
|
206
|
+
primaryEmail: $primaryEmail
|
|
207
|
+
primaryPhone: $primaryPhone
|
|
208
|
+
phones: $phones
|
|
209
|
+
emails: $emails
|
|
210
|
+
ownerId: $ownerId
|
|
211
|
+
position: $position
|
|
212
|
+
department: $department
|
|
213
|
+
leadStatus: $leadStatus
|
|
214
|
+
hasAuthority: $hasAuthority
|
|
215
|
+
description: $description
|
|
216
|
+
isSubscribed: $isSubscribed
|
|
217
|
+
links: $links
|
|
218
|
+
customFieldsData: $customFieldsData
|
|
219
|
+
code: $code
|
|
220
|
+
emailValidationStatus: $emailValidationStatus
|
|
221
|
+
phoneValidationStatus: $phoneValidationStatus
|
|
222
|
+
) {
|
|
223
|
+
_id
|
|
224
|
+
firstName
|
|
225
|
+
middleName
|
|
226
|
+
lastName
|
|
227
|
+
avatar
|
|
228
|
+
sex
|
|
229
|
+
birthDate
|
|
230
|
+
primaryEmail
|
|
231
|
+
emails
|
|
232
|
+
primaryPhone
|
|
233
|
+
phones
|
|
234
|
+
state
|
|
235
|
+
visitorContactInfo
|
|
236
|
+
modifiedAt
|
|
237
|
+
position
|
|
238
|
+
department
|
|
239
|
+
leadStatus
|
|
240
|
+
hasAuthority
|
|
241
|
+
description
|
|
242
|
+
isSubscribed
|
|
243
|
+
code
|
|
244
|
+
emailValidationStatus
|
|
245
|
+
phoneValidationStatus
|
|
246
|
+
score
|
|
247
|
+
isOnline
|
|
248
|
+
lastSeenAt
|
|
249
|
+
sessionCount
|
|
250
|
+
links
|
|
251
|
+
ownerId
|
|
252
|
+
owner {
|
|
253
|
+
_id
|
|
254
|
+
details {
|
|
255
|
+
fullName
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
integrationId
|
|
259
|
+
createdAt
|
|
260
|
+
remoteAddress
|
|
261
|
+
location
|
|
262
|
+
customFieldsData
|
|
263
|
+
trackedData
|
|
264
|
+
tagIds
|
|
265
|
+
getTags {
|
|
266
|
+
_id
|
|
267
|
+
name
|
|
268
|
+
colorCode
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
`;
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
connect,
|
|
276
|
+
widgetsInsertMessage,
|
|
277
|
+
widgetsSaveCustomerGetNotified,
|
|
278
|
+
saveBrowserInfo,
|
|
279
|
+
customersAdd,
|
|
280
|
+
};
|
package/src/graphql/query.ts
CHANGED
|
@@ -127,16 +127,7 @@ const widgetsConversationDetail = gql`
|
|
|
127
127
|
status
|
|
128
128
|
__typename
|
|
129
129
|
}
|
|
130
|
-
engageData {
|
|
131
|
-
content
|
|
132
|
-
kind
|
|
133
|
-
sentAs
|
|
134
|
-
messageId
|
|
135
|
-
brandId
|
|
136
|
-
__typename
|
|
137
|
-
}
|
|
138
130
|
botData
|
|
139
|
-
messengerAppData
|
|
140
131
|
attachments {
|
|
141
132
|
url
|
|
142
133
|
name
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { Svg, Path } from 'react-native-svg';
|
|
4
|
+
|
|
5
|
+
export function ArrowLeft({
|
|
6
|
+
size,
|
|
7
|
+
}: {
|
|
8
|
+
style?: StyleProp<ViewStyle>;
|
|
9
|
+
size?: string | number;
|
|
10
|
+
strokeWidth?: number;
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<Svg width={size || 32} height={size || 32} fill="none">
|
|
14
|
+
<Path
|
|
15
|
+
stroke="#fff"
|
|
16
|
+
strokeLinecap="round"
|
|
17
|
+
strokeLinejoin="round"
|
|
18
|
+
strokeWidth={1.5}
|
|
19
|
+
d="M20 12H4m0 0 6-6m-6 6 6 6"
|
|
20
|
+
/>
|
|
21
|
+
</Svg>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function CheckIcon({
|
|
26
|
+
size,
|
|
27
|
+
}: {
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
size?: string | number;
|
|
30
|
+
strokeWidth?: number;
|
|
31
|
+
}) {
|
|
32
|
+
return (
|
|
33
|
+
<Svg width={size || 32} height={size || 32} fill="none">
|
|
34
|
+
<Path
|
|
35
|
+
stroke="#1C274C"
|
|
36
|
+
strokeLinecap="round"
|
|
37
|
+
strokeLinejoin="round"
|
|
38
|
+
strokeWidth={1.5}
|
|
39
|
+
d="m7 12.9 3.143 3.6L18 7.5"
|
|
40
|
+
/>
|
|
41
|
+
</Svg>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function PlusIcon({
|
|
46
|
+
size,
|
|
47
|
+
}: {
|
|
48
|
+
style?: StyleProp<ViewStyle>;
|
|
49
|
+
size?: string | number;
|
|
50
|
+
strokeWidth?: number;
|
|
51
|
+
}) {
|
|
52
|
+
return (
|
|
53
|
+
<Svg width={size || 32} height={size || 32} fill="none">
|
|
54
|
+
<Path
|
|
55
|
+
fill="#212121"
|
|
56
|
+
fillRule="evenodd"
|
|
57
|
+
d="M11 11V3h2v8h8v2h-8v8h-2v-8H3v-2h8Z"
|
|
58
|
+
clipRule="evenodd"
|
|
59
|
+
/>
|
|
60
|
+
</Svg>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function SendIcon({
|
|
65
|
+
size,
|
|
66
|
+
}: {
|
|
67
|
+
style?: StyleProp<ViewStyle>;
|
|
68
|
+
size?: string | number;
|
|
69
|
+
strokeWidth?: number;
|
|
70
|
+
}) {
|
|
71
|
+
return (
|
|
72
|
+
<Svg width={size || 32} height={size || 32} fill="none">
|
|
73
|
+
<Path
|
|
74
|
+
stroke="#1C274C"
|
|
75
|
+
strokeWidth={1.5}
|
|
76
|
+
d="m18.636 15.67 1.716-5.15c1.5-4.498 2.25-6.747 1.062-7.934-1.187-1.187-3.436-.438-7.935 1.062L8.33 5.364C4.7 6.574 2.885 7.18 2.37 8.067a2.717 2.717 0 0 0 0 2.73c.515.888 2.33 1.493 5.96 2.704.584.194.875.291 1.119.454.236.158.439.361.597.597.163.244.26.535.454 1.118 1.21 3.63 1.816 5.446 2.703 5.962.844.49 1.887.49 2.731 0 .887-.516 1.492-2.331 2.703-5.962Z"
|
|
77
|
+
/>
|
|
78
|
+
<Path
|
|
79
|
+
stroke="#1C274C"
|
|
80
|
+
strokeLinecap="round"
|
|
81
|
+
strokeWidth={1.5}
|
|
82
|
+
d="m17.789 6.21-4.21 4.165"
|
|
83
|
+
/>
|
|
84
|
+
</Svg>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function CloseIcon({
|
|
89
|
+
size,
|
|
90
|
+
}: {
|
|
91
|
+
style?: StyleProp<ViewStyle>;
|
|
92
|
+
size?: string | number;
|
|
93
|
+
strokeWidth?: number;
|
|
94
|
+
}) {
|
|
95
|
+
return (
|
|
96
|
+
<Svg width={size || 32} height={size || 32} fill="none">
|
|
97
|
+
<Path
|
|
98
|
+
stroke="#fff"
|
|
99
|
+
strokeLinecap="round"
|
|
100
|
+
strokeLinejoin="round"
|
|
101
|
+
strokeWidth={1.5}
|
|
102
|
+
d="M5.001 5 19 19M5 19 18.999 5"
|
|
103
|
+
/>
|
|
104
|
+
</Svg>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
@@ -11,57 +11,88 @@ import {
|
|
|
11
11
|
TouchableWithoutFeedback,
|
|
12
12
|
Keyboard,
|
|
13
13
|
Image,
|
|
14
|
+
SafeAreaView,
|
|
14
15
|
} from 'react-native';
|
|
15
|
-
import React, { useEffect } from 'react';
|
|
16
|
-
import { useMutation, useQuery
|
|
16
|
+
import React, { useContext, useEffect } from 'react';
|
|
17
|
+
import { useMutation, useQuery } from '@apollo/client';
|
|
17
18
|
import { widgetsConversationDetail } from '../../graphql/query';
|
|
18
|
-
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
19
19
|
import Message from './Message';
|
|
20
20
|
import InputTools from '../../components/InputTools';
|
|
21
21
|
import { widgetsInsertMessage } from '../../graphql/mutation';
|
|
22
22
|
import { conversationMessageInserted } from '../../graphql/subscription';
|
|
23
23
|
import { getAttachmentUrl } from '../../utils/utils';
|
|
24
|
-
import
|
|
24
|
+
import AppContext from '../../context/Context';
|
|
25
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
26
|
+
import { ArrowLeft } from '../../icons/icons';
|
|
25
27
|
|
|
26
|
-
const ConversationDetail = (
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const ConversationDetail = () => {
|
|
29
|
+
const value = useContext(AppContext);
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
brand,
|
|
33
|
+
conversationId,
|
|
34
|
+
bgColor,
|
|
35
|
+
integrationId,
|
|
36
|
+
customerId,
|
|
37
|
+
visitorId,
|
|
38
|
+
setConnection,
|
|
39
|
+
} = value;
|
|
30
40
|
|
|
31
41
|
const [messages, setMessages] = React.useState<any>([]);
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
variables: {
|
|
35
|
-
_id,
|
|
36
|
-
integrationId,
|
|
37
|
-
},
|
|
38
|
-
fetchPolicy: 'network-only',
|
|
39
|
-
skip: !_id,
|
|
40
|
-
});
|
|
43
|
+
// console.log(messages);
|
|
41
44
|
|
|
42
|
-
const { data
|
|
43
|
-
|
|
45
|
+
const { data, loading, subscribeToMore } = useQuery(
|
|
46
|
+
widgetsConversationDetail,
|
|
44
47
|
{
|
|
45
|
-
variables: {
|
|
48
|
+
variables: {
|
|
49
|
+
_id: conversationId,
|
|
50
|
+
integrationId,
|
|
51
|
+
},
|
|
46
52
|
fetchPolicy: 'network-only',
|
|
47
|
-
skip: !
|
|
53
|
+
skip: !conversationId,
|
|
48
54
|
}
|
|
49
55
|
);
|
|
50
56
|
|
|
51
57
|
useEffect(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
const unSubsToMore = subscribeToMore({
|
|
59
|
+
document: conversationMessageInserted,
|
|
60
|
+
variables: { _id: conversationId },
|
|
61
|
+
updateQuery: (prev, { subscriptionData }) => {
|
|
62
|
+
const message = subscriptionData.data.conversationMessageInserted;
|
|
63
|
+
const tempWidgetsConversationDetail =
|
|
64
|
+
prev.widgetsConversationDetail || {};
|
|
65
|
+
const tempMessages = tempWidgetsConversationDetail?.messages || [];
|
|
66
|
+
|
|
67
|
+
// check whether or not already inserted
|
|
68
|
+
const prevEntry = tempMessages.find((m: any) => m._id === message?._id);
|
|
69
|
+
|
|
70
|
+
if (prevEntry) {
|
|
71
|
+
return prev;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// do not show internal or bot messages
|
|
75
|
+
if (message.internal || message.fromBot) {
|
|
76
|
+
return prev;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// add new message to messages list
|
|
80
|
+
const next = {
|
|
81
|
+
...prev,
|
|
82
|
+
widgetsConversationDetail: {
|
|
83
|
+
...tempWidgetsConversationDetail,
|
|
84
|
+
messages: [...tempMessages, message],
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return next;
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return () => {
|
|
93
|
+
unSubsToMore;
|
|
94
|
+
};
|
|
95
|
+
}, [conversationId, subscribeToMore]);
|
|
65
96
|
|
|
66
97
|
useEffect(() => {
|
|
67
98
|
if (data?.widgetsConversationDetail?.messages) {
|
|
@@ -80,7 +111,7 @@ const ConversationDetail = (props: any) => {
|
|
|
80
111
|
integrationId,
|
|
81
112
|
customerId,
|
|
82
113
|
visitorId,
|
|
83
|
-
conversationId
|
|
114
|
+
conversationId,
|
|
84
115
|
contentType: 'text',
|
|
85
116
|
message: text,
|
|
86
117
|
},
|
|
@@ -90,17 +121,21 @@ const ConversationDetail = (props: any) => {
|
|
|
90
121
|
return console.log(res.errors);
|
|
91
122
|
}
|
|
92
123
|
if (res.data.widgetsInsertMessage) {
|
|
93
|
-
|
|
94
|
-
if (!cachedCustomerId) {
|
|
124
|
+
if (!customerId) {
|
|
95
125
|
const tempCustomerId = res.data.widgetsInsertMessage.customerId;
|
|
96
|
-
|
|
126
|
+
const jsonValue = JSON.stringify(tempCustomerId);
|
|
127
|
+
AsyncStorage.setItem('cachedCustomerId', jsonValue);
|
|
128
|
+
setConnection({
|
|
129
|
+
visitorId,
|
|
130
|
+
cachedCustomerId: tempCustomerId,
|
|
131
|
+
});
|
|
97
132
|
}
|
|
98
133
|
let shouldAdd = messages?.length === 0;
|
|
99
134
|
if (!shouldAdd) {
|
|
100
|
-
shouldAdd = res.data.widgetsInsertMessage._id !==
|
|
135
|
+
shouldAdd = res.data.widgetsInsertMessage._id !== messages[0]._id;
|
|
101
136
|
}
|
|
102
137
|
if (shouldAdd) {
|
|
103
|
-
const newArray = [res.data.widgetsInsertMessage, ...
|
|
138
|
+
const newArray = [res.data.widgetsInsertMessage, ...messages];
|
|
104
139
|
setMessages(newArray);
|
|
105
140
|
}
|
|
106
141
|
}
|
|
@@ -142,7 +177,6 @@ const ConversationDetail = (props: any) => {
|
|
|
142
177
|
return (
|
|
143
178
|
<View style={{ flex: 1 }}>
|
|
144
179
|
<Header
|
|
145
|
-
navigation={navigation}
|
|
146
180
|
brand={brand}
|
|
147
181
|
bgColor={bgColor}
|
|
148
182
|
users={data?.widgetsConversationDetail?.participatedUsers}
|
|
@@ -165,25 +199,83 @@ const ConversationDetail = (props: any) => {
|
|
|
165
199
|
export default ConversationDetail;
|
|
166
200
|
|
|
167
201
|
const Header = (props: any) => {
|
|
168
|
-
const {
|
|
202
|
+
const { brand, bgColor, users } = props;
|
|
203
|
+
|
|
204
|
+
const value = useContext(AppContext);
|
|
169
205
|
|
|
170
|
-
const
|
|
206
|
+
const { setConversationId } = value;
|
|
171
207
|
|
|
172
208
|
if (users?.length > 0) {
|
|
173
|
-
|
|
209
|
+
let source;
|
|
210
|
+
if (users[0]?.details?.avatar) {
|
|
211
|
+
source = { uri: getAttachmentUrl(users[0]?.details?.avatar) };
|
|
212
|
+
} else {
|
|
213
|
+
source = require('../../assets/images/avatar.png');
|
|
214
|
+
}
|
|
174
215
|
return (
|
|
216
|
+
<SafeAreaView
|
|
217
|
+
style={{
|
|
218
|
+
backgroundColor: bgColor,
|
|
219
|
+
}}
|
|
220
|
+
>
|
|
221
|
+
<View
|
|
222
|
+
style={{
|
|
223
|
+
flexDirection: 'row',
|
|
224
|
+
alignItems: 'center',
|
|
225
|
+
paddingBottom: 20,
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<TouchableOpacity
|
|
229
|
+
onPress={() => {
|
|
230
|
+
setConversationId(null);
|
|
231
|
+
}}
|
|
232
|
+
style={[
|
|
233
|
+
styles.backStyle,
|
|
234
|
+
{
|
|
235
|
+
backgroundColor: '#2F1F69',
|
|
236
|
+
},
|
|
237
|
+
]}
|
|
238
|
+
>
|
|
239
|
+
<ArrowLeft size={24} />
|
|
240
|
+
</TouchableOpacity>
|
|
241
|
+
<View
|
|
242
|
+
style={[
|
|
243
|
+
styles.title,
|
|
244
|
+
{
|
|
245
|
+
marginLeft: 10,
|
|
246
|
+
alignItems: 'center',
|
|
247
|
+
flex: 1,
|
|
248
|
+
},
|
|
249
|
+
]}
|
|
250
|
+
>
|
|
251
|
+
<Image source={source} style={styles.avatar} resizeMode="stretch" />
|
|
252
|
+
<View style={{ marginLeft: 10 }}>
|
|
253
|
+
<Text style={{ fontWeight: '600' }}>
|
|
254
|
+
{users[0]?.details?.fullName}
|
|
255
|
+
</Text>
|
|
256
|
+
</View>
|
|
257
|
+
</View>
|
|
258
|
+
</View>
|
|
259
|
+
</SafeAreaView>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<SafeAreaView
|
|
265
|
+
style={{
|
|
266
|
+
backgroundColor: bgColor,
|
|
267
|
+
}}
|
|
268
|
+
>
|
|
175
269
|
<View
|
|
176
270
|
style={{
|
|
177
271
|
flexDirection: 'row',
|
|
178
272
|
alignItems: 'center',
|
|
179
273
|
paddingBottom: 20,
|
|
180
|
-
backgroundColor: bgColor || 'green',
|
|
181
|
-
paddingTop: insets.top,
|
|
182
274
|
}}
|
|
183
275
|
>
|
|
184
276
|
<TouchableOpacity
|
|
185
277
|
onPress={() => {
|
|
186
|
-
|
|
278
|
+
setConversationId(null);
|
|
187
279
|
}}
|
|
188
280
|
style={[
|
|
189
281
|
styles.backStyle,
|
|
@@ -192,63 +284,13 @@ const Header = (props: any) => {
|
|
|
192
284
|
},
|
|
193
285
|
]}
|
|
194
286
|
>
|
|
195
|
-
<
|
|
287
|
+
<ArrowLeft size={24} />
|
|
196
288
|
</TouchableOpacity>
|
|
197
|
-
<View
|
|
198
|
-
style={
|
|
199
|
-
styles.title,
|
|
200
|
-
{
|
|
201
|
-
marginLeft: 10,
|
|
202
|
-
alignItems: 'center',
|
|
203
|
-
flex: 1,
|
|
204
|
-
},
|
|
205
|
-
]}
|
|
206
|
-
>
|
|
207
|
-
<Image
|
|
208
|
-
source={{ uri: url, cache: 'force-cache' }}
|
|
209
|
-
style={styles.avatar}
|
|
210
|
-
resizeMode="stretch"
|
|
211
|
-
/>
|
|
212
|
-
<View style={{ marginLeft: 10 }}>
|
|
213
|
-
<Text style={{ fontWeight: '600' }}>
|
|
214
|
-
{users[0]?.details?.fullName}
|
|
215
|
-
</Text>
|
|
216
|
-
<Text style={{ color: '#686868' }}>
|
|
217
|
-
{users[0]?.details?.position}
|
|
218
|
-
</Text>
|
|
219
|
-
</View>
|
|
289
|
+
<View style={[styles.title]}>
|
|
290
|
+
<Text style={{ fontWeight: '600', fontSize: 16 }}>{brand?.name}</Text>
|
|
220
291
|
</View>
|
|
221
292
|
</View>
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return (
|
|
226
|
-
<View
|
|
227
|
-
style={{
|
|
228
|
-
flexDirection: 'row',
|
|
229
|
-
alignItems: 'center',
|
|
230
|
-
paddingBottom: 20,
|
|
231
|
-
backgroundColor: bgColor || 'green',
|
|
232
|
-
paddingTop: insets.top,
|
|
233
|
-
}}
|
|
234
|
-
>
|
|
235
|
-
<TouchableOpacity
|
|
236
|
-
onPress={() => {
|
|
237
|
-
navigation.goBack();
|
|
238
|
-
}}
|
|
239
|
-
style={[
|
|
240
|
-
styles.backStyle,
|
|
241
|
-
{
|
|
242
|
-
backgroundColor: '#2F1F69',
|
|
243
|
-
},
|
|
244
|
-
]}
|
|
245
|
-
>
|
|
246
|
-
<Text>A</Text>
|
|
247
|
-
</TouchableOpacity>
|
|
248
|
-
<View style={[styles.title]}>
|
|
249
|
-
<Text style={{ fontWeight: '600', fontSize: 16 }}>{brand?.name}</Text>
|
|
250
|
-
</View>
|
|
251
|
-
</View>
|
|
293
|
+
</SafeAreaView>
|
|
252
294
|
);
|
|
253
295
|
};
|
|
254
296
|
|
|
@@ -4,23 +4,23 @@ import {
|
|
|
4
4
|
Text,
|
|
5
5
|
FlatList,
|
|
6
6
|
StyleSheet,
|
|
7
|
-
Image,
|
|
8
7
|
TouchableOpacity,
|
|
9
8
|
RefreshControl,
|
|
10
9
|
} from 'react-native';
|
|
11
|
-
import React from 'react';
|
|
10
|
+
import React, { useContext } from 'react';
|
|
12
11
|
import { widgetsConversations } from '../../graphql/query';
|
|
13
12
|
import { useQuery } from '@apollo/client';
|
|
14
13
|
import dayjs from 'dayjs';
|
|
15
|
-
import images from '../../assets/images';
|
|
16
14
|
import FAB from '../../components/FAB';
|
|
17
|
-
import
|
|
15
|
+
import AppContext from '../../context/Context';
|
|
16
|
+
import Avatar from '../../components/Avatar';
|
|
17
|
+
import { PlusIcon } from '../../icons/icons';
|
|
18
18
|
|
|
19
|
-
const Conversations = (
|
|
20
|
-
const
|
|
21
|
-
props;
|
|
19
|
+
const Conversations = () => {
|
|
20
|
+
const value = useContext(AppContext);
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
const { customerId, visitorId, bgColor, integrationId, setConversationId } =
|
|
23
|
+
value;
|
|
24
24
|
|
|
25
25
|
const { data, loading, refetch } = useQuery(widgetsConversations, {
|
|
26
26
|
variables: {
|
|
@@ -45,31 +45,18 @@ const Conversations = (props: any) => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const renderItem = ({ item }: any) => {
|
|
48
|
-
let source = images.avatar;
|
|
49
48
|
let name = 'Support Staff';
|
|
50
49
|
if (item?.participatedUsers?.length > 0) {
|
|
51
|
-
source = {
|
|
52
|
-
uri: getAttachmentUrl(item?.participatedUsers[0]?.details?.avatar),
|
|
53
|
-
cache: 'only-if-cached',
|
|
54
|
-
};
|
|
55
50
|
name = item?.participatedUsers[0]?.details?.fullName;
|
|
56
51
|
}
|
|
57
52
|
return (
|
|
58
53
|
<TouchableOpacity
|
|
59
54
|
style={styles.itemContainer}
|
|
60
55
|
onPress={() => {
|
|
61
|
-
|
|
62
|
-
// navigation.navigate('ConversationDetail', {
|
|
63
|
-
// _id: item._id,
|
|
64
|
-
// integrationId,
|
|
65
|
-
// customerId,
|
|
66
|
-
// visitorId,
|
|
67
|
-
// bgColor,
|
|
68
|
-
// brand,
|
|
69
|
-
// });
|
|
56
|
+
setConversationId(item._id);
|
|
70
57
|
}}
|
|
71
58
|
>
|
|
72
|
-
<
|
|
59
|
+
<Avatar user={item?.participatedUsers[0]} bgColor={bgColor} />
|
|
73
60
|
<View style={{ flex: 1, marginLeft: 10 }}>
|
|
74
61
|
<Text style={{ fontWeight: '500' }}>{name}</Text>
|
|
75
62
|
<Text style={{ color: '#686868' }}>{item?.content}</Text>
|
|
@@ -125,20 +112,11 @@ const Conversations = (props: any) => {
|
|
|
125
112
|
ItemSeparatorComponent={seperator}
|
|
126
113
|
/>
|
|
127
114
|
<FAB
|
|
128
|
-
onPress={
|
|
129
|
-
()
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
// navigation.navigate('ConversationDetail', {
|
|
133
|
-
// _id: '',
|
|
134
|
-
// integrationId,
|
|
135
|
-
// customerId,
|
|
136
|
-
// bgColor,
|
|
137
|
-
// brand,
|
|
138
|
-
// })
|
|
139
|
-
}
|
|
115
|
+
onPress={() => {
|
|
116
|
+
setConversationId('');
|
|
117
|
+
}}
|
|
140
118
|
backgroundColor={bgColor}
|
|
141
|
-
icon={
|
|
119
|
+
icon={<PlusIcon size={24} />}
|
|
142
120
|
/>
|
|
143
121
|
</View>
|
|
144
122
|
);
|