react-native-srschat 0.1.68 → 0.1.69
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 +1 -0
- package/lib/commonjs/components/header.js +10 -6
- package/lib/commonjs/components/header.js.map +1 -1
- package/lib/commonjs/components/welcomeButton.js +23 -4
- package/lib/commonjs/components/welcomeButton.js.map +1 -1
- package/lib/commonjs/contexts/AppContext.js +37 -11
- package/lib/commonjs/contexts/AppContext.js.map +1 -1
- package/lib/commonjs/layout/welcome.js +13 -5
- package/lib/commonjs/layout/welcome.js.map +1 -1
- package/lib/commonjs/layout/window.js +11 -4
- package/lib/commonjs/layout/window.js.map +1 -1
- package/lib/commonjs/utils/cloudinary.js +12 -4
- package/lib/commonjs/utils/cloudinary.js.map +1 -1
- package/lib/module/components/header.js +10 -6
- package/lib/module/components/header.js.map +1 -1
- package/lib/module/components/welcomeButton.js +23 -4
- package/lib/module/components/welcomeButton.js.map +1 -1
- package/lib/module/contexts/AppContext.js +37 -11
- package/lib/module/contexts/AppContext.js.map +1 -1
- package/lib/module/layout/welcome.js +13 -5
- package/lib/module/layout/welcome.js.map +1 -1
- package/lib/module/layout/window.js +11 -4
- package/lib/module/layout/window.js.map +1 -1
- package/lib/module/utils/cloudinary.js +10 -3
- package/lib/module/utils/cloudinary.js.map +1 -1
- package/lib/typescript/components/header.d.ts.map +1 -1
- package/lib/typescript/components/welcomeButton.d.ts.map +1 -1
- package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
- package/lib/typescript/layout/welcome.d.ts.map +1 -1
- package/lib/typescript/layout/window.d.ts.map +1 -1
- package/lib/typescript/utils/cloudinary.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/header.js +6 -9
- package/src/components/welcomeButton.js +14 -4
- package/src/contexts/AppContext.js +42 -13
- package/src/layout/welcome.js +5 -8
- package/src/layout/window.js +8 -5
- package/src/utils/cloudinary.js +6 -3
|
@@ -3,7 +3,7 @@ import React, { useContext } from 'react';
|
|
|
3
3
|
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
|
|
4
4
|
import { AppContext } from '../contexts/AppContext';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const landscapeQuestions = [
|
|
7
7
|
{ text: 'What are the hours of my current branch?' },
|
|
8
8
|
{ text: 'Do you have part # RBLESPLXME2 in stock?' },
|
|
9
9
|
{ text: 'How do I install the seal on B82456?' },
|
|
@@ -11,18 +11,28 @@ const suggestedQuestions = [
|
|
|
11
11
|
{ text: '¿Puedes ayudarme en español?' }
|
|
12
12
|
];
|
|
13
13
|
|
|
14
|
+
const poolQuestions = [
|
|
15
|
+
{ text: 'What are the hours of my current branch?' },
|
|
16
|
+
{ text: 'Do you have part # JNDDEV48 in stock?' },
|
|
17
|
+
{ text: 'Do you carry Hayward super pumps?' },
|
|
18
|
+
{ text: 'Which grid assembly goes with the Hayward DE4820 filter?' },
|
|
19
|
+
{ text: '¿Puedes ayudarme en español?' }
|
|
20
|
+
];
|
|
21
|
+
|
|
14
22
|
const ButtonComponent = () => {
|
|
15
|
-
const { handleButtonClick } = useContext(AppContext);
|
|
23
|
+
const { handleButtonClick, theme, data } = useContext(AppContext);
|
|
24
|
+
const isPool = data?.brand_version === 'pool';
|
|
25
|
+
const suggestedQuestions = isPool ? poolQuestions : landscapeQuestions;
|
|
16
26
|
|
|
17
27
|
return (
|
|
18
28
|
<View style={styles.buttonContainer}>
|
|
19
29
|
{suggestedQuestions.map((item, index) => (
|
|
20
30
|
<TouchableOpacity
|
|
21
31
|
key={index}
|
|
22
|
-
style={styles.button}
|
|
32
|
+
style={[styles.button, { borderColor: theme.primaryColor }]}
|
|
23
33
|
onPress={() => handleButtonClick(item.text)}
|
|
24
34
|
>
|
|
25
|
-
<Text style={styles.buttonText}>{item.text}</Text>
|
|
35
|
+
<Text style={[styles.buttonText, { color: theme.primaryColor }]}>{item.text}</Text>
|
|
26
36
|
</TouchableOpacity>
|
|
27
37
|
))}
|
|
28
38
|
</View>
|
|
@@ -7,25 +7,54 @@ import { loadChat, updateChat, defaultState } from '../utils/storage';
|
|
|
7
7
|
export const AppContext = createContext();
|
|
8
8
|
|
|
9
9
|
export const AppProvider = ({ data, onProductCardClick, onAddToCartClick, uiConfig = {}, children }) => {
|
|
10
|
+
// Brand-driven configuration
|
|
11
|
+
const version = (data?.brand_version === 'pool' || data?.brand_version === 'landscape') ? data.brand_version : 'landscape';
|
|
12
|
+
const API_PREFIX = "https://";
|
|
13
|
+
|
|
14
|
+
const BRAND_CONFIG = (() => {
|
|
15
|
+
const isStage = data?.env === 'stage';
|
|
16
|
+
return {
|
|
17
|
+
pool: {
|
|
18
|
+
primaryColor: '#004687',
|
|
19
|
+
userMessageColor: '#003764',
|
|
20
|
+
cloudName: 'heritageplus',
|
|
21
|
+
// Pool assets live under mobileapp/ in heritageplus cloud
|
|
22
|
+
logoId: 'mobileapp/logos/HPSG_HPlus_Logo_White',
|
|
23
|
+
baseHost: isStage
|
|
24
|
+
? 'pool-stage-external-agent-adk-586731320826.us-east1.run.app'
|
|
25
|
+
: 'pool-prod-external-agent-adk-586731320826.us-east1.run.app',
|
|
26
|
+
loggingHost: 'srs-external-agent-logging-586731320826.us-central1.run.app',
|
|
27
|
+
},
|
|
28
|
+
landscape: {
|
|
29
|
+
primaryColor: '#437D3D',
|
|
30
|
+
userMessageColor: '#437D3D',
|
|
31
|
+
cloudName: 'mktg',
|
|
32
|
+
logoId: 'logos/HLSG_Logo_Lockup_Color',
|
|
33
|
+
baseHost: isStage
|
|
34
|
+
? 'landscape-stage-external-agent-adk-586731320826.us-east1.run.app'
|
|
35
|
+
: 'landscape-prod-external-agent-adk-586731320826.us-east1.run.app',
|
|
36
|
+
loggingHost: 'srs-external-agent-landscape-logging-586731320826.us-central1.run.app',
|
|
37
|
+
},
|
|
38
|
+
}[version];
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
const BASE_URL = BRAND_CONFIG.baseHost;
|
|
42
|
+
const LOGGING_URL = BRAND_CONFIG.loggingHost;
|
|
43
|
+
const TRACK_CLICK_URL = `${API_PREFIX}${LOGGING_URL}/track-click`;
|
|
44
|
+
const ADD_TO_CART_URL = `${API_PREFIX}${LOGGING_URL}/add-to-cart`;
|
|
45
|
+
|
|
10
46
|
const theme = {
|
|
11
|
-
userMessage:
|
|
12
|
-
botMessage:
|
|
47
|
+
userMessage: BRAND_CONFIG.userMessageColor,
|
|
48
|
+
botMessage: BRAND_CONFIG.userMessageColor,
|
|
13
49
|
backgroundColor: '#f6f6f6',
|
|
14
50
|
textColor: '#161616',
|
|
15
51
|
textColorSecondary: '#FFFFFF',
|
|
16
52
|
inlineButtonColor: '#dbd4c8',
|
|
17
|
-
primaryColor:
|
|
53
|
+
primaryColor: BRAND_CONFIG.primaryColor,
|
|
18
54
|
};
|
|
19
55
|
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
// Backend URLs
|
|
24
|
-
const BASE_URL = data.env === "stage"
|
|
25
|
-
? "landscape-stage-external-agent-adk-586731320826.us-east1.run.app"
|
|
26
|
-
: "landscape-prod-external-agent-adk-586731320826.us-east1.run.app";
|
|
27
|
-
const LOGGING_URL = "srs-external-agent-landscape-logging-586731320826.us-central1.run.app";
|
|
28
|
-
const API_PREFIX = "https://";
|
|
56
|
+
const brandLogo = BRAND_CONFIG.logoId;
|
|
57
|
+
const brandCloudName = BRAND_CONFIG.cloudName;
|
|
29
58
|
|
|
30
59
|
// Default Messages
|
|
31
60
|
const defaultMessage = [
|
|
@@ -382,7 +411,7 @@ export const AppProvider = ({ data, onProductCardClick, onAddToCartClick, uiConf
|
|
|
382
411
|
startStreaming, setStartStreaming, maintenance, setMaintenance, feedback, setFeedback, handleFeedback, feedbackOpen, setFeedbackOpen,
|
|
383
412
|
writeFeedback, setWriteFeedback, writeAnswer, setWriteAnswer, BASE_URL, lastMessageId, setLastMessageId,
|
|
384
413
|
onProductCardClick, onAddToCartClick: handleAddToCartWithMessage, data, sessionId, setSessionId, handleWrittenFeedback, switchFeedbackOpen, confirmDisclaimer,
|
|
385
|
-
formatChatHistory, uiConfig, handleVoiceSend, TRACK_CLICK_URL, ADD_TO_CART_URL, isListening, setIsListening
|
|
414
|
+
formatChatHistory, uiConfig, handleVoiceSend, TRACK_CLICK_URL, ADD_TO_CART_URL, isListening, setIsListening, brandLogo, brandCloudName
|
|
386
415
|
}}
|
|
387
416
|
>
|
|
388
417
|
{children}
|
package/src/layout/welcome.js
CHANGED
|
@@ -8,7 +8,7 @@ import ButtonComponent from '../components/welcomeButton';
|
|
|
8
8
|
import CloudinaryImage from '../utils/cloudinary';
|
|
9
9
|
|
|
10
10
|
export const Welcome = ({ panHandlers }) => {
|
|
11
|
-
const { setShowModal, uiConfig, onProductCardClick, onAddToCartClick, data } = useContext(AppContext);
|
|
11
|
+
const { setShowModal, uiConfig, onProductCardClick, onAddToCartClick, data, theme, brandLogo } = useContext(AppContext);
|
|
12
12
|
|
|
13
13
|
const handleClick = () => {
|
|
14
14
|
if ((uiConfig.showIcon ?? true) !== true) {
|
|
@@ -24,23 +24,20 @@ export const Welcome = ({ panHandlers }) => {
|
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<View style={styles.container}>
|
|
27
|
-
<View style={styles.parentContainer}>
|
|
27
|
+
<View style={[styles.parentContainer, { backgroundColor: theme.primaryColor }]}>
|
|
28
28
|
{/* Top section */}
|
|
29
|
-
<View style={styles.topContainer}>
|
|
29
|
+
<View style={[styles.topContainer, { backgroundColor: theme.primaryColor }]}>
|
|
30
30
|
<View style={styles.topHeader}>
|
|
31
31
|
{/* Logo container with absolute positioning */}
|
|
32
32
|
<View style={styles.logoContainer}>
|
|
33
|
-
<CloudinaryImage
|
|
34
|
-
cldImg="logos/HLSG_Logo_Lockup_Color"
|
|
35
|
-
imageStyle={{ width: 150, height: 35 }}
|
|
36
|
-
/>
|
|
33
|
+
<CloudinaryImage cldImg={brandLogo} imageStyle={{ width: 150, height: 35 }} />
|
|
37
34
|
</View>
|
|
38
35
|
<TouchableOpacity onPress={handleClick} style={styles.collapseButton}>
|
|
39
36
|
<Ionicons name="close" size={26} color="white" />
|
|
40
37
|
</TouchableOpacity>
|
|
41
38
|
</View>
|
|
42
39
|
|
|
43
|
-
<View style={styles.blueContainer}>
|
|
40
|
+
<View style={[styles.blueContainer, { backgroundColor: theme.primaryColor }]}>
|
|
44
41
|
<Text style={styles.welcomeHeader}>Hi {data?.customer_name || ""} 👋</Text>
|
|
45
42
|
<Text style={styles.welcomeBody2}>
|
|
46
43
|
I’m your Heritage+ AI Agent. I can help you during your online visit with Product and Account information.
|
package/src/layout/window.js
CHANGED
|
@@ -15,7 +15,7 @@ import { ProgressCircle } from '../components/progressCircle';
|
|
|
15
15
|
|
|
16
16
|
export const ChatWindow = ({ panHandlers }) => {
|
|
17
17
|
const { handleSend, messages, input, setInput, ghostMessage, handleButtonClick,
|
|
18
|
-
onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator, feedbackOpen, setFeedbackOpen
|
|
18
|
+
onProductCardClick, onAddToCartClick, uiConfig, ghostCard, typingIndicator, feedbackOpen, setFeedbackOpen, theme
|
|
19
19
|
} = useContext(AppContext);
|
|
20
20
|
|
|
21
21
|
const scrollViewRef = useRef(null);
|
|
@@ -106,7 +106,7 @@ export const ChatWindow = ({ panHandlers }) => {
|
|
|
106
106
|
|
|
107
107
|
<View key={msg.id || msg.message_id || i} style={styles.messageWrapper}>
|
|
108
108
|
{msg.type !== "middle" && (
|
|
109
|
-
<View style={[ styles.messageBubble, msg.type === "user" ? styles.userMessage : styles.aiMessage,]}>
|
|
109
|
+
<View style={[ styles.messageBubble, msg.type === "user" ? [styles.userMessage, { backgroundColor: theme.userMessage }] : styles.aiMessage,]}>
|
|
110
110
|
|
|
111
111
|
<Markdown style={{ body: { color: msg.type === "user" ? "#ffffff" : "#161616",fontSize: 16, lineHeight: 22, includeFontPadding: false, textAlignVertical: 'center' }}}>
|
|
112
112
|
{typeof msg.text === 'string' ? msg.text : String(msg.text || '')}
|
|
@@ -149,9 +149,12 @@ export const ChatWindow = ({ panHandlers }) => {
|
|
|
149
149
|
|
|
150
150
|
{msg.suggested_questions && Array.isArray(msg.questions) && msg.questions.length > 0 &&
|
|
151
151
|
msg.questions.map((question, index) => (
|
|
152
|
-
<TouchableOpacity
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
<TouchableOpacity
|
|
153
|
+
key={index}
|
|
154
|
+
style={[styles.suggestedQuestionButton, { borderColor: theme.primaryColor }]}
|
|
155
|
+
onPress={() => handleButtonClick(question)}
|
|
156
|
+
>
|
|
157
|
+
<Text style={[styles.suggestedQuestionText, { color: theme.primaryColor }]}>{question}</Text>
|
|
155
158
|
</TouchableOpacity>
|
|
156
159
|
))}
|
|
157
160
|
|
package/src/utils/cloudinary.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { Cloudinary } from '@cloudinary/url-gen';
|
|
3
3
|
import { Platform, View } from 'react-native';
|
|
4
4
|
import { AdvancedImage } from 'cloudinary-react-native';
|
|
5
5
|
import { scale } from '@cloudinary/url-gen/actions/resize';
|
|
6
|
+
import { AppContext } from '../contexts/AppContext';
|
|
6
7
|
|
|
7
8
|
const CloudinaryImage = ({ cldImg, imageStyle, accessibilityLabel, testID }) => {
|
|
9
|
+
const { brandCloudName } = useContext(AppContext);
|
|
8
10
|
const cld = new Cloudinary({
|
|
9
11
|
cloud: {
|
|
10
|
-
cloudName: 'mktg'
|
|
12
|
+
cloudName: brandCloudName || 'mktg'
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
15
|
|
|
@@ -32,9 +34,10 @@ export const CloudinaryBannerImage = ({
|
|
|
32
34
|
width = 345,
|
|
33
35
|
height = 100
|
|
34
36
|
}) => {
|
|
37
|
+
const { brandCloudName } = useContext(AppContext);
|
|
35
38
|
const cld = new Cloudinary({
|
|
36
39
|
cloud: {
|
|
37
|
-
cloudName: 'mktg'
|
|
40
|
+
cloudName: brandCloudName || 'mktg'
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
const myImage = cld.image(`${cldImg}`);
|