From 7e7dd5244e8d26485ad7950a89c04c98c4fef83f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 11 Mar 2019 21:00:02 +0400 Subject: Initial commit/ --- frontend/app/data/index.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 frontend/app/data/index.js (limited to 'frontend/app/data/index.js') 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(); -- cgit v1.2.3