@whatmore-repo/whatmore-reactnative-sdk 1.0.37 → 1.0.39

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.37",
3
+ "version": "1.0.39",
4
4
  "description": "",
5
5
  "private": false,
6
6
  "main": "index.js",
@@ -2,6 +2,7 @@ import React, { useState, useEffect, lazy } from 'react';
2
2
  import { WHATMORE_BACKEND_BASE_URL } from '../constants/AppGlobalVars';
3
3
  import { extractEvents, removeInvalidEvents } from '../utils/EventSanityUtils';
4
4
  import { View } from 'react-native';
5
+ import { getGlobalState } from '../globals/useAppState_APP';
5
6
  // import EventTileWithProduct from './carousel-view/EventTileWithProduct.js';
6
7
  const EventTileWithProduct = lazy(() => import('./carousel-view/EventTileWithProduct.js'));
7
8
  const EventClickComponent = lazy(() => import('./EventClickComponent'));
@@ -36,26 +37,31 @@ export default function WhatmoreRootComponent(props) {
36
37
  const [error, setError] = useState();
37
38
  const [isModalOpen, setIsModalOpen] = useState(false);
38
39
  const [initialEventIndex, setInitialEventIndex] = useState(0)
40
+ const collectionId = getGlobalState('collectionId');
41
+ const isCollectionsTemplate = collectionId != "";
39
42
 
40
43
  var eventStatuses = "live,upcoming";
41
44
  var isActive = "true";
42
45
 
43
46
  var whatmoreBackendEventsUrl = WHATMORE_BACKEND_BASE_URL + "/v1/events/";
47
+ var whatmoreBackendCollectionEventsUrl = WHATMORE_BACKEND_BASE_URL + "v2/collection";
48
+ let url = "";
49
+ if(isCollectionsTemplate){
50
+ url = whatmoreBackendCollectionEventsUrl + "?store_id=" + brandId.toString() + "&client_collection_id=" + collectionId;
51
+ }else{
52
+ url = whatmoreBackendEventsUrl + brandId + "?status=" + eventStatuses.toString() + "&is_active=" + isActive.toString();
53
+ }
44
54
 
45
55
  /**
46
56
  * external network calls
47
57
  */
48
58
 
49
59
  useEffect(() => {
50
- var url;
51
- url = whatmoreBackendEventsUrl.toString() + brandId.toString()
52
- + '?status=' + eventStatuses.toString()
53
- + '&is_active=' + isActive.toString();
54
60
  fetch(url)
55
61
  .then((response) => response.json())
56
- // .then((data) => {
57
- // return extractEvents(data, false);
58
- // })
62
+ .then((data) => {
63
+ return extractEvents(data, isCollectionsTemplate);
64
+ })
59
65
  .then((data) => {
60
66
  logEventData && console.log("initial received events size : " + data.length);
61
67
  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
  });