Files
classroomio/packages/ui/src/custom/org-landing-page/course-landing-page.helpers.ts
T
0abdfe2102 fix(dashboard): align hero enroll CTA with pricing section (#810)
The hero Enroll button was disabled unless metadata.allowNewStudent was
explicitly true, while the pricing CTA treated unset values as open
(matching the enroll page and API). This left the hero button inert on
courses where enrollment was allowed but the flag was not set.

Also sync pricing CTA disabled state, use activeOrg for paid enroll on
public org-site pages, and keep hero/pricing disabled flags aligned via
alignHeroCtaWithPricing.

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Rotimi Best <[email protected]>
2026-07-31 14:53:01 +01:00

54 lines
1.7 KiB
TypeScript

import type { CoursePricing, CourseLandingPageProps, CourseLandingPageLabels } from './types';
export function alignHeroCtaWithPricing(
hero: CourseLandingPageProps['hero'],
pricing: CoursePricing
): CourseLandingPageProps['hero'] {
return {
...hero,
primaryAction: {
label: pricing.ctaLabel,
href: pricing.ctaOnclick ? undefined : (pricing.ctaHref ?? '#pricing'),
onclick: pricing.ctaOnclick,
disabled: pricing.ctaDisabled ?? hero.primaryAction.disabled
}
};
}
export interface SectionNavItem {
id: string;
label: string;
}
export function buildCourseSectionNavItems(
props: Pick<CourseLandingPageProps, 'info' | 'curriculum' | 'chips' | 'instructor' | 'reviews'>,
labels?: CourseLandingPageLabels
): SectionNavItem[] {
const items: SectionNavItem[] = [];
const { info, curriculum, chips, reviews } = props;
const hasInfo = Boolean(info.requirements || info.description || info.goals || info.certificateUrl);
if (hasInfo) {
items.push({ id: 'course-info', label: labels?.navAboutLabel ?? 'About' });
}
if (curriculum.sections.length > 0) {
items.push({ id: 'curriculum', label: labels?.navCurriculumLabel ?? 'Modules' });
}
const hasChips = Boolean((chips?.skills?.length ?? 0) > 0 || (chips?.tools?.length ?? 0) > 0);
if (hasChips) {
items.push({ id: 'course-chips', label: labels?.navSkillsLabel ?? 'Skills' });
}
items.push({ id: 'instructor', label: labels?.navInstructorLabel ?? 'Instructor' });
if (reviews.items.length > 0) {
items.push({ id: 'reviews', label: labels?.navReviewsLabel ?? 'Reviews' });
}
items.push({ id: 'pricing', label: labels?.navPricingLabel ?? 'Pricing' });
return items;
}