summaryrefslogtreecommitdiff
path: root/frontend/app/data/index.js
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2019-03-11 21:00:02 +0400
committerAndrew <saintruler@gmail.com>2019-03-11 21:00:02 +0400
commit7e7dd5244e8d26485ad7950a89c04c98c4fef83f (patch)
tree810730c4650392080fb87a78d3b527201e89fe4b /frontend/app/data/index.js
Initial commit/
Diffstat (limited to 'frontend/app/data/index.js')
-rw-r--r--frontend/app/data/index.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/frontend/app/data/index.js b/frontend/app/data/index.js
new file mode 100644
index 0000000..2c5abb0
--- /dev/null
+++ b/frontend/app/data/index.js
@@ -0,0 +1,52 @@
+import _ from 'lodash';
+import populate from './dataGenerator';
+import users from './raw/users';
+import articles from './raw/articles';
+import notifications from './raw/notifications';
+import conversations from './raw/conversations';
+import cards from './raw/cards';
+
+class DataProvider {
+ getUser(id = 1) {
+ return _.find(users, x => x.id === id);
+ }
+
+ getUsers() {
+ return users;
+ }
+
+ getNotifications() {
+ return notifications;
+ }
+
+ getArticles(type = 'article') {
+ return _.filter(articles, x => x.type === type);
+ }
+
+ getArticle(id) {
+ return _.find(articles, x => x.id === id);
+ }
+
+
+ getConversation(userId = 1) {
+ return _.find(conversations, x => x.withUser.id === userId);
+ }
+
+ getChatList() {
+ return conversations;
+ }
+
+ getComments(postId = 1) {
+ return this.getArticle(postId).comments;
+ }
+
+ getCards() {
+ return cards;
+ }
+
+ populateData() {
+ populate();
+ }
+}
+
+export const data = new DataProvider();