@propel-nsl/propel-react-native-sdk 1.1.1 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@propel-nsl/propel-react-native-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Propel Mobile SDK - React Native Core",
5
5
  "files": [
6
6
  "src/",
@@ -89,30 +89,44 @@ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
89
89
  }, [dispatch, cartId, isFocus]);
90
90
 
91
91
  const handleQuantitySelect = (quantity: number) => {
92
+ console.log('🟢 handleQuantitySelect called, quantity:', quantity);
93
+ console.log('🔍 handleQuantitySelect called, quantity:', quantity); // Added debug log
92
94
  setSelectedQuantity(quantity);
93
95
  setSelectedQty(quantity);
94
96
  };
95
97
 
96
98
  const handleItem = async (item: any) => {
99
+ console.log('🟡 handleItem called, item:', JSON.stringify(item?.name), 'quantity:', item?.quantity);
100
+ console.log('🔍 handleItem called, item:', JSON.stringify(item?.name), 'quantity:', item?.quantity); // Added debug log
97
101
  setSelectedItem(item);
98
102
  setSelectedQuantity(item.quantity);
99
103
  };
100
104
 
101
105
  const handleUpdate = () => {
102
- dispatch(
103
- updateCartRequest({
104
- id: cartId,
105
- item: {
106
- product_variation_id: selectedItem?.variation?.id,
107
- quantity: selectedQty,
108
- shipping_address: {
109
- email: selectedItem?.shipping_address?.email,
110
- phone_numbers: selectedItem?.shipping_address?.phone_numbers[0],
111
- },
106
+ console.log('🔄 handleUpdate called');
107
+ console.log('🔍 handleUpdate called'); // Added debug log
108
+ console.log('cartId:', cartId);
109
+ console.log('selectedItem:', selectedItem);
110
+ console.log('selectedQty:', selectedQty);
111
+ console.log('product_variation_id:', selectedItem?.variation?.id);
112
+ console.log('shipping_address:', selectedItem?.shipping_address);
113
+
114
+ const payload = {
115
+ id: cartId,
116
+ item: {
117
+ product_variation_id: selectedItem?.variation?.id,
118
+ quantity: selectedQty,
119
+ shipping_address: {
120
+ email: selectedItem?.shipping_address?.email,
121
+ phone_numbers: selectedItem?.shipping_address?.phone_numbers[0],
112
122
  },
113
- skip_payable_validation: true,
114
- }),
115
- );
123
+ },
124
+ skip_payable_validation: true,
125
+ };
126
+
127
+ console.log('📤 Dispatching updateCartRequest with payload:', JSON.stringify(payload));
128
+ console.log('🔍 Dispatching updateCartRequest with payload:', JSON.stringify(payload)); // Added debug log
129
+ dispatch(updateCartRequest(payload));
116
130
  setVisible(false);
117
131
  };
118
132
 
@@ -176,6 +190,8 @@ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
176
190
  activeOpacity={0.7}
177
191
  style={styles.productQuantityContainer}
178
192
  onPress={() => {
193
+ console.log('🟣 Qty button pressed, opening modal');
194
+ console.log('🔍 Qty button pressed, opening modal');
179
195
  handleItem(item);
180
196
  setVisible(true);
181
197
  }}
@@ -186,7 +202,7 @@ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
186
202
  </Text>
187
203
  <CustomImage source={Images.greyDownArrow} imgStyle={styles.icon} />
188
204
  </TouchableOpacity>
189
- <Text style={styles.productPoints}>{item?.amount_cents / 100} {POINTS}</Text>
205
+ <Text style={styles.productPoints}>{item?.amount_cents / 100} points</Text>
190
206
  </View>
191
207
  </View>
192
208
  );
@@ -259,17 +275,10 @@ const MyCart: React.FC<MyCartProps> = ({ navigation }) => {
259
275
  {!!viewMyCartData?.items?.length && (
260
276
  <View style={styles.stickyButtonContainer}>
261
277
  <View style={styles.bottomContent}>
262
- <View style={styles.bottomRow}>
263
- <Text style={styles.leftText}>{REMAINING_AMOUNT}</Text>
264
- <Text style={styles.rightText}>
265
- {viewMyCartData?.total_amount_cents / 100} {POINTS}
266
- </Text>
267
- </View>
268
- <View style={styles.separator} />
269
278
  <View style={styles.bottomRow}>
270
279
  <Text style={styles.amountText}>{AMOUNT_TO_BE_PAID}</Text>
271
280
  <Text style={styles.amountPoints}>
272
- {viewMyCartData?.total_amount_cents / 100} {POINTS}
281
+ {viewMyCartData?.total_amount_cents / 100}
273
282
  </Text>
274
283
  </View>
275
284
  </View>
@@ -199,7 +199,7 @@ const PaymentMethod: React.FC<{
199
199
  <View style={styles.balancepointsContainer}>
200
200
  <View style={styles.headerRow}>
201
201
  <Text style={[styles.label, { color: 'black' }]}>
202
- {viewMyCartData?.total_amount_cents / 100} Apna Points
202
+ {viewMyCartData?.total_amount_cents / 100}
203
203
  </Text>
204
204
  <TouchableOpacity
205
205
  style={styles.row}
@@ -662,6 +662,7 @@ const ProductDetail: React.FC = () => {
662
662
  }}
663
663
  label_1={ORDER_AMOUNT}
664
664
  label_2={DELIVERY_CHARGES}
665
+ quantity={quantity}
665
666
  />
666
667
  )}
667
668
 
@@ -5,6 +5,7 @@ import {
5
5
  TouchableWithoutFeedback,
6
6
  Dimensions,
7
7
  } from 'react-native';
8
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
8
9
  import styles from './styles';
9
10
  import CustomImage from '../CustomImage';
10
11
  import Images from '../../constants/Images';
@@ -23,6 +24,7 @@ interface OTPModalProps {
23
24
  };
24
25
  label_1: string;
25
26
  label_2: string;
27
+ quantity?: number;
26
28
  }
27
29
 
28
30
  const AmountModal: React.FC<OTPModalProps> = ({
@@ -31,7 +33,9 @@ const AmountModal: React.FC<OTPModalProps> = ({
31
33
  item,
32
34
  label_1,
33
35
  label_2,
36
+ quantity = 1,
34
37
  }) => {
38
+ const insets = useSafeAreaInsets();
35
39
  if (!visible) return null;
36
40
 
37
41
  // Use absolute positioning instead of Modal for SDK/AAR compatibility
@@ -41,13 +45,13 @@ const AmountModal: React.FC<OTPModalProps> = ({
41
45
  <View style={styles.overlay} />
42
46
  </TouchableWithoutFeedback>
43
47
 
44
- <View style={styles.modalContainer}>
48
+ <View style={[styles.modalContainer, { marginBottom: Math.max(insets.bottom, 60) }]}>
45
49
  {/* Handle bar */}
46
50
  <View style={styles.handleBar} />
47
51
 
48
52
  {/* Title */}
49
53
  <View style={styles.row}>
50
- <Text style={styles.title}>{AMOUNT_BREAKDOWN}</Text>
54
+ <Text style={styles.title}>{AMOUNT_BREAKDOWN} 1</Text>
51
55
  <CustomImage
52
56
  source={Images.blackcrossIcon}
53
57
  imgStyle={styles.icon}
@@ -59,7 +63,7 @@ const AmountModal: React.FC<OTPModalProps> = ({
59
63
  <View style={styles.row}>
60
64
  <Text style={styles.leftText}>{label_1}</Text>
61
65
  <Text style={styles.rightText}>
62
- {item.total_amount_cents / 100} {POINTS}
66
+ {(item.total_amount_cents * quantity) / 100} {POINTS}
63
67
  </Text>
64
68
  </View>
65
69
  {/* <View style={styles.row}>
@@ -75,7 +79,7 @@ const AmountModal: React.FC<OTPModalProps> = ({
75
79
  <View style={styles.row}>
76
80
  <Text style={styles.amountText}> {AMOUNT_TO_BE_PAID}</Text>
77
81
  <Text style={styles.amountPoints}>
78
- {pointsFromCentsFixed(item.grand_total, 1)} {POINTS}
82
+ {pointsFromCentsFixed(item.grand_total * quantity, 1)} {POINTS}
79
83
  </Text>
80
84
  </View>
81
85
  </View>
@@ -29,12 +29,14 @@ const styles = StyleSheet.create({
29
29
  modalContainer: {
30
30
  width: '100%',
31
31
  maxWidth: '100%',
32
- height: Platform.OS === 'ios' ? VSCALE(230) : VSCALE(250),
32
+ height: Platform.OS === 'ios' ? VSCALE(280) : VSCALE(300),
33
33
  backgroundColor: '#FFFFFF',
34
34
  borderTopLeftRadius: SCALE(30),
35
35
  borderTopRightRadius: SCALE(30),
36
36
  paddingHorizontal: SCALE(20),
37
37
  paddingTop: VSCALE(15),
38
+ paddingBottom: VSCALE(20),
39
+ marginBottom: VSCALE(60),
38
40
  },
39
41
  handleBar: {
40
42
  width: SCALE(48),
@@ -378,11 +378,23 @@ function* handleUpdateCart(
378
378
  action: ReturnType<typeof updateCartRequest>
379
379
  ): SagaIterator {
380
380
  try {
381
- const { id, item } = action.payload;
382
- const response = yield call(updateCartApi, id, item);
381
+ console.log('🔵 handleUpdateCart saga called');
382
+ console.log('action.payload:', JSON.stringify(action.payload));
383
+ const { id, item, skip_payable_validation } = action.payload;
384
+ console.log('Extracted - id:', id, 'item:', JSON.stringify(item), 'skip_payable_validation:', skip_payable_validation);
385
+
386
+ const payload = {
387
+ skip_payable_validation,
388
+ item,
389
+ };
390
+ console.log('📡 Calling updateCartApi with orderId:', id, 'payload:', JSON.stringify(payload));
391
+
392
+ const response = yield call(updateCartApi, id, payload);
393
+ console.log('✅ updateCartApi response:', JSON.stringify(response.data));
383
394
  yield put(updateCartSuccess(response.data));
384
395
  yield put(viewMyCartRequest({ id }));
385
396
  } catch (error: any) {
397
+ console.log('❌ updateCartApi error:', error?.response?.data || error?.message);
386
398
  yield put(updateCartFailure(error?.response?.data?.errors));
387
399
  }
388
400
  }
@@ -18,7 +18,7 @@ const ENDPOINTS = {
18
18
  CREATE_ADDRESS: 'api/v1/orders/addresses',
19
19
  UPDATE_ADDRESS: 'api/v1/orders/addresses',
20
20
  DELETE_ADDRESS: 'api/v1/orders/addresses',
21
- UPDATE_CART: (orderId: string | number) => `api/v1/orders/${orderId}/items`,
21
+ UPDATE_CART: (orderId: string | number) => `api/v1/propel/orders/${orderId}/items`,
22
22
  DELETE_CART: (orderId: string | number) => `api/v1/orders/${orderId}/items`,
23
23
  ADD_TO_CART: 'api/v1/orders',
24
24
  ADD_TO_EXISTING_CART: (orderId: string | number) =>