react-native-srschat 0.1.42 → 0.1.44
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 +18 -0
- package/lib/commonjs/components/email.js +50 -24
- package/lib/commonjs/components/email.js.map +1 -1
- package/lib/commonjs/components/productCard.js +2 -6
- package/lib/commonjs/components/productCard.js.map +1 -1
- package/lib/commonjs/layout/welcome.js +17 -14
- package/lib/commonjs/layout/welcome.js.map +1 -1
- package/lib/commonjs/utils/audioRecorder.js +49 -21
- package/lib/commonjs/utils/audioRecorder.js.map +1 -1
- package/lib/module/components/email.js +51 -25
- package/lib/module/components/email.js.map +1 -1
- package/lib/module/components/productCard.js +2 -6
- package/lib/module/components/productCard.js.map +1 -1
- package/lib/module/layout/welcome.js +17 -14
- package/lib/module/layout/welcome.js.map +1 -1
- package/lib/module/utils/audioRecorder.js +50 -22
- package/lib/module/utils/audioRecorder.js.map +1 -1
- package/lib/typescript/components/email.d.ts +1 -0
- package/lib/typescript/components/email.d.ts.map +1 -1
- package/lib/typescript/layout/welcome.d.ts +1 -0
- package/lib/typescript/layout/welcome.d.ts.map +1 -1
- package/lib/typescript/utils/audioRecorder.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/components/email.js +113 -55
- package/src/components/productCard.js +2 -2
- package/src/layout/welcome.js +24 -26
- package/src/utils/audioRecorder.js +52 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useContext","View","Text","
|
|
1
|
+
{"version":3,"names":["React","useContext","View","Text","TouchableOpacity","ScrollView","StyleSheet","Ionicons","AppContext","WelcomeInput","ButtonComponent","CloudinaryImage","Welcome","panHandlers","setShowModal","uiConfig","onProductCardClick","onAddToCartClick","handleClick","showIcon","setToggleChat","createElement","style","styles","container","parentContainer","topContainer","topHeader","logoContainer","cldImg","imageStyle","width","height","onPress","collapseButton","name","size","color","blueContainer","welcomeHeader","welcomeBody2","textBeta","bottomContainer","welcomeBody","create","flex","flexGrow","backgroundColor","paddingTop","paddingBottom","flexDirection","alignItems","paddingHorizontal","justifyContent","position","left","top","padding","margin","borderRadius","fontSize","marginBottom","fontWeight","lineHeight","textAlign","marginTop"],"sourceRoot":"../../../src","sources":["layout/welcome.js"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,IAAI,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,UAAU,QAAQ,cAAc;AACnF,OAAOC,QAAQ,MAAM,oCAAoC;AACzD,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,YAAY,QAAQ,4BAA4B;AACzD,OAAOC,eAAe,MAAM,6BAA6B;AACzD,OAAOC,eAAe,MAAM,qBAAqB;AAEjD,OAAO,MAAMC,OAAO,GAAGA,CAAC;EAAEC;AAAY,CAAC,KAAK;EAC1C,MAAM;IAAEC,YAAY;IAAEC,QAAQ;IAAEC,kBAAkB;IAAEC;EAAiB,CAAC,GAAGhB,UAAU,CAACO,UAAU,CAAC;EAE/F,MAAMU,WAAW,GAAGA,CAAA,KAAM;IACxB,IAAI,CAACH,QAAQ,CAACI,QAAQ,IAAI,IAAI,MAAM,IAAI,EAAE;MACxCL,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC,MAAM;MACLA,YAAY,CAAC,MAAM,CAAC;IACtB;IAEA,IAAI,OAAOC,QAAQ,CAACK,aAAa,KAAK,UAAU,EAAE;MAChDL,QAAQ,CAACK,aAAa,CAAC,KAAK,CAAC;IAC/B;EACF,CAAC;EAED,oBACEpB,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IAACoB,KAAK,EAAEC,MAAM,CAACC;EAAU,gBAC5BxB,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IAACoB,KAAK,EAAEC,MAAM,CAACE;EAAgB,gBAElCzB,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IAACoB,KAAK,EAAEC,MAAM,CAACG;EAAa,gBAC/B1B,KAAA,CAAAqB,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AE,KAAK;IACjBG,SAAS,EAAE;EACb,CAAC;EACDvB,eAAe,EAAE;IACfU,iBAAiB,EAAE,EAAE;IACrBL,eAAe,EAAE,SAAS;IAC1BC,UAAU,EAAE;EACd,CAAC;EACDL,WAAW,EAAE;IACXiB,QAAQ,EAAE,EAAE;IACZC,YAAY,EAAE,EAAE;IAChBxB,KAAK,EAAE,SAAS;IAChByB,UAAU,EAAE,KAAK;IACjBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,eAAenD,OAAO","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// audioRecorder.js
|
|
2
2
|
|
|
3
|
-
import { Platform
|
|
4
|
-
import Voice from '@react-native-
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import Voice from '@react-native-voice/voice';
|
|
5
5
|
import { check, PERMISSIONS, request, RESULTS } from 'react-native-permissions';
|
|
6
6
|
import useAsyncStorage from '../hooks/useAsyncStorage';
|
|
7
7
|
let resultCallback = null;
|
|
@@ -28,6 +28,12 @@ export async function initVoice(onResult) {
|
|
|
28
28
|
resultCallback = onResult;
|
|
29
29
|
finalResult = '';
|
|
30
30
|
|
|
31
|
+
// Check if Voice module is available
|
|
32
|
+
if (!Voice) {
|
|
33
|
+
console.error('Voice module is not available');
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
// First check if speech recognition is available
|
|
32
38
|
const isAvailable = await Voice.isAvailable();
|
|
33
39
|
if (!isAvailable) {
|
|
@@ -66,7 +72,8 @@ export async function initVoice(onResult) {
|
|
|
66
72
|
};
|
|
67
73
|
Voice.onSpeechError = async e => {
|
|
68
74
|
var _e$error, _e$error2;
|
|
69
|
-
console.error('onSpeechError: ', e);
|
|
75
|
+
// console.error('onSpeechError: ', e);
|
|
76
|
+
|
|
70
77
|
if (silenceTimer) {
|
|
71
78
|
clearTimeout(silenceTimer);
|
|
72
79
|
silenceTimer = null;
|
|
@@ -77,14 +84,13 @@ export async function initVoice(onResult) {
|
|
|
77
84
|
await cleanupVoiceSession();
|
|
78
85
|
|
|
79
86
|
// Only send error to callback if it's not a "No speech detected" error
|
|
80
|
-
if (!isNoSpeechError) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
87
|
+
// if (!isNoSpeechError) {
|
|
88
|
+
// resultCallback(null, e.error?.message || 'Speech recognition error');
|
|
89
|
+
// } else {
|
|
90
|
+
// console.log('No speech detected, ignoring error');
|
|
91
|
+
// // Optionally, call the callback with null parameters or a special indicator
|
|
92
|
+
// resultCallback(null, null); // This won't trigger an error alert in the component
|
|
93
|
+
// }
|
|
88
94
|
};
|
|
89
95
|
Voice.onSpeechResults = e => {
|
|
90
96
|
console.log('onSpeechResults: ', e);
|
|
@@ -143,6 +149,12 @@ const cleanupVoiceSession = async () => {
|
|
|
143
149
|
silenceTimer = null;
|
|
144
150
|
}
|
|
145
151
|
try {
|
|
152
|
+
// Check if Voice module is available
|
|
153
|
+
if (!Voice) {
|
|
154
|
+
console.log('Voice module not available during cleanup');
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
146
158
|
// First try to stop if still recognizing
|
|
147
159
|
const isRecognizing = await Voice.isRecognizing();
|
|
148
160
|
if (isRecognizing) {
|
|
@@ -168,7 +180,9 @@ const cleanupVoiceSession = async () => {
|
|
|
168
180
|
console.error('Error in cleanupVoiceSession:', error);
|
|
169
181
|
// Final attempt to destroy on error
|
|
170
182
|
try {
|
|
171
|
-
|
|
183
|
+
if (Voice) {
|
|
184
|
+
await Voice.destroy();
|
|
185
|
+
}
|
|
172
186
|
} catch (e) {
|
|
173
187
|
console.error('Final destroy attempt failed:', e);
|
|
174
188
|
}
|
|
@@ -177,6 +191,12 @@ const cleanupVoiceSession = async () => {
|
|
|
177
191
|
};
|
|
178
192
|
export async function startRecording() {
|
|
179
193
|
try {
|
|
194
|
+
// Check if Voice module is available
|
|
195
|
+
if (!Voice) {
|
|
196
|
+
console.error('Voice module is not available');
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
|
|
180
200
|
// Ensure cleanup of any existing session
|
|
181
201
|
await cleanupVoiceSession();
|
|
182
202
|
const hasPermission = await requestAudioPermission();
|
|
@@ -195,7 +215,7 @@ export async function startRecording() {
|
|
|
195
215
|
}
|
|
196
216
|
export async function stopRecording() {
|
|
197
217
|
try {
|
|
198
|
-
if (!isCurrentlyRecording) return;
|
|
218
|
+
if (!isCurrentlyRecording || !Voice) return;
|
|
199
219
|
|
|
200
220
|
// Set this first to prevent race conditions
|
|
201
221
|
isCurrentlyRecording = false;
|
|
@@ -231,6 +251,7 @@ export async function stopRecording() {
|
|
|
231
251
|
}
|
|
232
252
|
export async function cancelRecording() {
|
|
233
253
|
try {
|
|
254
|
+
if (!Voice) return;
|
|
234
255
|
await Voice.cancel();
|
|
235
256
|
await cleanupVoiceSession();
|
|
236
257
|
} catch (error) {
|
|
@@ -265,19 +286,20 @@ export async function requestAudioPermission() {
|
|
|
265
286
|
}
|
|
266
287
|
async function requestAndroidPermission() {
|
|
267
288
|
try {
|
|
268
|
-
//
|
|
289
|
+
// Request microphone permission
|
|
290
|
+
const micPermission = await request(PERMISSIONS.ANDROID.RECORD_AUDIO);
|
|
291
|
+
if (micPermission !== RESULTS.GRANTED) {
|
|
292
|
+
console.log('Microphone permission denied');
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Skip checking speech recognition services which is causing errors
|
|
269
297
|
const services = await Voice.getSpeechRecognitionServices();
|
|
270
298
|
if (!services || services.length === 0) {
|
|
271
299
|
console.error('No speech recognition services available');
|
|
272
300
|
return false;
|
|
273
301
|
}
|
|
274
|
-
|
|
275
|
-
title: 'Microphone Permission',
|
|
276
|
-
message: 'This app needs access to your microphone for voice recognition.',
|
|
277
|
-
buttonPositive: 'OK',
|
|
278
|
-
buttonNegative: 'Cancel'
|
|
279
|
-
});
|
|
280
|
-
return granted === PermissionsAndroid.RESULTS.GRANTED;
|
|
302
|
+
return true;
|
|
281
303
|
} catch (error) {
|
|
282
304
|
console.error('Error requesting Android permission:', error);
|
|
283
305
|
return false;
|
|
@@ -312,13 +334,19 @@ export function resetStoredPermission() {
|
|
|
312
334
|
return false;
|
|
313
335
|
}
|
|
314
336
|
export function cleanup() {
|
|
337
|
+
if (!Voice) {
|
|
338
|
+
console.log('Voice module not available during cleanup');
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
315
341
|
Voice.destroy().then(() => {
|
|
316
342
|
Voice.removeAllListeners();
|
|
317
343
|
cleanupVoiceSession();
|
|
318
344
|
}).catch(error => {
|
|
319
345
|
console.error('Error in cleanup:', error);
|
|
320
346
|
// Try one more time
|
|
321
|
-
Voice
|
|
347
|
+
if (Voice) {
|
|
348
|
+
Voice.destroy().catch(e => console.error('Final cleanup attempt failed:', e));
|
|
349
|
+
}
|
|
322
350
|
});
|
|
323
351
|
}
|
|
324
352
|
//# sourceMappingURL=audioRecorder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
1
|
+
{"version":3,"names":["Platform","Voice","check","PERMISSIONS","request","RESULTS","useAsyncStorage","resultCallback","silenceTimer","isCurrentlyRecording","finalResult","SILENCE_DURATION","PERMISSION_STORAGE_KEY","permissionStatusGetter","permissionStatusSetter","setPermissionStatusHandlers","getter","setter","initVoice","onResult","console","error","isAvailable","onSpeechStart","e","log","clearTimeout","onSpeechRecognized","isFinal","handleFinalResult","onSpeechEnd","onSpeechError","_e$error","_e$error2","isNoSpeechError","code","message","includes","cleanupVoiceSession","onSpeechResults","value","length","handleSilenceDetection","onSpeechPartialResults","OS","onSpeechVolumeChanged","setTimeout","stopRecording","isRecognizing","stop","Promise","resolve","destroy","stillRecognizing","startRecording","hasPermission","requestAudioPermission","start","cancelRecording","cancel","storedPermission","permissionResult","requestAndroidPermission","requestIOSPermission","micPermission","ANDROID","RECORD_AUDIO","GRANTED","services","getSpeechRecognitionServices","IOS","MICROPHONE","speechPermission","SPEECH_RECOGNITION","resetStoredPermission","cleanup","then","removeAllListeners","catch"],"sourceRoot":"../../../src","sources":["utils/audioRecorder.js"],"mappings":"AAAA;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,KAAK,MAAM,2BAA2B;AAC7C,SAASC,KAAK,EAAEC,WAAW,EAAEC,OAAO,EAAEC,OAAO,QAAQ,0BAA0B;AAC/E,OAAOC,eAAe,MAAM,0BAA0B;AAEtD,IAAIC,cAAc,GAAG,IAAI;AACzB,IAAIC,YAAY,GAAG,IAAI;AACvB,IAAIC,oBAAoB,GAAG,KAAK;AAChC,IAAIC,WAAW,GAAG,EAAE;AACpB,MAAMC,gBAAgB,GAAG,IAAI,CAAC,CAAC;;AAE/B;AACA,MAAMC,sBAAsB,GAAG,0BAA0B;;AAEzD;AACA;AACA,IAAIC,sBAAsB,GAAG,IAAI;AACjC,IAAIC,sBAAsB,GAAG,IAAI;AAEjC,OAAO,SAASC,2BAA2BA,CAACC,MAAM,EAAEC,MAAM,EAAE;EAC1DJ,sBAAsB,GAAGG,MAAM;EAC/BF,sBAAsB,GAAGG,MAAM;AACjC;;AAEA;AACA,OAAO,eAAeC,SAASA,CAACC,QAAQ,EAAE;EACxC,IAAI;IACFZ,cAAc,GAAGY,QAAQ;IACzBT,WAAW,GAAG,EAAE;;IAEhB;IACA,IAAI,CAACT,KAAK,EAAE;MACVmB,OAAO,CAACC,KAAK,CAAC,+BAA+B,CAAC;MAC9C,OAAO,KAAK;IACd;;IAEA;IACA,MAAMC,WAAW,GAAG,MAAMrB,KAAK,CAACqB,WAAW,CAAC,CAAC;IAC7C,IAAI,CAACA,WAAW,EAAE;MAChBF,OAAO,CAACC,KAAK,CAAC,oDAAoD,CAAC;MACnE,OAAO,KAAK;IACd;;IAEA;IACApB,KAAK,CAACsB,aAAa,GAAIC,CAAC,IAAK;MAC3BJ,OAAO,CAACK,GAAG,CAAC,iBAAiB,EA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AC/E;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/components/email.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/components/email.js"],"names":[],"mappings":"AAiBO;;sBAmKN;;kBApLmD,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"welcome.d.ts","sourceRoot":"","sources":["../../../src/layout/welcome.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"welcome.d.ts","sourceRoot":"","sources":["../../../src/layout/welcome.js"],"names":[],"mappings":"AASO;;sBAmDN;;kBA3DiC,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioRecorder.d.ts","sourceRoot":"","sources":["../../../src/utils/audioRecorder.js"],"names":[],"mappings":"AAqBA,4EAGC;AAGD,
|
|
1
|
+
{"version":3,"file":"audioRecorder.d.ts","sourceRoot":"","sources":["../../../src/utils/audioRecorder.js"],"names":[],"mappings":"AAqBA,4EAGC;AAGD,2DA4GC;AA+ED,mDAyBC;AAED,+CAoCC;AAED,iDASC;AAED,2DA2BC;AAiDD,iDAMC;AAED,gCAgBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-srschat",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern, sophisticated chat interface for React Native",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"@react-native-async-storage/async-storage": "^2.1.1",
|
|
64
64
|
"@react-native-community/audio-toolkit": "^2.0.3",
|
|
65
65
|
"@react-native-community/cli": "^15.0.0",
|
|
66
|
-
"@react-native-community/voice": "^1.1.9",
|
|
67
66
|
"@react-native-picker/picker": "^2.11.0",
|
|
67
|
+
"@react-native-voice/voice": "^3.2.4",
|
|
68
68
|
"axios": "^1.7.9",
|
|
69
|
+
"cloudinary-react-native": "^0.3.0",
|
|
69
70
|
"react-native-audio-recorder-player": "^3.6.12",
|
|
71
|
+
"react-native-eject": "^1.0.2",
|
|
70
72
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
71
73
|
"react-native-markdown-display": "^7.0.2",
|
|
72
74
|
"react-native-permissions": "^5.2.6",
|
|
73
|
-
"react-native-eject": "^1.0.2",
|
|
74
75
|
"react-native-uuid": "^2.0.3",
|
|
75
76
|
"react-native-vector-icons": "^10.2.0",
|
|
76
77
|
"react-native-video": "^6.10.2",
|
|
77
|
-
"react-native-web": "~0.19.10"
|
|
78
|
-
"cloudinary-react-native": "^0.3.0"
|
|
78
|
+
"react-native-web": "~0.19.10"
|
|
79
79
|
},
|
|
80
80
|
"react-native-builder-bob": {
|
|
81
81
|
"source": "src",
|
package/src/components/email.js
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import React, { useState, useContext } from "react";
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState, useContext, useRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TextInput,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
ActivityIndicator,
|
|
8
|
+
StyleSheet,
|
|
9
|
+
Platform,
|
|
10
|
+
findNodeHandle
|
|
11
|
+
} from "react-native";
|
|
3
12
|
import Ionicons from "react-native-vector-icons/Ionicons";
|
|
4
13
|
import axios from "axios";
|
|
5
14
|
import { AppContext } from "../contexts/AppContext";
|
|
6
15
|
import { Header } from "./header";
|
|
16
|
+
import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
7
17
|
|
|
8
18
|
export const EmailForm = ({ panHandlers }) => {
|
|
9
19
|
const { data, BASE_URL, setShowModal, messages, formatChatHistory, conversationStartTime } = useContext(AppContext);
|
|
10
20
|
const [subject, setSubject] = useState("");
|
|
11
21
|
const [message, setMessage] = useState("");
|
|
12
22
|
const [userEmail, setUserEmail] = useState("");
|
|
13
|
-
const [branchEmail, setBranchEmail] = useState(data
|
|
23
|
+
const [branchEmail, setBranchEmail] = useState((data?.branch_email) || "");
|
|
14
24
|
const [isLoading, setIsLoading] = useState(false);
|
|
15
25
|
const [error, setError] = useState("");
|
|
16
26
|
const [success, setSuccess] = useState(false);
|
|
17
27
|
const [isComposing, setIsComposing] = useState(false);
|
|
18
28
|
|
|
29
|
+
// Refs for the scroll view and inputs
|
|
30
|
+
const scrollViewRef = useRef(null);
|
|
31
|
+
const subjectInputRef = useRef(null);
|
|
32
|
+
const messageInputRef = useRef(null);
|
|
33
|
+
const emailInputRef = useRef(null);
|
|
34
|
+
|
|
19
35
|
const handleComposeEmail = async () => {
|
|
20
|
-
setIsComposing(true);
|
|
36
|
+
setIsComposing(true);
|
|
21
37
|
setError("");
|
|
22
38
|
|
|
23
39
|
try {
|
|
@@ -25,7 +41,7 @@ export const EmailForm = ({ panHandlers }) => {
|
|
|
25
41
|
const payload = {
|
|
26
42
|
chat_history: chatHistory,
|
|
27
43
|
conversation_start_time: conversationStartTime,
|
|
28
|
-
customer_name:
|
|
44
|
+
customer_name: "",
|
|
29
45
|
branch_email: branchEmail,
|
|
30
46
|
};
|
|
31
47
|
|
|
@@ -60,7 +76,7 @@ export const EmailForm = ({ panHandlers }) => {
|
|
|
60
76
|
message,
|
|
61
77
|
chat_history: chatHistory,
|
|
62
78
|
conversation_start_time: conversationStartTime,
|
|
63
|
-
customer_name:
|
|
79
|
+
customer_name: "",
|
|
64
80
|
branch_email: branchEmail,
|
|
65
81
|
});
|
|
66
82
|
|
|
@@ -76,50 +92,92 @@ export const EmailForm = ({ panHandlers }) => {
|
|
|
76
92
|
}
|
|
77
93
|
};
|
|
78
94
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
95
|
+
return (
|
|
96
|
+
<View style={styles.container}>
|
|
97
|
+
<Header />
|
|
98
|
+
<KeyboardAwareScrollView
|
|
99
|
+
ref={scrollViewRef}
|
|
100
|
+
style={styles.content}
|
|
101
|
+
contentContainerStyle={{ flexGrow: 1, paddingBottom: 50 }}
|
|
102
|
+
keyboardShouldPersistTaps="handled"
|
|
103
|
+
showsVerticalScrollIndicator={true}
|
|
104
|
+
enableOnAndroid={true}
|
|
105
|
+
extraScrollHeight={40}
|
|
106
|
+
keyboardDismissMode="interactive"
|
|
107
|
+
bounces={false}
|
|
108
|
+
>
|
|
84
109
|
<View style={styles.topBar}>
|
|
85
|
-
|
|
110
|
+
<TouchableOpacity onPress={() => setShowModal("ChatWindow")} style={styles.backButton}>
|
|
86
111
|
<Ionicons name="arrow-back" size={20} color="#000" />
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
</TouchableOpacity>
|
|
113
|
+
<Text style={styles.topBarTitle}>Contact Us</Text>
|
|
89
114
|
</View>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
</Text>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
|
|
116
|
+
<Text style={styles.infoText}>
|
|
117
|
+
Our AI assistant can help draft a professional email based on your chat conversation. The email will capture your main points and maintain a conversational tone. You can review and modify before sending.
|
|
118
|
+
</Text>
|
|
119
|
+
|
|
120
|
+
<TouchableOpacity style={styles.composeButton} onPress={handleComposeEmail} disabled={isComposing}>
|
|
121
|
+
{isComposing ? (
|
|
122
|
+
<ActivityIndicator size="small" color="#FFFFFF" />
|
|
123
|
+
) : (
|
|
124
|
+
<Text style={styles.buttonText}>Draft My Email</Text>
|
|
125
|
+
)}
|
|
126
|
+
</TouchableOpacity>
|
|
127
|
+
|
|
128
|
+
<TextInput
|
|
129
|
+
style={styles.input}
|
|
130
|
+
value={branchEmail}
|
|
131
|
+
editable={false}
|
|
132
|
+
placeholder="Branch Email"
|
|
133
|
+
/>
|
|
134
|
+
<TextInput
|
|
135
|
+
ref={emailInputRef}
|
|
136
|
+
style={styles.input}
|
|
137
|
+
value={userEmail}
|
|
138
|
+
onChangeText={setUserEmail}
|
|
139
|
+
placeholder="Your Email"
|
|
140
|
+
onFocus={() =>
|
|
141
|
+
scrollViewRef.current?.scrollToFocusedInput(
|
|
142
|
+
findNodeHandle(emailInputRef.current)
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
/>
|
|
146
|
+
<TextInput
|
|
147
|
+
ref={subjectInputRef}
|
|
148
|
+
style={styles.input}
|
|
149
|
+
value={subject}
|
|
150
|
+
onChangeText={setSubject}
|
|
151
|
+
placeholder="Subject"
|
|
152
|
+
onFocus={() =>
|
|
153
|
+
scrollViewRef.current?.scrollToFocusedInput(
|
|
154
|
+
findNodeHandle(subjectInputRef.current)
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
/>
|
|
158
|
+
<TextInput
|
|
159
|
+
ref={messageInputRef}
|
|
160
|
+
style={styles.textArea}
|
|
161
|
+
value={message}
|
|
162
|
+
onChangeText={setMessage}
|
|
163
|
+
placeholder="Message"
|
|
164
|
+
multiline
|
|
165
|
+
onFocus={() =>
|
|
166
|
+
scrollViewRef.current?.scrollToFocusedInput(
|
|
167
|
+
findNodeHandle(messageInputRef.current)
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
/>
|
|
171
|
+
|
|
172
|
+
{error ? <Text style={styles.errorText}>{error}</Text> : null}
|
|
173
|
+
{success ? <Text style={styles.successText}>Email sent successfully!</Text> : null}
|
|
174
|
+
|
|
175
|
+
<TouchableOpacity style={styles.sendButton} onPress={handleSubmit} disabled={isLoading}>
|
|
176
|
+
{isLoading ? <ActivityIndicator size="small" color="#FFFFFF" /> : <Text style={styles.buttonText}>Send Email</Text>}
|
|
177
|
+
</TouchableOpacity>
|
|
178
|
+
</KeyboardAwareScrollView>
|
|
179
|
+
</View>
|
|
180
|
+
);
|
|
123
181
|
};
|
|
124
182
|
|
|
125
183
|
const styles = StyleSheet.create({
|
|
@@ -129,24 +187,22 @@ const styles = StyleSheet.create({
|
|
|
129
187
|
content: {
|
|
130
188
|
padding: 20,
|
|
131
189
|
paddingTop: 5,
|
|
132
|
-
|
|
133
|
-
marginBottom: 40
|
|
190
|
+
flex: 1,
|
|
134
191
|
},
|
|
135
192
|
topBar: {
|
|
136
|
-
flexDirection:
|
|
137
|
-
alignItems:
|
|
193
|
+
flexDirection: "row",
|
|
194
|
+
alignItems: "center",
|
|
138
195
|
paddingVertical: 10,
|
|
139
|
-
|
|
140
|
-
marginTop: 10
|
|
196
|
+
marginTop: 10,
|
|
141
197
|
},
|
|
142
198
|
backButton: {
|
|
143
199
|
padding: 8,
|
|
144
200
|
borderRadius: 20,
|
|
145
|
-
backgroundColor:
|
|
201
|
+
backgroundColor: "#FFF",
|
|
146
202
|
},
|
|
147
203
|
topBarTitle: {
|
|
148
204
|
fontSize: 18,
|
|
149
|
-
fontWeight:
|
|
205
|
+
fontWeight: "500",
|
|
150
206
|
marginLeft: 12,
|
|
151
207
|
},
|
|
152
208
|
infoText: {
|
|
@@ -208,3 +264,5 @@ const styles = StyleSheet.create({
|
|
|
208
264
|
marginTop: 10,
|
|
209
265
|
},
|
|
210
266
|
});
|
|
267
|
+
|
|
268
|
+
export default EmailForm;
|
|
@@ -24,7 +24,8 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
24
24
|
const grossPrice = uomInfo.gross_price || 0;
|
|
25
25
|
const netPrice = uomInfo.net_price || 0;
|
|
26
26
|
const isOnSale = uomInfo.is_on_sale || false;
|
|
27
|
-
const discounts = uomInfo.discounts
|
|
27
|
+
const discounts = Array.isArray(uomInfo.discounts) ? uomInfo.discounts : [];
|
|
28
|
+
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
const maxQuantity = Math.floor(prod.inventory_info?.info_by_uom?.EA?.quantity_available || 0);
|
|
@@ -201,7 +202,6 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
201
202
|
disabled={!valid}
|
|
202
203
|
>
|
|
203
204
|
<Text style={styles.dropdownButtonText}>{selectedUom}</Text>
|
|
204
|
-
<Ionicons name="close" size={26} color="rgba(0, 0, 0, 0.6)" />
|
|
205
205
|
</TouchableOpacity>
|
|
206
206
|
</View>
|
|
207
207
|
) : null}
|