feat(dashboard): moved course completion deadline to course settings page (#842)

This commit is contained in:
Victor Jack
2026-08-15 18:55:51 +01:00
committed by GitHub
parent b267db6319
commit ad5c8db5a9
22 changed files with 528 additions and 244 deletions
@@ -108,6 +108,7 @@ export const ErrorCodes = {
SLUG_IN_USE: 'SLUG_IN_USE',
QUESTION_TYPE_NOT_ALLOWED_IN_PUBLIC_COURSE: 'QUESTION_TYPE_NOT_ALLOWED_IN_PUBLIC_COURSE',
PUBLIC_COURSE_CONVERSION_BLOCKED: 'PUBLIC_COURSE_CONVERSION_BLOCKED',
COMPLIANCE_DEADLINE_REQUIRED: 'COMPLIANCE_DEADLINE_REQUIRED',
// Lesson errors
LESSON_NOT_FOUND: 'LESSON_NOT_FOUND',
@@ -0,0 +1,38 @@
/**
* A published COMPLIANCE course must have a completion deadline.
* Draft courses, non-compliance types, and downloadable certificates do not require one.
*/
export function isPublishedComplianceMissingDeadline(params: {
type: string | null | undefined;
isPublished: boolean | null | undefined;
deadline: string | null | undefined;
}): boolean {
if (params.isPublished !== true) {
return false;
}
if (params.type !== 'COMPLIANCE') {
return false;
}
return !params.deadline?.trim();
}
/**
* Course updates replace the certificate JSON value when `certificate` is sent.
* If the patch omits `deadline`, the stored deadline is cleared.
*/
export function resolveCourseCertificateDeadline(
currentDeadline: string | null | undefined,
certificatePatch: { deadline?: string | null } | null | undefined
): string | null | undefined {
if (certificatePatch === undefined) {
return currentDeadline;
}
if (certificatePatch === null) {
return null;
}
return certificatePatch.deadline ?? null;
}
+1
View File
@@ -1,4 +1,5 @@
export * from './array';
export * from './compliance-deadline';
export * from './course-progression';
export * from './currency';
export * from './fileValidation';