Rollen fix
This commit is contained in:
@@ -97,27 +97,12 @@ export function canDeleteExpense(
|
||||
return viewerId === creatorId && approvalStatus === "PENDING" && !paidAt && !documentedAt;
|
||||
}
|
||||
|
||||
export function getDefaultApprovalPermissionsForRole(role: AppRole): ApprovalTypeValue[] {
|
||||
switch (role) {
|
||||
case "ADMIN":
|
||||
return ["CHAIR_A"];
|
||||
case "FINANCE":
|
||||
return ["FINANCE"];
|
||||
case "MEMBER":
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeApprovalPermissions(
|
||||
role: AppRole,
|
||||
_role: AppRole,
|
||||
approvalPermissions: ApprovalTypeValue[] | null | undefined,
|
||||
approvalPreference: ApprovalTypeValue | null | undefined = null
|
||||
) {
|
||||
const rawPermissions = approvalPermissions && approvalPermissions.length > 0
|
||||
? approvalPermissions
|
||||
: approvalPreference
|
||||
? [approvalPreference]
|
||||
: getDefaultApprovalPermissionsForRole(role);
|
||||
const rawPermissions = approvalPermissions ?? (approvalPreference ? [approvalPreference] : []);
|
||||
|
||||
return APPROVAL_FLOW.filter(
|
||||
(approvalType, index) => rawPermissions.includes(approvalType) && rawPermissions.indexOf(approvalType) === index
|
||||
|
||||
Reference in New Issue
Block a user