web-apps/apps/common/mobile/lib/store/users.js

33 lines
824 B
JavaScript
Raw Normal View History

2020-08-31 17:31:05 +00:00
2021-02-18 15:40:54 +00:00
import {observable, action, computed} from 'mobx';
2020-08-31 17:31:05 +00:00
2020-09-29 18:59:57 +00:00
export class storeUsers {
2021-02-18 15:40:54 +00:00
@observable users = [];
2020-08-31 17:31:05 +00:00
2020-09-29 18:59:57 +00:00
@action reset(users) {
this.users = Object.values(users)
}
2021-02-18 15:40:54 +00:00
@observable currentUser;
@action setCurrentUser(id) {
this.users.forEach((item) => {
if (item.asc_getIdOriginal() === id) {
this.currentUser = item;
}
});
}
getInitials (name) {
const fio = Common.Utils.UserInfoParser.getParsedName(name).split(' ');
let initials = fio[0].substring(0, 1).toUpperCase();
for (let i = fio.length-1; i>0; i--) {
if (fio[i][0]!=='(' && fio[i][0]!==')') {
initials += fio[i].substring(0, 1).toUpperCase();
break;
}
}
return initials;
}
2020-09-29 18:59:57 +00:00
}