marco.pms.web/src/utils/projectStatus.js

58 lines
1.2 KiB
JavaScript

export const getProjectStatusName = (statusId) => {
switch (statusId) {
case 1:
return "Active";
case 2:
return "On Hold";
// case 3:
// return "Suspended";
case 3:
return "Inactive";
case 4:
return "Completed";
}
};
export const getProjectStatusColor = (statusId) => {
switch (statusId) {
case 1:
return "bg-label-success";
case 2:
return "bg-label-warning";
case 3:
return "bg-label-info";
case 4:
return "bg-label-secondary";
case 5:
return "bg-label-dark";
}
};
// for different color for each user
export function hashString(str) {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = (hash << 5) - hash + char;
}
return hash;
}
// Map a hash value to a Bootstrap background class
export function getBgClassFromHash(str) {
const bgClasses = [
"primary",
"secondary",
"success",
"danger",
"warning",
"info",
"dark",
"light",
];
const hash = hashString(str);
const index = Math.abs(hash % bgClasses.length);
return bgClasses[index];
}