push rasad front on new repo
This commit is contained in:
35
src/utils/sortRoles.js
Normal file
35
src/utils/sortRoles.js
Normal file
@@ -0,0 +1,35 @@
|
||||
export const sortRoles = (roles) => {
|
||||
if (roles) {
|
||||
const priorityRoles = [
|
||||
"AdminX",
|
||||
"SuperAdmin",
|
||||
"ProvinceOperator",
|
||||
"LiveStockProvinceJahad",
|
||||
"Union",
|
||||
"Cooperative",
|
||||
"Rancher",
|
||||
"KillHouse",
|
||||
"KillHouseVet",
|
||||
"VetFarm",
|
||||
"VetSupervisor",
|
||||
"CityVet",
|
||||
"ParentCompany",
|
||||
"Steward",
|
||||
"Guilds",
|
||||
"ProvinceSupervisor",
|
||||
"Commerce",
|
||||
"PoultryScience",
|
||||
];
|
||||
return [...roles].sort((a, b) => {
|
||||
const aIndex = priorityRoles.indexOf(a);
|
||||
const bIndex = priorityRoles.indexOf(b);
|
||||
if (aIndex !== -1 && bIndex !== -1) {
|
||||
return aIndex - bIndex;
|
||||
}
|
||||
if (aIndex !== -1) return -1;
|
||||
if (bIndex !== -1) return 1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
};
|
||||
Reference in New Issue
Block a user