react-native-srschat 0.1.30 → 0.1.32
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/lib/commonjs/components/input.js +20 -1
- package/lib/commonjs/components/input.js.map +1 -1
- package/lib/commonjs/components/productCard.js +163 -36
- package/lib/commonjs/components/productCard.js.map +1 -1
- package/lib/commonjs/components/welcomeInput.js +20 -1
- package/lib/commonjs/components/welcomeInput.js.map +1 -1
- package/lib/module/components/input.js +20 -1
- package/lib/module/components/input.js.map +1 -1
- package/lib/module/components/productCard.js +163 -36
- package/lib/module/components/productCard.js.map +1 -1
- package/lib/module/components/welcomeInput.js +20 -1
- package/lib/module/components/welcomeInput.js.map +1 -1
- package/lib/typescript/components/input.d.ts.map +1 -1
- package/lib/typescript/components/productCard.d.ts.map +1 -1
- package/lib/typescript/components/welcomeInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/input.js +20 -1
- package/src/components/productCard.js +211 -58
- package/src/components/welcomeInput.js +20 -1
|
@@ -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 = uomInfo.discounts || [];
|
|
28
|
+
|
|
28
29
|
|
|
29
30
|
const maxQuantity = Math.floor(prod.inventory_info?.info_by_uom?.EA?.quantity_available || 0);
|
|
30
31
|
const valid = prod.inventory_info?.is_valid || false;
|
|
@@ -64,6 +65,18 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
67
|
|
|
68
|
+
const incrementQuantity = () => {
|
|
69
|
+
if (quantity < maxQuantity) {
|
|
70
|
+
setQuantity(prevQuantity => prevQuantity + 1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const decrementQuantity = () => {
|
|
75
|
+
if (quantity > 0) {
|
|
76
|
+
setQuantity(prevQuantity => prevQuantity - 1);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
67
80
|
const handleAddToCart = () => {
|
|
68
81
|
onAddToCartClick({
|
|
69
82
|
selectedUom: "EA",
|
|
@@ -81,6 +94,10 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
81
94
|
onProductCardClick(prodWithSku);
|
|
82
95
|
};
|
|
83
96
|
|
|
97
|
+
const handleUomChange = (value) => {
|
|
98
|
+
setSelectedUom(value);
|
|
99
|
+
};
|
|
100
|
+
|
|
84
101
|
return (
|
|
85
102
|
<View style={styles.card}>
|
|
86
103
|
{/* Two-column layout */}
|
|
@@ -88,6 +105,11 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
88
105
|
{/* Left Column (Image, Price, Availability) */}
|
|
89
106
|
<View style={styles.leftColumn}>
|
|
90
107
|
<TouchableOpacity onPress={handleProductClick}>
|
|
108
|
+
{isOnSale && (
|
|
109
|
+
<View style={styles.saleTag}>
|
|
110
|
+
<Text style={styles.saleTagText}>SALE</Text>
|
|
111
|
+
</View>
|
|
112
|
+
)}
|
|
91
113
|
<Image source={{ uri: prod.product_details.image_url }} style={styles.image} />
|
|
92
114
|
</TouchableOpacity>
|
|
93
115
|
{valid &&
|
|
@@ -123,43 +145,104 @@ export const ProductCard = ({ prod, onFocusQuantityInput }) => {
|
|
|
123
145
|
<Text style={styles.boldText}>Part # </Text>{prod.part_number}
|
|
124
146
|
</Text>
|
|
125
147
|
|
|
126
|
-
{/*
|
|
127
|
-
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
height: 40,
|
|
136
|
-
minHeight: 40,
|
|
137
|
-
maxHeight: 40
|
|
138
|
-
}
|
|
139
|
-
]}
|
|
140
|
-
editable={valid && inStock}
|
|
141
|
-
underlineColorAndroid="transparent"
|
|
142
|
-
autoCorrect={false}
|
|
143
|
-
autoCapitalize="none"
|
|
144
|
-
caretHidden={false}
|
|
145
|
-
contextMenuHidden={true}
|
|
146
|
-
disableFullscreenUI={true}
|
|
147
|
-
defaultValue="1"
|
|
148
|
-
/>
|
|
148
|
+
{/* Display discounts if available */}
|
|
149
|
+
{discounts.length > 0 && (
|
|
150
|
+
<View style={styles.discountContainer}>
|
|
151
|
+
{discounts.map((discount, index) => (
|
|
152
|
+
<Text key={index} style={styles.discountText}>{discount}</Text>
|
|
153
|
+
))}
|
|
154
|
+
</View>
|
|
155
|
+
)}
|
|
149
156
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
style={
|
|
154
|
-
styles.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
{/* Input Section with UOM Selector and Quantity */}
|
|
158
|
+
<View style={styles.inputRow}>
|
|
159
|
+
{uoms.length > 1 ? (
|
|
160
|
+
<View style={styles.uomSelectorContainer}>
|
|
161
|
+
<Text style={styles.inputLabel}>Unit</Text>
|
|
162
|
+
<View style={[styles.uomSelector, { height: 40 }]}>
|
|
163
|
+
{uoms.map((uom) => (
|
|
164
|
+
<TouchableOpacity
|
|
165
|
+
key={uom}
|
|
166
|
+
style={[
|
|
167
|
+
styles.uomOption,
|
|
168
|
+
selectedUom === uom && styles.selectedUomOption,
|
|
169
|
+
{ height: 40 }
|
|
170
|
+
]}
|
|
171
|
+
onPress={() => handleUomChange(uom)}
|
|
172
|
+
disabled={!valid}
|
|
173
|
+
>
|
|
174
|
+
<Text
|
|
175
|
+
style={[
|
|
176
|
+
styles.uomText,
|
|
177
|
+
selectedUom === uom && styles.selectedUomText
|
|
178
|
+
]}
|
|
179
|
+
>
|
|
180
|
+
{uom}
|
|
181
|
+
</Text>
|
|
182
|
+
</TouchableOpacity>
|
|
183
|
+
))}
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
) : null}
|
|
187
|
+
|
|
188
|
+
<View style={styles.quantityContainer}>
|
|
189
|
+
<Text style={styles.inputLabel}>Qty</Text>
|
|
190
|
+
<View style={styles.quantityInputContainer}>
|
|
191
|
+
<TouchableOpacity
|
|
192
|
+
style={styles.quantityButton}
|
|
193
|
+
onPress={decrementQuantity}
|
|
194
|
+
disabled={!valid || quantity <= 0}
|
|
195
|
+
>
|
|
196
|
+
<Ionicons
|
|
197
|
+
name="remove"
|
|
198
|
+
size={18}
|
|
199
|
+
color={valid && quantity > 0 ? "#367cb6" : "rgba(0, 0, 0, 0.23)"}
|
|
200
|
+
/>
|
|
201
|
+
</TouchableOpacity>
|
|
202
|
+
|
|
203
|
+
<TextInput
|
|
204
|
+
value={quantity.toString()}
|
|
205
|
+
onChangeText={handleQuantityChange}
|
|
206
|
+
keyboardType="numeric"
|
|
207
|
+
style={styles.quantityInput}
|
|
208
|
+
editable={valid && inStock}
|
|
209
|
+
underlineColorAndroid="transparent"
|
|
210
|
+
autoCorrect={false}
|
|
211
|
+
autoCapitalize="none"
|
|
212
|
+
caretHidden={false}
|
|
213
|
+
contextMenuHidden={true}
|
|
214
|
+
disableFullscreenUI={true}
|
|
215
|
+
defaultValue="1"
|
|
216
|
+
/>
|
|
217
|
+
|
|
218
|
+
<TouchableOpacity
|
|
219
|
+
style={styles.quantityButton}
|
|
220
|
+
onPress={incrementQuantity}
|
|
221
|
+
disabled={!valid || quantity >= maxQuantity}
|
|
222
|
+
>
|
|
223
|
+
<Ionicons
|
|
224
|
+
name="add"
|
|
225
|
+
size={18}
|
|
226
|
+
color={valid && quantity < maxQuantity ? "#367cb6" : "rgba(0, 0, 0, 0.23)"}
|
|
227
|
+
/>
|
|
228
|
+
</TouchableOpacity>
|
|
229
|
+
</View>
|
|
230
|
+
</View>
|
|
162
231
|
</View>
|
|
232
|
+
|
|
233
|
+
{/* Add to Cart Button on a new line */}
|
|
234
|
+
<TouchableOpacity
|
|
235
|
+
onPress={handleAddToCart}
|
|
236
|
+
disabled={!valid || !inStock || quantity === 0}
|
|
237
|
+
style={[
|
|
238
|
+
styles.addToCartButton,
|
|
239
|
+
valid && inStock && quantity > 0 ? styles.activeButton : styles.disabledButton
|
|
240
|
+
]}
|
|
241
|
+
>
|
|
242
|
+
<Text style={[styles.buttonText, valid && inStock && quantity > 0 ? styles.activeText : styles.disabledText]}>
|
|
243
|
+
Add to Cart
|
|
244
|
+
</Text>
|
|
245
|
+
</TouchableOpacity>
|
|
163
246
|
</View>
|
|
164
247
|
</View>
|
|
165
248
|
</View>
|
|
@@ -170,7 +253,6 @@ const styles = StyleSheet.create({
|
|
|
170
253
|
card: {
|
|
171
254
|
backgroundColor: "#fff",
|
|
172
255
|
width: '100%',
|
|
173
|
-
padding: 10,
|
|
174
256
|
padding: 12,
|
|
175
257
|
paddingHorizontal: 16,
|
|
176
258
|
borderRadius: 12,
|
|
@@ -183,6 +265,7 @@ const styles = StyleSheet.create({
|
|
|
183
265
|
leftColumn: {
|
|
184
266
|
width: "25%",
|
|
185
267
|
alignItems: "center",
|
|
268
|
+
position: "relative",
|
|
186
269
|
},
|
|
187
270
|
rightColumn: {
|
|
188
271
|
width: "75%",
|
|
@@ -194,24 +277,31 @@ const styles = StyleSheet.create({
|
|
|
194
277
|
resizeMode: "contain",
|
|
195
278
|
marginBottom: 5,
|
|
196
279
|
},
|
|
280
|
+
saleTag: {
|
|
281
|
+
position: "absolute",
|
|
282
|
+
top: 0,
|
|
283
|
+
left: 0,
|
|
284
|
+
backgroundColor: "red",
|
|
285
|
+
borderRadius: 4,
|
|
286
|
+
paddingVertical: 2,
|
|
287
|
+
paddingHorizontal: 5,
|
|
288
|
+
zIndex: 1,
|
|
289
|
+
},
|
|
290
|
+
saleTagText: {
|
|
291
|
+
color: "#fff",
|
|
292
|
+
fontSize: 10,
|
|
293
|
+
fontWeight: "bold",
|
|
294
|
+
},
|
|
197
295
|
price: {
|
|
198
296
|
fontSize: 14,
|
|
199
297
|
fontWeight: "bold",
|
|
200
298
|
textAlign: "center",
|
|
201
299
|
},
|
|
202
|
-
saleTag: {
|
|
203
|
-
backgroundColor: "#ff4757",
|
|
204
|
-
color: "#fff",
|
|
205
|
-
fontSize: 12,
|
|
206
|
-
fontWeight: "bold",
|
|
207
|
-
paddingVertical: 2,
|
|
208
|
-
paddingHorizontal: 5,
|
|
209
|
-
borderRadius: 4,
|
|
210
|
-
marginBottom: 5,
|
|
211
|
-
},
|
|
212
300
|
priceContainer: {
|
|
213
301
|
flexDirection: "row",
|
|
214
302
|
alignItems: "center",
|
|
303
|
+
flexWrap: "wrap",
|
|
304
|
+
justifyContent: "center",
|
|
215
305
|
},
|
|
216
306
|
originalPrice: {
|
|
217
307
|
fontSize: 14,
|
|
@@ -222,7 +312,7 @@ const styles = StyleSheet.create({
|
|
|
222
312
|
salePrice: {
|
|
223
313
|
fontSize: 16,
|
|
224
314
|
fontWeight: "bold",
|
|
225
|
-
color: "
|
|
315
|
+
color: "red",
|
|
226
316
|
},
|
|
227
317
|
perUnit: {
|
|
228
318
|
fontSize: 12,
|
|
@@ -250,29 +340,92 @@ const styles = StyleSheet.create({
|
|
|
250
340
|
boldText: {
|
|
251
341
|
fontWeight: "bold",
|
|
252
342
|
},
|
|
253
|
-
|
|
343
|
+
discountContainer: {
|
|
344
|
+
marginTop: 5,
|
|
345
|
+
marginBottom: 5,
|
|
346
|
+
},
|
|
347
|
+
discountText: {
|
|
348
|
+
fontSize: 13,
|
|
349
|
+
color: "#e41e31",
|
|
350
|
+
fontWeight: "500",
|
|
351
|
+
// backgroundColor: "#f0f7ff",
|
|
352
|
+
// borderWidth: 1,
|
|
353
|
+
// borderColor: "#bae0ff",
|
|
354
|
+
// borderRadius: 4,
|
|
355
|
+
// padding: 3,
|
|
356
|
+
marginTop: 3,
|
|
357
|
+
},
|
|
358
|
+
inputRow: {
|
|
254
359
|
flexDirection: "row",
|
|
255
|
-
alignItems: "
|
|
360
|
+
alignItems: "flex-end",
|
|
256
361
|
marginTop: 10,
|
|
362
|
+
marginBottom: 10,
|
|
257
363
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
364
|
+
uomSelectorContainer: {
|
|
365
|
+
marginRight: 10,
|
|
366
|
+
},
|
|
367
|
+
inputLabel: {
|
|
368
|
+
fontSize: 12,
|
|
369
|
+
color: "rgba(0, 0, 0, 0.6)",
|
|
370
|
+
marginBottom: 4,
|
|
371
|
+
},
|
|
372
|
+
uomSelector: {
|
|
373
|
+
flexDirection: "row",
|
|
261
374
|
borderWidth: 1,
|
|
262
375
|
borderColor: "rgba(0, 0, 0, 0.23)",
|
|
263
376
|
borderRadius: 4,
|
|
264
|
-
|
|
377
|
+
overflow: "hidden",
|
|
378
|
+
height: 40,
|
|
379
|
+
},
|
|
380
|
+
uomOption: {
|
|
381
|
+
paddingHorizontal: 12,
|
|
382
|
+
backgroundColor: "transparent",
|
|
383
|
+
justifyContent: "center",
|
|
384
|
+
alignItems: "center",
|
|
385
|
+
height: 40,
|
|
386
|
+
},
|
|
387
|
+
selectedUomOption: {
|
|
388
|
+
backgroundColor: "#367cb6",
|
|
389
|
+
},
|
|
390
|
+
uomText: {
|
|
391
|
+
fontSize: 14,
|
|
392
|
+
color: "#555",
|
|
393
|
+
},
|
|
394
|
+
selectedUomText: {
|
|
395
|
+
color: "#fff",
|
|
396
|
+
fontWeight: "bold",
|
|
397
|
+
},
|
|
398
|
+
quantityContainer: {
|
|
399
|
+
flex: 1,
|
|
400
|
+
},
|
|
401
|
+
quantityInputContainer: {
|
|
402
|
+
flexDirection: "row",
|
|
403
|
+
alignItems: "center",
|
|
404
|
+
height: 40,
|
|
405
|
+
borderWidth: 1,
|
|
406
|
+
borderColor: "rgba(0, 0, 0, 0.23)",
|
|
407
|
+
borderRadius: 4,
|
|
408
|
+
},
|
|
409
|
+
quantityButton: {
|
|
410
|
+
width: 40,
|
|
411
|
+
height: 40,
|
|
412
|
+
justifyContent: "center",
|
|
413
|
+
alignItems: "center",
|
|
414
|
+
},
|
|
415
|
+
quantityInput: {
|
|
416
|
+
flex: 1,
|
|
417
|
+
height: 40,
|
|
265
418
|
textAlign: "center",
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
419
|
+
paddingHorizontal: 5,
|
|
420
|
+
fontSize: 14,
|
|
421
|
+
minWidth: 40,
|
|
269
422
|
},
|
|
270
423
|
addToCartButton: {
|
|
271
|
-
flex: 1,
|
|
272
424
|
height: 40,
|
|
273
425
|
justifyContent: "center",
|
|
274
426
|
alignItems: "center",
|
|
275
427
|
borderRadius: 4,
|
|
428
|
+
marginTop: 5,
|
|
276
429
|
},
|
|
277
430
|
activeButton: {
|
|
278
431
|
backgroundColor: "#367cb6",
|
|
@@ -18,6 +18,20 @@ export const WelcomeInput = ({ onProductCardClick, onAddToCartClick }) => {
|
|
|
18
18
|
|
|
19
19
|
const { data, handleSend, input, setInput, showModal, theme } = useContext(AppContext);
|
|
20
20
|
|
|
21
|
+
const handleKeyPress = ({ nativeEvent }) => {
|
|
22
|
+
if (nativeEvent.key === 'return' && !nativeEvent.shiftKey) {
|
|
23
|
+
nativeEvent.preventDefault && nativeEvent.preventDefault();
|
|
24
|
+
handleSend(input);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const onSubmitEditing = () => {
|
|
30
|
+
if (input.trim()) {
|
|
31
|
+
handleSend(input);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
21
35
|
return (
|
|
22
36
|
<View style={styles.inputContainer}>
|
|
23
37
|
<TextInput
|
|
@@ -26,7 +40,12 @@ export const WelcomeInput = ({ onProductCardClick, onAddToCartClick }) => {
|
|
|
26
40
|
onChangeText={setInput}
|
|
27
41
|
placeholder="Ask a question..."
|
|
28
42
|
placeholderTextColor="#999"
|
|
29
|
-
multiline
|
|
43
|
+
multiline={false}
|
|
44
|
+
returnKeyType="send"
|
|
45
|
+
enablesReturnKeyAutomatically={true}
|
|
46
|
+
onKeyPress={handleKeyPress}
|
|
47
|
+
onSubmitEditing={onSubmitEditing}
|
|
48
|
+
blurOnSubmit={false}
|
|
30
49
|
/>
|
|
31
50
|
<VoiceButton/>
|
|
32
51
|
<TouchableOpacity
|