-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUserEntries.js
More file actions
65 lines (58 loc) · 1.92 KB
/
UserEntries.js
File metadata and controls
65 lines (58 loc) · 1.92 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import EntryOverview from '../container/EntryOverview';
import View from '../store/View';
import Title from '../component/Title';
import { ProjectStore } from '../store/Project';
import { UserStore } from '../store/User';
import { EntryStore } from '../store/Entry';
@observer
export default class UserEntriesScreen extends Component {
static propTypes = {
viewStore: PropTypes.instanceOf(View).isRequired,
match: PropTypes.object.isRequired,
};
componentWillMount() {
this.projectStore = new ProjectStore();
this.userStore = new UserStore();
this.entryStore = new EntryStore();
}
componentDidMount() {
this.subscribe();
this.props.viewStore.socket.on('open', this.subscribe);
}
componentWillUnmount() {
this.unsubscribe();
}
subscribe = () => {
this.projectStore.clear();
this.projectStore.subscribe();
this.userStore.clear();
this.userStore.subscribe();
this.entryStore.clear();
this.entryStore.subscribe({
user: parseInt(this.props.match.params.id),
});
};
unsubscribe = () => {
this.projectStore.unsubscribe();
this.userStore.unsubscribe();
this.entryStore.unsubscribe();
};
render() {
const userId = this.props.match.params.id;
const user = this.userStore.get(userId);
return (
<div>
<Title>Employee {user ? user.displayName : 'Unknown'}</Title>
<EntryOverview
viewStore={this.props.viewStore}
entries={this.entryStore}
projectStore={this.projectStore}
allowEdit={this.props.viewStore.currentUser.pmc === 'Management'}
/>
</div>
);
}
}