web: People: Added new EmployeeStatus and EmployeeActivationStatus enums

This commit is contained in:
Alexey Safronov 2019-08-06 14:02:36 +03:00
parent 217b5f0bed
commit 1e6732a929
2 changed files with 25 additions and 4 deletions

View File

@ -1 +1,21 @@
export const AUTH_KEY = 'asc_auth_key';
export const AUTH_KEY = "asc_auth_key";
/**
* Enum for employee activation status.
* @readonly
*/
export const EmployeeActivationStatus = Object.freeze({
NotActivated: 0,
Activated: 1,
Pending: 2,
AutoGenerated: 4
});
/**
* Enum for employee status.
* @readonly
*/
export const EmployeeStatus = Object.freeze({
Active: 1,
Disabled: 2
});

View File

@ -1,4 +1,5 @@
import { find, filter } from "lodash";
import { EmployeeActivationStatus, EmployeeStatus } from "../../helpers/constants";
export function getSelectedUser(selection, userId) {
return find(selection, function (obj) {
@ -40,13 +41,13 @@ export function getTreeGroups(groups) {
};
export const getUserStatus = user => {
if (user.status === 1 && user.activationStatus === 1) {
if (user.status === EmployeeStatus.Active && user.activationStatus === EmployeeActivationStatus.Activated) {
return "normal";
}
else if (user.status === 1 && (user.activationStatus === 0 || user.activationStatus === 2)) {
else if (user.status === EmployeeStatus.Active && user.activationStatus === EmployeeActivationStatus.Pending) {
return "pending";
}
else if (user.status === 2) {
else if (user.status === EmployeeStatus.Disabled) {
return "disabled";
}
else {