react-native-srschat 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.
Files changed (140) hide show
  1. package/lib/commonjs/components/email.js +243 -0
  2. package/lib/commonjs/components/email.js.map +1 -0
  3. package/lib/commonjs/components/feedback.js +115 -0
  4. package/lib/commonjs/components/feedback.js.map +1 -0
  5. package/lib/commonjs/components/header.js +35 -17
  6. package/lib/commonjs/components/header.js.map +1 -1
  7. package/lib/commonjs/components/input.js +106 -0
  8. package/lib/commonjs/components/input.js.map +1 -0
  9. package/lib/commonjs/components/productCard.js +234 -0
  10. package/lib/commonjs/components/productCard.js.map +1 -0
  11. package/lib/commonjs/components/testing.js +19 -6
  12. package/lib/commonjs/components/testing.js.map +1 -1
  13. package/lib/commonjs/{layout/chatIcon.js → components/welcomeButton.js} +40 -37
  14. package/lib/commonjs/components/welcomeButton.js.map +1 -0
  15. package/lib/commonjs/components/welcomeInput.js +87 -0
  16. package/lib/commonjs/components/welcomeInput.js.map +1 -0
  17. package/lib/commonjs/contexts/AppContext.js +272 -56
  18. package/lib/commonjs/contexts/AppContext.js.map +1 -1
  19. package/lib/commonjs/hooks/{Stream.js → stream.js} +107 -39
  20. package/lib/commonjs/hooks/stream.js.map +1 -0
  21. package/lib/commonjs/hooks/useAsyncStorage.js +36 -0
  22. package/lib/commonjs/hooks/useAsyncStorage.js.map +1 -0
  23. package/lib/commonjs/index.js +13 -6
  24. package/lib/commonjs/index.js.map +1 -1
  25. package/lib/commonjs/layout/disclaimer.js +200 -0
  26. package/lib/commonjs/layout/disclaimer.js.map +1 -0
  27. package/lib/commonjs/layout/ex.js +272 -0
  28. package/lib/commonjs/layout/ex.js.map +1 -0
  29. package/lib/commonjs/layout/icon.js +114 -0
  30. package/lib/commonjs/layout/icon.js.map +1 -0
  31. package/lib/commonjs/layout/layout.js +148 -14
  32. package/lib/commonjs/layout/layout.js.map +1 -1
  33. package/lib/commonjs/layout/welcome.js +135 -0
  34. package/lib/commonjs/layout/welcome.js.map +1 -0
  35. package/lib/commonjs/layout/window.js +205 -0
  36. package/lib/commonjs/layout/window.js.map +1 -0
  37. package/lib/module/components/email.js +233 -0
  38. package/lib/module/components/email.js.map +1 -0
  39. package/lib/module/components/feedback.js +105 -0
  40. package/lib/module/components/feedback.js.map +1 -0
  41. package/lib/module/components/header.js +35 -17
  42. package/lib/module/components/header.js.map +1 -1
  43. package/lib/module/components/input.js +96 -0
  44. package/lib/module/components/input.js.map +1 -0
  45. package/lib/module/components/productCard.js +225 -0
  46. package/lib/module/components/productCard.js.map +1 -0
  47. package/lib/module/components/testing.js +20 -7
  48. package/lib/module/components/testing.js.map +1 -1
  49. package/lib/module/components/welcomeButton.js +48 -0
  50. package/lib/module/components/welcomeButton.js.map +1 -0
  51. package/lib/module/components/welcomeInput.js +77 -0
  52. package/lib/module/components/welcomeInput.js.map +1 -0
  53. package/lib/module/contexts/AppContext.js +272 -57
  54. package/lib/module/contexts/AppContext.js.map +1 -1
  55. package/lib/module/hooks/{Stream.js → stream.js} +107 -39
  56. package/lib/module/hooks/stream.js.map +1 -0
  57. package/lib/module/hooks/useAsyncStorage.js +29 -0
  58. package/lib/module/hooks/useAsyncStorage.js.map +1 -0
  59. package/lib/module/index.js +13 -6
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/layout/disclaimer.js +190 -0
  62. package/lib/module/layout/disclaimer.js.map +1 -0
  63. package/lib/module/layout/ex.js +262 -0
  64. package/lib/module/layout/ex.js.map +1 -0
  65. package/lib/module/layout/icon.js +104 -0
  66. package/lib/module/layout/icon.js.map +1 -0
  67. package/lib/module/layout/layout.js +150 -16
  68. package/lib/module/layout/layout.js.map +1 -1
  69. package/lib/module/layout/welcome.js +126 -0
  70. package/lib/module/layout/welcome.js.map +1 -0
  71. package/lib/module/layout/window.js +195 -0
  72. package/lib/module/layout/window.js.map +1 -0
  73. package/lib/typescript/components/email.d.ts +5 -0
  74. package/lib/typescript/components/email.d.ts.map +1 -0
  75. package/lib/typescript/components/feedback.d.ts +6 -0
  76. package/lib/typescript/components/feedback.d.ts.map +1 -0
  77. package/lib/typescript/components/header.d.ts.map +1 -1
  78. package/lib/typescript/components/input.d.ts +6 -0
  79. package/lib/typescript/components/input.d.ts.map +1 -0
  80. package/lib/typescript/components/productCard.d.ts +5 -0
  81. package/lib/typescript/components/productCard.d.ts.map +1 -0
  82. package/lib/typescript/components/testing.d.ts.map +1 -1
  83. package/lib/typescript/components/welcomeButton.d.ts +4 -0
  84. package/lib/typescript/components/welcomeButton.d.ts.map +1 -0
  85. package/lib/typescript/components/welcomeInput.d.ts +6 -0
  86. package/lib/typescript/components/welcomeInput.d.ts.map +1 -0
  87. package/lib/typescript/contexts/AppContext.d.ts +5 -1
  88. package/lib/typescript/contexts/AppContext.d.ts.map +1 -1
  89. package/lib/typescript/hooks/{Stream.d.ts → stream.d.ts} +1 -1
  90. package/lib/typescript/hooks/stream.d.ts.map +1 -0
  91. package/lib/typescript/hooks/useAsyncStorage.d.ts +2 -0
  92. package/lib/typescript/hooks/useAsyncStorage.d.ts.map +1 -0
  93. package/lib/typescript/index.d.ts +2 -1
  94. package/lib/typescript/index.d.ts.map +1 -1
  95. package/lib/typescript/layout/disclaimer.d.ts +5 -0
  96. package/lib/typescript/layout/disclaimer.d.ts.map +1 -0
  97. package/lib/typescript/layout/ex.d.ts +3 -0
  98. package/lib/typescript/layout/ex.d.ts.map +1 -0
  99. package/lib/typescript/layout/{chatIcon.d.ts → icon.d.ts} +1 -1
  100. package/lib/typescript/layout/icon.d.ts.map +1 -0
  101. package/lib/typescript/layout/layout.d.ts +1 -4
  102. package/lib/typescript/layout/layout.d.ts.map +1 -1
  103. package/lib/typescript/layout/welcome.d.ts +5 -0
  104. package/lib/typescript/layout/welcome.d.ts.map +1 -0
  105. package/lib/typescript/layout/window.d.ts +5 -0
  106. package/lib/typescript/layout/window.d.ts.map +1 -0
  107. package/package.json +7 -1
  108. package/src/components/email.js +210 -0
  109. package/src/components/feedback.js +114 -0
  110. package/src/components/header.js +32 -17
  111. package/src/components/input.js +95 -0
  112. package/src/components/productCard.js +240 -0
  113. package/src/components/testing.js +17 -4
  114. package/src/components/welcomeButton.js +51 -0
  115. package/src/components/welcomeInput.js +81 -0
  116. package/src/contexts/AppContext.js +237 -52
  117. package/src/hooks/{Stream.js → stream.js} +123 -41
  118. package/src/hooks/useAsyncStorage.js +33 -0
  119. package/src/index.js +7 -3
  120. package/src/layout/disclaimer.js +187 -0
  121. package/src/layout/ex.js +251 -0
  122. package/src/layout/icon.js +96 -0
  123. package/src/layout/layout.js +137 -10
  124. package/src/layout/welcome.js +124 -0
  125. package/src/layout/window.js +194 -0
  126. package/lib/commonjs/hooks/Stream.js.map +0 -1
  127. package/lib/commonjs/layout/chatIcon.js.map +0 -1
  128. package/lib/commonjs/layout/chatWindow.js +0 -214
  129. package/lib/commonjs/layout/chatWindow.js.map +0 -1
  130. package/lib/module/hooks/Stream.js.map +0 -1
  131. package/lib/module/layout/chatIcon.js +0 -44
  132. package/lib/module/layout/chatIcon.js.map +0 -1
  133. package/lib/module/layout/chatWindow.js +0 -204
  134. package/lib/module/layout/chatWindow.js.map +0 -1
  135. package/lib/typescript/hooks/Stream.d.ts.map +0 -1
  136. package/lib/typescript/layout/chatIcon.d.ts.map +0 -1
  137. package/lib/typescript/layout/chatWindow.d.ts +0 -6
  138. package/lib/typescript/layout/chatWindow.d.ts.map +0 -1
  139. package/src/layout/chatIcon.js +0 -38
  140. package/src/layout/chatWindow.js +0 -207
@@ -0,0 +1,240 @@
1
+ import React, { useState, useContext } from "react";
2
+ import { View, Text, Image, TouchableOpacity, TextInput, StyleSheet, Platform } from "react-native";
3
+ import { AppContext } from "../contexts/AppContext";
4
+
5
+ export const ProductCard = ({ prod }) => {
6
+ const { onProductCardClick, onAddToCartClick } = useContext(AppContext);
7
+
8
+ const [selectedUom, setSelectedUom] = useState(() => {
9
+ if (prod.inventory_info?.info_by_uom) {
10
+ const availableUoms = Object.keys(prod.inventory_info.info_by_uom);
11
+ const defaultUom = prod.inventory_info.default_uom;
12
+ return availableUoms.includes(defaultUom) ? defaultUom : availableUoms[0];
13
+ }
14
+ return "EA";
15
+ });
16
+
17
+ const uoms = prod.inventory_info?.info_by_uom
18
+ ? Object.keys(prod.inventory_info.info_by_uom)
19
+ : ["EA"];
20
+ const uomInfo = prod.inventory_info?.info_by_uom?.[selectedUom] || {};
21
+
22
+ const grossPrice = uomInfo.gross_price || 0;
23
+ const netPrice = uomInfo.net_price || 0;
24
+ const isOnSale = uomInfo.is_on_sale || false;
25
+ const discounts = uomInfo.discounts || []
26
+
27
+ const maxQuantity = Math.floor(prod.inventory_info?.info_by_uom?.EA?.quantity_available || 0);
28
+ const valid = prod.inventory_info?.is_valid || false;
29
+ const inStock = maxQuantity > 0;
30
+ const [quantity, setQuantity] = useState(valid && inStock ? 1 : 0);
31
+
32
+ const handleQuantityChange = (text) => {
33
+ const value = parseInt(text) || 0;
34
+ if (value >= 0 && value <= maxQuantity) {
35
+ setQuantity(value);
36
+ }
37
+ };
38
+
39
+ const handleAddToCart = () => {
40
+ onAddToCartClick({selectedUom: "EA", quantity: quantity, product: JSON.stringify(prod)})
41
+ };
42
+
43
+ const handleProductClick = () => {
44
+ onProductCardClick(JSON.stringify(prod))
45
+ }
46
+
47
+ return (
48
+ <View style={styles.card}>
49
+ {/* Two-column layout */}
50
+ <View style={styles.row}>
51
+ {/* Left Column (Image, Price, Availability) */}
52
+ <View style={styles.leftColumn}>
53
+ <TouchableOpacity onPress={handleProductClick}>
54
+ <Image source={{ uri: prod.product_details.image_url }} style={styles.image} />
55
+ </TouchableOpacity>
56
+ {valid &&
57
+ <>
58
+ <View style={styles.priceContainer}>
59
+ {isOnSale ? (
60
+ <>
61
+ <Text style={styles.originalPrice}>${Number(grossPrice).toFixed(2)}</Text>
62
+ <Text style={styles.salePrice}>${Number(netPrice).toFixed(2)}</Text>
63
+ </>
64
+ ) : (
65
+ <Text style={styles.price}>${Number(grossPrice).toFixed(2)}</Text>
66
+ )}
67
+ <Text style={styles.perUnit}> / {selectedUom}</Text>
68
+ </View>
69
+ <Text style={styles.availability}>
70
+ {maxQuantity === 0 ? "0 available" : maxQuantity > 1000 ? "1000+ available" : `${maxQuantity} available`}
71
+ </Text>
72
+ </>
73
+ }
74
+ </View>
75
+
76
+ {/* Right Column (Product Details) */}
77
+ <View style={styles.rightColumn}>
78
+ <TouchableOpacity onPress={handleProductClick}>
79
+ <Text style={styles.productName}>{prod.product_details.product_name}</Text>
80
+ </TouchableOpacity>
81
+
82
+ <Text style={styles.details}>
83
+ <Text style={styles.boldText}>MFG # </Text>{prod.product_details.manufacturer_id}
84
+ </Text>
85
+ <Text style={styles.details}>
86
+ <Text style={styles.boldText}>Part # </Text>{prod.part_number}
87
+ </Text>
88
+
89
+ {/* Bottom Row: Quantity Input & Add to Cart Button */}
90
+ <View style={styles.bottomRow}>
91
+ <TextInput
92
+ value={quantity.toString()}
93
+ onChangeText={handleQuantityChange}
94
+ keyboardType="numeric"
95
+ style={styles.quantityInput}
96
+ editable={valid && inStock}
97
+ />
98
+
99
+ <TouchableOpacity
100
+ onPress={handleAddToCart}
101
+ disabled={!valid || !inStock || quantity === 0}
102
+ style={[
103
+ styles.addToCartButton,
104
+ valid && inStock && quantity > 0 ? styles.activeButton : styles.disabledButton
105
+ ]}
106
+ >
107
+ <Text style={[styles.buttonText, valid && inStock && quantity > 0 ? styles.activeText : styles.disabledText]}>
108
+ Add to Cart
109
+ </Text>
110
+ </TouchableOpacity>
111
+ </View>
112
+ </View>
113
+ </View>
114
+ </View>
115
+ );
116
+ };
117
+
118
+ const styles = StyleSheet.create({
119
+ card: {
120
+ backgroundColor: "#fff",
121
+ width: '100%',
122
+ padding: 10,
123
+ padding: 12,
124
+ paddingHorizontal: 16,
125
+ borderRadius: 12,
126
+ marginBottom: 5
127
+ },
128
+ row: {
129
+ flexDirection: "row",
130
+ alignItems: "flex-start",
131
+ },
132
+ leftColumn: {
133
+ width: "25%",
134
+ alignItems: "center",
135
+ },
136
+ rightColumn: {
137
+ width: "75%",
138
+ paddingLeft: 12,
139
+ },
140
+ image: {
141
+ width: 80,
142
+ height: 80,
143
+ resizeMode: "contain",
144
+ marginBottom: 5,
145
+ },
146
+ price: {
147
+ fontSize: 14,
148
+ fontWeight: "bold",
149
+ textAlign: "center",
150
+ },
151
+ saleTag: {
152
+ backgroundColor: "#ff4757",
153
+ color: "#fff",
154
+ fontSize: 12,
155
+ fontWeight: "bold",
156
+ paddingVertical: 2,
157
+ paddingHorizontal: 5,
158
+ borderRadius: 4,
159
+ marginBottom: 5,
160
+ },
161
+ priceContainer: {
162
+ flexDirection: "row",
163
+ alignItems: "center",
164
+ },
165
+ originalPrice: {
166
+ fontSize: 14,
167
+ textDecorationLine: "line-through",
168
+ color: "gray",
169
+ marginRight: 5,
170
+ },
171
+ salePrice: {
172
+ fontSize: 16,
173
+ fontWeight: "bold",
174
+ color: "#ff4757",
175
+ },
176
+ perUnit: {
177
+ fontSize: 12,
178
+ color: "gray",
179
+ },
180
+ availability: {
181
+ fontSize: 12,
182
+ color: "gray",
183
+ textAlign: "center",
184
+ marginTop: 3,
185
+ },
186
+ productName: {
187
+ fontSize: 16,
188
+ fontWeight: "medium",
189
+ color: "#161616",
190
+ marginBottom: 5,
191
+ },
192
+ details: {
193
+ fontSize: 13,
194
+ color: "#555",
195
+ marginTop: 3,
196
+ },
197
+ boldText: {
198
+ fontWeight: "bold",
199
+ },
200
+ bottomRow: {
201
+ flexDirection: "row",
202
+ alignItems: "center",
203
+ marginTop: 10,
204
+ },
205
+ quantityInput: {
206
+ width: 60,
207
+ height: 35,
208
+ borderWidth: 1,
209
+ borderColor: "rgba(0, 0, 0, 0.23)",
210
+ borderRadius: 4,
211
+ paddingHorizontal: 10,
212
+ textAlign: "center",
213
+ marginRight: 10,
214
+ },
215
+ addToCartButton: {
216
+ flex: 1,
217
+ height: 40,
218
+ justifyContent: "center",
219
+ alignItems: "center",
220
+ borderRadius: 4,
221
+ },
222
+ activeButton: {
223
+ backgroundColor: "#367cb6",
224
+ },
225
+ disabledButton: {
226
+ backgroundColor: "transparent",
227
+ borderWidth: 1,
228
+ borderColor: "rgba(0, 0, 0, 0.23)",
229
+ },
230
+ buttonText: {
231
+ fontSize: 14,
232
+ fontWeight: "bold",
233
+ },
234
+ activeText: {
235
+ color: "#fff",
236
+ },
237
+ disabledText: {
238
+ color: "rgba(0, 0, 0, 0.60)",
239
+ },
240
+ });
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { View, Button, StyleSheet } from 'react-native';
2
+ import { View, Button, StyleSheet, TouchableOpacity, Text } from 'react-native';
3
3
 
4
4
  export const Testing = ({ onProductCardClick, onAddToCartClick }) => {
5
5
 
@@ -29,8 +29,12 @@ export const Testing = ({ onProductCardClick, onAddToCartClick }) => {
29
29
 
30
30
  return (
31
31
  <View style={styles.container}>
32
- <Button title="Product Card Click" onPress={() => onProductCardClick(product)} />
33
- <Button title="Add to Cart" onPress={() => onAddToCartClick({"quantity":1,"product":product})} />
32
+ <TouchableOpacity style={styles.button} onPress={() => onProductCardClick(product)}>
33
+ <Text style={styles.buttonText}>Product Card Click</Text>
34
+ </TouchableOpacity>
35
+ <TouchableOpacity style={styles.button} onPress={() => onAddToCartClick({"quantity":1,"product":product})}>
36
+ <Text style={styles.buttonText}>Add to Cart</Text>
37
+ </TouchableOpacity>
34
38
  </View>
35
39
  );
36
40
  };
@@ -38,10 +42,19 @@ export const Testing = ({ onProductCardClick, onAddToCartClick }) => {
38
42
  const styles = StyleSheet.create({
39
43
  container: {
40
44
  flexDirection: 'row',
45
+ alignItems: 'center',
41
46
  justifyContent: 'space-evenly',
42
- marginVertical: 10,
43
47
  paddingHorizontal: 16,
44
48
  borderTopWidth: 1,
45
49
  borderTopColor: '#DDD',
46
50
  },
51
+ button: {
52
+ backgroundColor: "#d4d4d4",
53
+ paddingVertical: 12,
54
+ paddingHorizontal: 12,
55
+ borderRadius: 5,
56
+ alignItems: "center",
57
+ marginBottom: 10,
58
+ marginTop: 10,
59
+ },
47
60
  });
@@ -0,0 +1,51 @@
1
+ // WelcomeButton.js
2
+ import React, { useContext } from 'react';
3
+ import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
4
+ import { AppContext } from '../contexts/AppContext';
5
+
6
+ const suggestedQuestions = [
7
+ { text: 'What are the hours of my current branch?' },
8
+ { text: 'Do you have part # JNDDEV48 in stock?' },
9
+ { text: 'Do you carry Hayward super pumps?' },
10
+ { text: 'Which grid assembly goes with the Hayward DE4820 filter?' },
11
+ { text: '¿Puedes ayudarme en español?' }
12
+ ];
13
+
14
+ const ButtonComponent = () => {
15
+ const { handleButtonClick } = useContext(AppContext);
16
+
17
+ return (
18
+ <View style={styles.buttonContainer}>
19
+ {suggestedQuestions.map((item, index) => (
20
+ <TouchableOpacity
21
+ key={index}
22
+ style={styles.button}
23
+ onPress={() => handleButtonClick(item.text)}
24
+ >
25
+ <Text style={styles.buttonText}>{item.text}</Text>
26
+ </TouchableOpacity>
27
+ ))}
28
+ </View>
29
+ );
30
+ };
31
+
32
+ const styles = StyleSheet.create({
33
+ buttonContainer: {
34
+ },
35
+ button: {
36
+ backgroundColor: 'white',
37
+ borderColor: '#004687',
38
+ borderWidth: 1,
39
+ borderRadius: 18,
40
+ paddingVertical: 12,
41
+ paddingHorizontal: 16,
42
+ marginBottom: 16,
43
+ },
44
+ buttonText: {
45
+ color: '#004687',
46
+ fontSize: 13,
47
+ fontWeight: '400',
48
+ },
49
+ });
50
+
51
+ export default ButtonComponent;
@@ -0,0 +1,81 @@
1
+ import React, { useState, useEffect, useContext, useRef } from 'react';
2
+ import {
3
+ Text,
4
+ StyleSheet,
5
+ View,
6
+ TextInput,
7
+ TouchableOpacity,
8
+ Platform,
9
+ KeyboardAvoidingView,
10
+ Keyboard
11
+ } from 'react-native';
12
+ import { Header } from '../components/header';
13
+ import { AppContext } from '../contexts/AppContext';
14
+ import Ionicons from 'react-native-vector-icons/Ionicons';
15
+
16
+ export const WelcomeInput = ({ onProductCardClick, onAddToCartClick }) => {
17
+ const { handleSend, input, setInput, showModal, theme } = useContext(AppContext);
18
+
19
+ return (
20
+ <View style={styles.inputContainer}>
21
+ <TextInput
22
+ style={styles.input}
23
+ value={input}
24
+ onChangeText={setInput}
25
+ placeholder="Ask a question..."
26
+ placeholderTextColor="#999"
27
+ multiline
28
+ />
29
+ <TouchableOpacity style={styles.inputButton}>
30
+ <Ionicons name="mic-outline" size={24} color="#8E8E93" />
31
+ </TouchableOpacity>
32
+ <TouchableOpacity
33
+ style={styles.sendButton}
34
+ onPress={() => handleSend(input)}
35
+ disabled={!input.trim()}
36
+ >
37
+ <Ionicons
38
+ name="paper-plane-outline"
39
+ size={24}
40
+ color={input.trim() ? theme.primaryColor : '#8E8E93'}
41
+ />
42
+ </TouchableOpacity>
43
+ </View>
44
+ );
45
+ };
46
+
47
+ const styles = StyleSheet.create({
48
+ inputContainer: {
49
+ flexDirection: 'row',
50
+ alignItems: 'center',
51
+ paddingHorizontal: 8,
52
+ paddingVertical: 8,
53
+ backgroundColor: '#FFFFFF',
54
+ borderRadius: 16,
55
+ shadowColor: '#000',
56
+ shadowOffset: {
57
+ width: 0,
58
+ height: 2,
59
+ },
60
+ shadowOpacity: 0.1,
61
+ shadowRadius: 4,
62
+ elevation: 3,
63
+ },
64
+ input: {
65
+ flex: 1,
66
+ fontSize: 16,
67
+ paddingVertical: 8,
68
+ paddingHorizontal: 12,
69
+ color: '#000000',
70
+ },
71
+ inputButton: {
72
+ padding: 6,
73
+ },
74
+ sendButton: {
75
+ padding: 6,
76
+ marginLeft: 'auto',
77
+ },
78
+ disabledButton: {
79
+ opacity: 0.7,
80
+ },
81
+ });