1 import { hasBit } from '../helpers/bitset';
2 import type { Address as AddressInterface } from '../interfaces';
3 import type { CalendarMember as MemberInterface } from '../interfaces/calendar';
4 import { CALENDAR_PERMISSIONS } from './constants';
6 export const getMemberAddressWithAdminPermissions = (Members: MemberInterface[], Addresses: AddressInterface[]) => {
7 const Member = Members.find(({ Email: MemberEmail, Permissions }) => {
8 return hasBit(Permissions, CALENDAR_PERMISSIONS.ADMIN) && Addresses.find(({ Email }) => MemberEmail === Email);
11 throw new Error('Member with admin permission not found');
13 const Address = Addresses.find(({ Email }) => Member.Email === Email);
15 throw new Error('Address for member not found');