diff --git a/backend/hug_api.py b/backend/hug_api.py
index 4d55f25..6fe8fc5 100644
--- a/backend/hug_api.py
+++ b/backend/hug_api.py
@@ -2,7 +2,6 @@
import json
import numpy as np
from datetime import datetime
-import dateutil
from scipy.spatial.distance import cosine
# enable CORS
@@ -22,7 +21,7 @@ def get_future_event(date):
Function return True if the event happens after now
"""
try:
- if dateutil.parser.parse(date) > datetime.now():
+ if datetime.strptime(date, '%d-%m-%Y') > datetime.now():
return True
else:
return False
@@ -43,6 +42,10 @@ def recommendations(body):
The body is then passed as an argument to this function, as a dictionary.
"""
event_indices = body['payload']
+
+ if len(event_indices) == 0:
+ return json.dumps([])
+
pref_indices = [int(event_idx) for event_idx in event_indices]
pref_vector = np.mean([np.array(event_vectors_map[idx])
for idx in pref_indices], axis=0)
diff --git a/backend/requirements.txt b/backend/requirements.txt
index cacb2b2..44a9d5a 100644
--- a/backend/requirements.txt
+++ b/backend/requirements.txt
@@ -1,2 +1,4 @@
hug
uwsgi
+numpy
+scipy
diff --git a/gatsby_site/package-lock.json b/gatsby_site/package-lock.json
index 4274e0f..5cee039 100644
--- a/gatsby_site/package-lock.json
+++ b/gatsby_site/package-lock.json
@@ -2075,9 +2075,9 @@
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
},
"base64id": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz",
- "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY="
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
+ "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog=="
},
"batch": {
"version": "0.6.1",
@@ -4467,16 +4467,16 @@
}
},
"engine.io": {
- "version": "3.3.2",
- "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.3.2.tgz",
- "integrity": "sha512-AsaA9KG7cWPXWHp5FvHdDWY3AMWeZ8x+2pUVLcn71qE5AtAzgGbxuclOytygskw8XGmiQafTmnI9Bix3uihu2w==",
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.4.0.tgz",
+ "integrity": "sha512-XCyYVWzcHnK5cMz7G4VTu2W7zJS7SM1QkcelghyIk/FmobWBtXE7fwhBusEKvCSqc3bMh8fNFMlUkCKTFRxH2w==",
"requires": {
"accepts": "~1.3.4",
- "base64id": "1.0.0",
+ "base64id": "2.0.0",
"cookie": "0.3.1",
- "debug": "~3.1.0",
- "engine.io-parser": "~2.1.0",
- "ws": "~6.1.0"
+ "debug": "~4.1.0",
+ "engine.io-parser": "~2.2.0",
+ "ws": "^7.1.2"
},
"dependencies": {
"cookie": {
@@ -4485,29 +4485,24 @@
"integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s="
},
"debug": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
- "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
- },
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"engine.io-client": {
- "version": "3.3.2",
- "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.3.2.tgz",
- "integrity": "sha512-y0CPINnhMvPuwtqXfsGuWE8BB66+B6wTtCofQDRecMQPYX3MYUZXFNKDhdrSe3EVjgOu4V3rxdeqN/Tr91IgbQ==",
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.4.0.tgz",
+ "integrity": "sha512-a4J5QO2k99CM2a0b12IznnyQndoEvtA4UAldhGzKqnHf42I3Qs2W5SPnDvatZRcMaNZs4IevVicBPayxYt6FwA==",
"requires": {
"component-emitter": "1.2.1",
"component-inherit": "0.0.3",
- "debug": "~3.1.0",
- "engine.io-parser": "~2.1.1",
+ "debug": "~4.1.0",
+ "engine.io-parser": "~2.2.0",
"has-cors": "1.1.0",
"indexof": "0.0.1",
"parseqs": "0.0.5",
@@ -4523,24 +4518,27 @@
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"debug": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
- "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
},
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ "ws": {
+ "version": "6.1.4",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
+ "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
+ "requires": {
+ "async-limiter": "~1.0.0"
+ }
}
}
},
"engine.io-parser": {
- "version": "2.1.3",
- "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.3.tgz",
- "integrity": "sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.2.0.tgz",
+ "integrity": "sha512-6I3qD9iUxotsC5HEMuuGsKA0cXerGz+4uGcXQEkfBidgKf0amsjrrtwcbwK/nzpZBxclXlV7gGl9dgWvu4LF6w==",
"requires": {
"after": "0.8.2",
"arraybuffer.slice": "~0.0.7",
@@ -5646,8 +5644,7 @@
},
"ansi-regex": {
"version": "2.1.1",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"aproba": {
"version": "1.2.0",
@@ -5665,13 +5662,11 @@
},
"balanced-match": {
"version": "1.0.0",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
- "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -5684,18 +5679,15 @@
},
"code-point-at": {
"version": "1.1.0",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"concat-map": {
"version": "0.0.1",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"console-control-strings": {
"version": "1.1.0",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"core-util-is": {
"version": "1.0.2",
@@ -5798,8 +5790,7 @@
},
"inherits": {
"version": "2.0.3",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"ini": {
"version": "1.3.5",
@@ -5809,7 +5800,6 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
- "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -5822,20 +5812,17 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
- "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
- "optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@@ -5852,7 +5839,6 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
- "optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -5925,8 +5911,7 @@
},
"number-is-nan": {
"version": "1.0.1",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"object-assign": {
"version": "4.1.1",
@@ -5936,7 +5921,6 @@
"once": {
"version": "1.4.0",
"bundled": true,
- "optional": true,
"requires": {
"wrappy": "1"
}
@@ -6012,8 +5996,7 @@
},
"safe-buffer": {
"version": "5.1.2",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -6043,7 +6026,6 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
- "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@@ -6061,7 +6043,6 @@
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
- "optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -6100,13 +6081,11 @@
},
"wrappy": {
"version": "1.0.2",
- "bundled": true,
- "optional": true
+ "bundled": true
},
"yallist": {
"version": "3.0.3",
- "bundled": true,
- "optional": true
+ "bundled": true
}
}
},
@@ -7717,14 +7696,12 @@
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
- "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
- "optional": true
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
},
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
- "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
- "optional": true
+ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
},
"slice-ansi": {
"version": "1.0.0",
@@ -7750,7 +7727,6 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
- "optional": true,
"requires": {
"ansi-regex": "^4.1.0"
}
@@ -8639,8 +8615,7 @@
"ansi-regex": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
- "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==",
- "optional": true
+ "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
},
"is-fullwidth-code-point": {
"version": "2.0.0",
@@ -8663,7 +8638,6 @@
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
- "optional": true,
"requires": {
"ansi-regex": "^4.1.0"
}
@@ -11588,7 +11562,6 @@
"version": "0.13.6",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.13.6.tgz",
"integrity": "sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==",
- "optional": true,
"requires": {
"loose-envify": "^1.1.0",
"object-assign": "^4.1.1"
@@ -12006,16 +11979,16 @@
}
},
"socket.io": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.2.0.tgz",
- "integrity": "sha512-wxXrIuZ8AILcn+f1B4ez4hJTPG24iNgxBBDaJfT6MsyOhVYiTXWexGoPkd87ktJG8kQEcL/NBvRi64+9k4Kc0w==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.3.0.tgz",
+ "integrity": "sha512-2A892lrj0GcgR/9Qk81EaY2gYhCBxurV0PfmmESO6p27QPrUK1J3zdns+5QPqvUYK2q657nSj0guoIil9+7eFg==",
"requires": {
"debug": "~4.1.0",
- "engine.io": "~3.3.1",
+ "engine.io": "~3.4.0",
"has-binary2": "~1.0.2",
"socket.io-adapter": "~1.1.0",
- "socket.io-client": "2.2.0",
- "socket.io-parser": "~3.3.0"
+ "socket.io-client": "2.3.0",
+ "socket.io-parser": "~3.4.0"
},
"dependencies": {
"debug": {
@@ -12034,16 +12007,16 @@
"integrity": "sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs="
},
"socket.io-client": {
- "version": "2.2.0",
- "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.2.0.tgz",
- "integrity": "sha512-56ZrkTDbdTLmBIyfFYesgOxsjcLnwAKoN4CiPyTVkMQj3zTUh0QAx3GbvIvLpFEOvQWu92yyWICxB0u7wkVbYA==",
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.3.0.tgz",
+ "integrity": "sha512-cEQQf24gET3rfhxZ2jJ5xzAOo/xhZwK+mOqtGRg5IowZsMgwvHwnf/mCRapAAkadhM26y+iydgwsXGObBB5ZdA==",
"requires": {
"backo2": "1.0.2",
"base64-arraybuffer": "0.1.5",
"component-bind": "1.0.0",
"component-emitter": "1.2.1",
- "debug": "~3.1.0",
- "engine.io-client": "~3.3.1",
+ "debug": "~4.1.0",
+ "engine.io-client": "~3.4.0",
"has-binary2": "~1.0.2",
"has-cors": "1.1.0",
"indexof": "0.0.1",
@@ -12060,27 +12033,52 @@
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"debug": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
- "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
},
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ "isarray": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
+ "integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
+ },
+ "socket.io-parser": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz",
+ "integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==",
+ "requires": {
+ "component-emitter": "1.2.1",
+ "debug": "~3.1.0",
+ "isarray": "2.0.1"
+ },
+ "dependencies": {
+ "debug": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
+ "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "requires": {
+ "ms": "2.0.0"
+ }
+ },
+ "ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ }
+ }
}
}
},
"socket.io-parser": {
- "version": "3.3.0",
- "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.3.0.tgz",
- "integrity": "sha512-hczmV6bDgdaEbVqhAeVMM/jfUfzuEZHsQg6eOmLgJht6G3mPKMxYm75w2+qhAQZ+4X+1+ATZ+QFKeOZD5riHng==",
+ "version": "3.4.0",
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.4.0.tgz",
+ "integrity": "sha512-/G/VOI+3DBp0+DJKW4KesGnQkQPFmUCbA/oO2QGT6CWxU7hLGWqU3tyuzeSK/dqcyeHsQg1vTe9jiZI8GU9SCQ==",
"requires": {
"component-emitter": "1.2.1",
- "debug": "~3.1.0",
+ "debug": "~4.1.0",
"isarray": "2.0.1"
},
"dependencies": {
@@ -12090,22 +12088,17 @@
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"debug": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
- "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
+ "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
- "ms": "2.0.0"
+ "ms": "^2.1.1"
}
},
"isarray": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.1.tgz",
"integrity": "sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4="
- },
- "ms": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
@@ -13997,11 +13990,11 @@
}
},
"ws": {
- "version": "6.1.4",
- "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz",
- "integrity": "sha512-eqZfL+NE/YQc1/ZynhojeV8q+H050oR8AZ2uIev7RU10svA9ZnJUddHcOUZTJLinZ9yEfdA2kSATS2qZK5fhJA==",
+ "version": "7.1.2",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz",
+ "integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==",
"requires": {
- "async-limiter": "~1.0.0"
+ "async-limiter": "^1.0.0"
}
},
"xdg-basedir": {
diff --git a/gatsby_site/src/components/EventsContainer/EventItem/Components/TimeBox.js b/gatsby_site/src/components/EventsContainer/EventItem/Components/TimeBox.js
index eea791d..fa4ddc6 100644
--- a/gatsby_site/src/components/EventsContainer/EventItem/Components/TimeBox.js
+++ b/gatsby_site/src/components/EventsContainer/EventItem/Components/TimeBox.js
@@ -1,6 +1,6 @@
import { FontAwesomeIcon as Fa } from '@fortawesome/react-fontawesome';
import PropTypes from 'prop-types';
-import React, { useState } from 'react';
+import React from 'react';
import styled from 'styled-components';
import { Datetime as dtutil } from '../../../../utils';
import useGlobal from '../../../../store';
@@ -37,8 +37,10 @@ const StyledFavIcon = styled(Fa).attrs(() => ({
`;
const TimeBox = ({ starttime, endtime, eventIndex }) => {
- const [, globalActions] = useGlobal();
- const [checked, setChecked] = useState(false);
+ const [globalState, globalActions] = useGlobal();
+
+ // destructuring state to use
+ const { selectedEvents } = globalState;
// destructuring actions to use
const { toggleSelectedEvent } = globalActions;
@@ -75,8 +77,6 @@ const TimeBox = ({ starttime, endtime, eventIndex }) => {
onClick={(e) => {
// set global state
toggleSelectedEvent(eventIndex);
- // set local state
- setChecked(prev => !prev);
// block this because if the item has
// description this will propagate
// through invoke showing description
@@ -84,7 +84,7 @@ const TimeBox = ({ starttime, endtime, eventIndex }) => {
}}
>
diff --git a/gatsby_site/src/components/EventsContainer/index.js b/gatsby_site/src/components/EventsContainer/index.js
index 7280564..57a0f9f 100644
--- a/gatsby_site/src/components/EventsContainer/index.js
+++ b/gatsby_site/src/components/EventsContainer/index.js
@@ -22,6 +22,16 @@ const StyledH2 = styled.h2`
`;
const EventsContainer = ({ allEvents }) => {
+ // render no data screen
+ if (allEvents.length === 0) {
+ return (
+
+ No available events!
+
+ );
+ }
+
+ // group event by date before rendering
const groupedByDates = evUtil.groupByDate(allEvents);
return groupedByDates.map(grp => (
diff --git a/gatsby_site/src/components/layout.js b/gatsby_site/src/components/layout.js
index f3b0be9..ff060db 100644
--- a/gatsby_site/src/components/layout.js
+++ b/gatsby_site/src/components/layout.js
@@ -21,12 +21,10 @@ const Layout = ({ children }) => (
Home
-
+
Selected Events
-
+
Recommendations
diff --git a/gatsby_site/src/pages/index.js b/gatsby_site/src/pages/index.js
index 78b48c0..6d57103 100644
--- a/gatsby_site/src/pages/index.js
+++ b/gatsby_site/src/pages/index.js
@@ -2,8 +2,8 @@ import { library } from '@fortawesome/fontawesome-svg-core';
import {
faBookmark, faCalendarAlt, faChevronCircleDown,
faChevronCircleUp, faClock, faCopy, faExternalLinkAlt,
- faFileAlt, faMapMarkerAlt, faSchool, faUniversity, faUserTie,
- faStar,
+ faFileAlt, faMapMarkerAlt, faSchool,
+ faStar, faUniversity, faUserTie,
} from '@fortawesome/free-solid-svg-icons';
import { graphql } from 'gatsby';
import React from 'react';
@@ -18,27 +18,14 @@ library.add(
faCopy, faStar,
);
-export default ({ data }) => {
- fetch('http://localhost:8888/recommendations', {
- method: 'POST',
- mode: 'cors',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify({
- payload: [1, 2, 3, 4, 5],
- }),
- }).then(res => console.log(res.json()));
-
- return (
-
- Upcoming Events
-
-
- );
-};
+export default ({ data }) => (
+
+ Upcoming Events
+
+
+);
export const query = graphql`
query {
diff --git a/gatsby_site/src/pages/recommendations.js b/gatsby_site/src/pages/recommendations.js
new file mode 100644
index 0000000..b08ae00
--- /dev/null
+++ b/gatsby_site/src/pages/recommendations.js
@@ -0,0 +1,66 @@
+import { graphql } from 'gatsby';
+import React, { useState, useEffect } from 'react';
+import EventsContainer from '../components/EventsContainer';
+import Layout from '../components/layout';
+import useGlobal from '../store';
+
+export default ({ data }) => {
+ const [globalState] = useGlobal();
+ const [recommendedEvents, setRecommendedEvents] = useState([]);
+
+ // get selected event indexes from global state
+ const { selectedEvents: selectedEventsIndexes } = globalState;
+
+ useEffect(() => {
+ fetch('http://localhost:8888/recommendations', {
+ method: 'POST',
+ mode: 'cors',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ payload: selectedEventsIndexes,
+ }),
+ })
+ .then(res => res.json())
+ .then((recommendedIndexes) => {
+ const filteredData = data.allEventsJson.edges.filter(
+ x => recommendedIndexes.includes(x.node.event_index),
+ );
+ setRecommendedEvents(filteredData);
+ })
+ // eslint-disable-next-line
+ .catch(err => console.log(err));
+ }, selectedEventsIndexes);
+
+ return (
+
+ Recommendations
+
+
+ );
+};
+
+export const query = graphql`
+ query {
+ allEventsJson {
+ edges {
+ node {
+ id
+ event_index
+ date_dt
+ title
+ description
+ starttime
+ endtime
+ speaker
+ owner
+ location
+ url
+ }
+ }
+ }
+ }
+`;
diff --git a/gatsby_site/src/pages/selected-events.js b/gatsby_site/src/pages/selected-events.js
new file mode 100644
index 0000000..794b756
--- /dev/null
+++ b/gatsby_site/src/pages/selected-events.js
@@ -0,0 +1,47 @@
+import { graphql } from 'gatsby';
+import React from 'react';
+import EventsContainer from '../components/EventsContainer';
+import Layout from '../components/layout';
+import useGlobal from '../store';
+
+export default ({ data }) => {
+ const [globalState] = useGlobal();
+
+ // get selected event indexes from global state
+ const { selectedEvents: selectedEventsIndexes } = globalState;
+ // filter only selected event to pass to container
+ const selectedEvents = data.allEventsJson.edges.filter(
+ x => selectedEventsIndexes.includes(x.node.event_index),
+ );
+
+ return (
+
+ Selected Events
+
+
+ );
+};
+
+export const query = graphql`
+ query {
+ allEventsJson {
+ edges {
+ node {
+ id
+ event_index
+ date_dt
+ title
+ description
+ starttime
+ endtime
+ speaker
+ owner
+ location
+ url
+ }
+ }
+ }
+ }
+`;