1 import { MEMBER_STATE, type Member, MemberUnprivatizationState } from '../interfaces';
3 export const getHasMemberUnprivatization = (
5 ): member is Member & { Unprivatization: NonNullable<Member['Unprivatization']> } => {
6 return Boolean(member && member.Unprivatization);
9 export const getIsMemberSetup = (member?: Member): member is Member => {
10 return Boolean(member?.PublicKey);
13 export const getIsMemberInactive = (member?: Member): member is Member & { State: MEMBER_STATE.STATUS_DISABLED } => {
14 return member?.State === MEMBER_STATE.STATUS_DISABLED;
17 export enum MemberUnprivatizationMode {
24 export const getMemberUnprivatizationMode = (member?: Member) => {
25 if (getHasMemberUnprivatization(member)) {
29 member.Unprivatization.State === MemberUnprivatizationState.Pending ||
30 member.Unprivatization.State === MemberUnprivatizationState.Ready,
33 return MemberUnprivatizationMode.GSSO;
35 const isMemberSetup = getIsMemberSetup(member);
37 return MemberUnprivatizationMode.AdminAccess;
39 return MemberUnprivatizationMode.MagicLinkInvite;
46 mode: MemberUnprivatizationMode.None,
51 export const getMemberEmailOrName = (member: Member) => {
52 return member.Addresses?.[0]?.Email || member.Name || '';