- Added `AssignCoursesModal`, `AudienceMemberRow`, `AudienceTable`, and related components for improved audience management UI. - Implemented audience invite actions including resend and revoke functionality. - Updated audience API to support importing members and assigning courses. - Refactored audience data handling to include status and invite management. - Improved overall user experience with pagination and selection features in the audience table.
24 lines
561 B
TypeScript
24 lines
561 B
TypeScript
export type AudienceMemberStatus = 'active' | 'pending' | 'expired' | 'revoked';
|
|
|
|
export function deriveAudienceMemberStatus(
|
|
profileId: string | null,
|
|
invite: { acceptedAt: string | null; isRevoked: boolean; expiresAt: string } | undefined
|
|
): AudienceMemberStatus {
|
|
if (profileId) {
|
|
return 'active';
|
|
}
|
|
if (invite?.acceptedAt) {
|
|
return 'active';
|
|
}
|
|
if (!invite) {
|
|
return 'pending';
|
|
}
|
|
if (invite.isRevoked) {
|
|
return 'revoked';
|
|
}
|
|
if (new Date(invite.expiresAt) <= new Date()) {
|
|
return 'expired';
|
|
}
|
|
return 'pending';
|
|
}
|