@whatmore-repo/whatmore-reactnative-sdk 1.0.37 → 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
|
@@ -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
|
-
|
|
57
|
-
|
|
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);
|