blob: 2c5abb06c7d608370a5dc2cc6cc7c7d309c639dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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();
|