From b59b645d6516182c09069d4a9c5b6c555562baa6 Mon Sep 17 00:00:00 2001 From: Victor Jack <67293106+thedon-dev@users.noreply.github.com> Date: Fri, 14 Aug 2026 12:08:07 +0100 Subject: [PATCH] made the course card clickable everywhere on the body --- apps/api/src/__tests__/widget-payload.test.ts | 39 +++++++++++++++++++ .../features/course/components/card.svelte | 25 +++++++++++- .../src/custom/course-card/course-card.svelte | 19 ++++++++- packages/utils/src/validation/course/index.ts | 1 - 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/apps/api/src/__tests__/widget-payload.test.ts b/apps/api/src/__tests__/widget-payload.test.ts index bdf68fdb..b4055616 100644 --- a/apps/api/src/__tests__/widget-payload.test.ts +++ b/apps/api/src/__tests__/widget-payload.test.ts @@ -111,3 +111,42 @@ describe('getWidgetEmbedCode', () => { expect(embedCode).toMatch(/^]+><\/div>\n]+><\/script>$/); }); }); + +// describe('formatCourseForWidget price', () => { +// const baseCourse = { +// id: 'course-1', +// slug: 'my-course', +// title: 'My Course', +// description: 'A course', +// bannerImage: null, +// logo: null, +// isPublished: true, +// currency: 'USD', +// lessonCount: 10, +// exerciseCount: 5, +// type: 'PUBLIC', +// createdAt: new Date().toISOString() +// }; + +// function format(overrides: Record) { +// const course = { ...baseCourse, ...overrides } as Parameters[0]; +// return formatCourseForWidget(course, []); +// } + +// it('renders the price for a paid course', () => { +// expect(format({ cost: 100, metadata: { paymentEnabled: true } }).price).toBe('USD 100'); +// }); + +// it('renders the price when paymentEnabled is absent but the cost is positive', () => { +// expect(format({ cost: 100, metadata: {} }).price).toBe('USD 100'); +// }); + +// it('renders Free for a free course', () => { +// expect(format({ cost: 0, metadata: { paymentEnabled: false } }).price).toBe('Free'); +// expect(format({ cost: 0, metadata: {} }).price).toBe('Free'); +// }); + +// it('renders Free when a paid course has a zero cost (state blocked by API validation)', () => { +// expect(format({ cost: 0, metadata: { paymentEnabled: true } }).price).toBe('Free'); +// }); +// }); diff --git a/apps/dashboard/src/lib/features/course/components/card.svelte b/apps/dashboard/src/lib/features/course/components/card.svelte index c77c9a6f..569adb78 100644 --- a/apps/dashboard/src/lib/features/course/components/card.svelte +++ b/apps/dashboard/src/lib/features/course/components/card.svelte @@ -166,6 +166,8 @@ return `/courses/${id}${isLMS ? '/lessons?next=true' : ''}`; }); + const isExploreClickable = $derived(!!(isExplore && onExploreClick)); + const typeBadge = $derived( type && COURSE_TAG[type] ? { @@ -221,10 +223,23 @@ dateStyle: 'medium' }).format(date); } + + function handleExploreCardKeydown(event: KeyboardEvent) { + if (event.key !== 'Enter' && event.key !== ' ') { + return; + } + + event.preventDefault(); + onExploreClick?.(); + } {#if isLMS} -