-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
59 lines (55 loc) · 1.55 KB
/
index.js
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
import React from 'react';
import { connect } from 'react-redux';
import withPhone from 'ringcentral-widgets/lib/withPhone';
import GlipGroupsPanel from '../../components/GlipGroupsPanel';
function mapToProps(_, {
phone: {
glipGroups,
contacts,
routerInteraction,
},
mobile,
}) {
const isInChat = routerInteraction.currentPath.indexOf('/glip/groups') > -1;
return {
groups: glipGroups.groupsWithUnread,
currentGroupId: (!isInChat || mobile) ? null : glipGroups.currentGroupId,
searchFilter: glipGroups.searchFilter,
currentPage: glipGroups.pageNumber,
filteredContacts: contacts.filteredContacts,
contactSearchFilter: contacts.searchFilter,
};
}
function mapToFunctions(_, {
phone: {
routerInteraction,
glipGroups,
contacts,
}
}) {
return {
goToGroup: (groupId) => {
if (groupId) {
routerInteraction.push(`/glip/groups/${groupId}`);
}
},
updateSearchFilter: (searchFilter) => {
glipGroups.updateFilter({ searchFilter });
},
onNextPage: (pageNumber) => {
glipGroups.updateFilter({ pageNumber });
},
updateContactSearchFilter: (searchFilter) => {
contacts.updateFilter({ searchFilter });
},
createTeam: async ({ teamName, selectedContacts }) => {
const groupId = await glipGroups.createTeam(teamName, selectedContacts.map(sc => sc.email));
routerInteraction.push(`/glip/groups/${groupId}`);
}
};
}
const GlipGroupsPage = withPhone(connect(
mapToProps,
mapToFunctions
)(GlipGroupsPanel));
export default GlipGroupsPage;