Skip to content

Commit

Permalink
Fixed lessonId
Browse files Browse the repository at this point in the history
  • Loading branch information
ravirajput10 committed Dec 5, 2024
1 parent 7108f7e commit 9c5cf8c
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions apps/web/graphql/courses/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,34 @@ export const getCourse = async (
]) || checkOwnershipWithoutModel(course, ctx);

if (isOwner) {
await loadFirstLesson(course, ctx);
return course;
}
}

if (course.published) {
if (
[constants.course, constants.download].includes(
course.type as
| typeof constants.course
| typeof constants.download,
)
) {
const { nextLesson } = await getPrevNextCursor(
course.courseId,
ctx.subdomain._id,
);
(course as any).firstLesson = nextLesson;
}
// course.groups = accessibleGroups;
await loadFirstLesson(course, ctx);
return course;
} else {
throw new Error(responses.item_not_found);
}
};

const loadFirstLesson = async (course: Course, ctx: GQLContext) => {
if (
[constants.course, constants.download].includes(
course.type as typeof constants.course | typeof constants.download,
)
) {
const { nextLesson } = await getPrevNextCursor(
course.courseId,
ctx.subdomain._id,
);
(course as any).firstLesson = nextLesson;
}
// course.groups = accessibleGroups;
};

export const createCourse = async (
courseData: { title: string; type: Filter },
ctx: GQLContext,
Expand Down

0 comments on commit 9c5cf8c

Please sign in to comment.