Updated permissions to have a key to group them
This commit is contained in:
@@ -1,58 +1,89 @@
|
||||
export const markets = ["au", "br", "de"] as const;
|
||||
export interface PermissionTopic {
|
||||
topic: string;
|
||||
list: string[];
|
||||
}
|
||||
|
||||
export const permissions = [
|
||||
// generate codes are basicly invites
|
||||
"createCodeStudent",
|
||||
"createCodeTeacher",
|
||||
"createCodeCorporate",
|
||||
"createCodeCountryManager",
|
||||
"createCodeAdmin",
|
||||
// exams
|
||||
"createReadingExam",
|
||||
"createListeningExam",
|
||||
"createWritingExam",
|
||||
"createSpeakingExam",
|
||||
"createLevelExam",
|
||||
// view pages
|
||||
"viewExams",
|
||||
"viewExercises",
|
||||
"viewRecords",
|
||||
"viewStats",
|
||||
"viewTickets",
|
||||
"viewPaymentRecords",
|
||||
// view data
|
||||
"viewStudent",
|
||||
"viewTeacher",
|
||||
"viewCorporate",
|
||||
"viewCountryManager",
|
||||
"viewAdmin",
|
||||
"viewGroup",
|
||||
"viewCodes",
|
||||
// edit data
|
||||
"editStudent",
|
||||
"editTeacher",
|
||||
"editCorporate",
|
||||
"editCountryManager",
|
||||
"editAdmin",
|
||||
"editGroup",
|
||||
// delete data
|
||||
"deleteStudent",
|
||||
"deleteTeacher",
|
||||
"deleteCorporate",
|
||||
"deleteCountryManager",
|
||||
"deleteAdmin",
|
||||
"deleteGroup",
|
||||
"deleteCodes",
|
||||
// create options
|
||||
"createGroup",
|
||||
"createCodes",
|
||||
"all",
|
||||
{
|
||||
topic: "Manage Corporate",
|
||||
list: [
|
||||
"viewCorporate",
|
||||
"editCorporate",
|
||||
"deleteCorporate",
|
||||
"createCodeCorporate",
|
||||
],
|
||||
},
|
||||
{
|
||||
topic: "Manage Admin",
|
||||
list: ["viewAdmin", "editAdmin", "deleteAdmin", "createCodeAdmin"],
|
||||
},
|
||||
{
|
||||
topic: "Manage Student",
|
||||
list: ["viewStudent", "editStudent", "deleteStudent", "createCodeStudent"],
|
||||
},
|
||||
{
|
||||
topic: "Manage Teacher",
|
||||
list: ["viewTeacher", "editTeacher", "deleteTeacher", "createCodeTeacher"],
|
||||
},
|
||||
{
|
||||
topic: "Manage Country Manager",
|
||||
list: [
|
||||
"viewCountryManager",
|
||||
"editCountryManager",
|
||||
"deleteCountryManager",
|
||||
"createCodeCountryManager",
|
||||
],
|
||||
},
|
||||
{
|
||||
topic: "Manage Exams",
|
||||
list: [
|
||||
"createReadingExam",
|
||||
"createListeningExam",
|
||||
"createWritingExam",
|
||||
"createSpeakingExam",
|
||||
"createLevelExam",
|
||||
],
|
||||
},
|
||||
{
|
||||
topic: "View Pages",
|
||||
list: [
|
||||
"viewExams",
|
||||
"viewExercises",
|
||||
"viewRecords",
|
||||
"viewStats",
|
||||
"viewTickets",
|
||||
"viewPaymentRecords",
|
||||
],
|
||||
},
|
||||
{
|
||||
topic: "Manage Group",
|
||||
list: ["viewGroup", "editGroup", "deleteGroup", "createGroup"],
|
||||
},
|
||||
{
|
||||
topic: "Manage Codes",
|
||||
list: ["viewCodes", "deleteCodes", "createCodes"],
|
||||
},
|
||||
{
|
||||
topic: "Others",
|
||||
list: ["all"],
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type PermissionType = (typeof permissions)[keyof typeof permissions];
|
||||
const permissionsList = [
|
||||
...new Set(
|
||||
permissions.reduce(
|
||||
(accm: string[], permission) => [...accm, ...permission.list],
|
||||
[]
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
export type PermissionType =
|
||||
(typeof permissionsList)[keyof typeof permissionsList];
|
||||
|
||||
export interface Permission {
|
||||
id: string;
|
||||
type: PermissionType;
|
||||
users: string[];
|
||||
id: string;
|
||||
type: PermissionType;
|
||||
topic: string;
|
||||
users: string[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user