Files
classroomio/apps/dashboard/src/lib/features/course/utils/constants.ts
T

87 lines
2.6 KiB
TypeScript
Raw Normal View History

2026-03-09 11:18:22 +01:00
export const ROUTES = {
COURSES: 'courses',
LESSONS: 'lessons'
};
export const EXERCISE_TEMPLATE_TAGS = {
HTML: 'HTML',
CSS: 'CSS',
JS: 'JS',
Typescript: 'Typescript',
ReactJS: 'ReactJS',
VueJS: 'VueJS',
NodeJS: 'NodeJS',
Python: 'Python',
PHP: 'PHP',
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;
import type { CertificateTemplateId } from '@cio/certificates';
export {
ACCENT_COLORS,
CERTIFICATE_TEMPLATE_IDS,
CERTIFICATE_TEMPLATES,
DEFAULT_ACCENT_COLOR,
DEFAULT_CERTIFICATE_DESIGN,
LEGACY_THEME_MAP
} from '@cio/certificates';
export type { CertificateTemplateId } from '@cio/certificates';
/**
* @deprecated Use `CertificateTemplateId` from `@cio/certificates`. Kept here so the
* existing `CertificateThemeId` import sites compile during the migration.
*/
export type CertificateThemeId = CertificateTemplateId;
export const DEFAULT_CERTIFICATE_THEME_ID: CertificateThemeId = 'classique';
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;
}
2026-03-09 11:18:22 +01:00
export const COURSE_SORT_OPTIONS = [
{ 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' }
2026-03-09 11:18:22 +01:00
] 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;
}