Enhance audience management features with new components and API integrations

- 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.
This commit is contained in:
Rotimi Best
2026-03-22 18:42:23 +01:00
parent e9c4082f89
commit 3919ff6c2f
157 changed files with 13183 additions and 872 deletions
@@ -16,8 +16,51 @@ export const EXERCISE_TEMPLATE_TAGS = {
GIT: 'GIT'
};
/** Named sort keys for course lists (URL `sort`, localStorage, filter UI). */
export const CourseSortBy = {
DateCreated: 'date_created',
Published: 'published',
Lessons: 'lessons'
} as const;
export type CourseSortBy = (typeof CourseSortBy)[keyof typeof CourseSortBy];
export const DEFAULT_COURSE_SORT: CourseSortBy = CourseSortBy.DateCreated;
/** URL `order` param and filter toggle (ascending vs descending). */
export const CourseSortOrder = {
Asc: 'asc',
Desc: 'desc'
} as const;
export type CourseSortOrder = (typeof CourseSortOrder)[keyof typeof CourseSortOrder];
export const DEFAULT_SORT_ORDER: CourseSortOrder = CourseSortOrder.Desc;
const COURSE_SORT_ORDER_VALUES = new Set<string>(Object.values(CourseSortOrder));
export function parseCourseSortOrder(value: string | null | undefined): CourseSortOrder {
if (value != null && COURSE_SORT_ORDER_VALUES.has(value)) {
return value as CourseSortOrder;
}
return DEFAULT_SORT_ORDER;
}
export const COURSE_SORT_OPTIONS = [
{ value: '0', label: 'courses.course_filter.date_created' },
{ value: '1', label: 'courses.course_filter.published' },
{ value: '2', label: 'courses.course_filter.lessons' }
{ value: CourseSortBy.DateCreated, label: 'courses.course_filter.date_created' },
{ value: CourseSortBy.Published, label: 'courses.course_filter.published' },
{ value: CourseSortBy.Lessons, label: 'courses.course_filter.lessons' }
] as const;
const COURSE_SORT_VALUES = new Set<string>(Object.values(CourseSortBy));
/** Parses URL `sort` / stored sort strings into {@link CourseSortBy}; unknown values fall back to default. */
export function parseCourseSortValue(value: string | null | undefined): CourseSortBy {
if (value == null || value === '') {
return DEFAULT_COURSE_SORT;
}
if (COURSE_SORT_VALUES.has(value)) {
return value as CourseSortBy;
}
return DEFAULT_COURSE_SORT;
}
@@ -0,0 +1,37 @@
import type { TLocale } from '@cio/db/types';
interface LessonDraft {
content: string;
timestamp: number;
}
function draftKey(lessonId: string, locale: TLocale): string {
return `lesson-draft-${lessonId}-${locale}`;
}
export function saveDraft(lessonId: string, locale: TLocale, content: string) {
try {
const draft: LessonDraft = { content, timestamp: Date.now() };
localStorage.setItem(draftKey(lessonId, locale), JSON.stringify(draft));
} catch {
// localStorage may be full or unavailable
}
}
export function loadDraft(lessonId: string, locale: TLocale): LessonDraft | null {
try {
const raw = localStorage.getItem(draftKey(lessonId, locale));
if (!raw) return null;
return JSON.parse(raw) as LessonDraft;
} catch {
return null;
}
}
export function clearDraft(lessonId: string, locale: TLocale) {
try {
localStorage.removeItem(draftKey(lessonId, locale));
} catch {
// ignore
}
}