@whatmore-repo/whatmore-reactnative-sdk 1.0.36 → 1.0.38

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/index.js CHANGED
@@ -13,6 +13,7 @@ export function WhatmoreBase(props){
13
13
  setGlobalState('modalUsed', props.modalUsed);
14
14
  setGlobalState('activateMock', props.activateMock);
15
15
  setGlobalState('customStyles', props.customStyles);
16
+ setGlobalState('collectionId', props.collectionId ?? "");
16
17
  }, []);
17
18
 
18
19
  // return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatmore-repo/whatmore-reactnative-sdk",
3
- "version": "1.0.36",
3
+ "version": "1.0.38",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "index.js",
@@ -36,26 +36,31 @@ export default function WhatmoreRootComponent(props) {
36
36
  const [error, setError] = useState();
37
37
  const [isModalOpen, setIsModalOpen] = useState(false);
38
38
  const [initialEventIndex, setInitialEventIndex] = useState(0)
39
+ const collectionId = getGlobalState('collectionId');
40
+ const isCollectionsTemplate = collectionId != "";
39
41
 
40
42
  var eventStatuses = "live,upcoming";
41
43
  var isActive = "true";
42
44
 
43
45
  var whatmoreBackendEventsUrl = WHATMORE_BACKEND_BASE_URL + "/v1/events/";
46
+ var whatmoreBackendCollectionEventsUrl = WHATMORE_BACKEND_BASE_URL + "v2/collection";
47
+ let url = "";
48
+ if(isCollectionsTemplate){
49
+ url = whatmoreBackendCollectionEventsUrl + "?store_id=" + brandId.toString() + "&client_collection_id=" + collectionId;
50
+ }else{
51
+ url = whatmoreBackendEventsUrl + brandId + "?status=" + eventStatuses.toString() + "&is_active=" + isActive.toString();
52
+ }
44
53
 
45
54
  /**
46
55
  * external network calls
47
56
  */
48
57
 
49
58
  useEffect(() => {
50
- var url;
51
- url = whatmoreBackendEventsUrl.toString() + brandId.toString()
52
- + '?status=' + eventStatuses.toString()
53
- + '&is_active=' + isActive.toString();
54
59
  fetch(url)
55
60
  .then((response) => response.json())
56
- // .then((data) => {
57
- // return extractEvents(data, false);
58
- // })
61
+ .then((data) => {
62
+ return extractEvents(data, isCollectionsTemplate);
63
+ })
59
64
  .then((data) => {
60
65
  logEventData && console.log("initial received events size : " + data.length);
61
66
  return removeInvalidEvents(data, brandId);
@@ -15,5 +15,6 @@ export const { GlobalStateProvider, useGlobalState, getGlobalState, setGlobalSta
15
15
  template: 'template-swipe-a',
16
16
  modalUsed: true,
17
17
  activateMock: false,
18
+ collectionId: "",
18
19
  customStyles: {}
19
20
  });
@@ -1,5 +1,6 @@
1
1
 
2
2
  import getSymbolFromCurrency from 'currency-symbol-map'
3
+ import { getGlobalState } from '../globals/useAppState_APP';
3
4
 
4
5
  function priceWithCommas(price){
5
6
  return price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
@@ -23,6 +24,8 @@ export function getPriceStringWithCurrency(price, spaceString = "", currencyCode
23
24
  if(!price || typeof price == undefined){
24
25
  return "";
25
26
  }
27
+ const whatmoreShopId = getGlobalState('whatmoreShopId')
28
+ const finalCurrency = whatmoreShopId == "68234805419" ? "QAR": getSymbolFromCurrency(currencyCode ?? "INR")
26
29
 
27
- return getSymbolFromCurrency(currencyCode ?? "INR") + spaceString + priceWithCommas(roundedPrice(price));
30
+ return finalCurrency + spaceString + priceWithCommas(roundedPrice(price));
28
31
  }