feat: make explore more visible in lms
This commit is contained in:
@@ -74,6 +74,7 @@ import { searchRouter } from '@api/routes/organization/search';
|
||||
import { tagsRouter } from '@api/routes/organization/tags';
|
||||
import { widgetsRouter } from '@api/routes/organization/widgets';
|
||||
import { zValidator } from '@hono/zod-validator';
|
||||
import { ZGetRecommendedCourses } from '@cio/utils/validation/course';
|
||||
|
||||
export const organizationRouter = new Hono()
|
||||
/**
|
||||
@@ -433,24 +434,31 @@ export const organizationRouter = new Hono()
|
||||
* Gets recommended courses (published courses user isn't enrolled in) for a user in an organization (used in lms)
|
||||
* Requires authentication and organization membership
|
||||
*/
|
||||
.get('/courses/recommended', authMiddleware, orgMemberMiddleware, async (c) => {
|
||||
try {
|
||||
const user = c.get('user')!;
|
||||
.get(
|
||||
'/courses/recommended',
|
||||
authMiddleware,
|
||||
orgMemberMiddleware,
|
||||
zValidator('query', ZGetRecommendedCourses),
|
||||
async (c) => {
|
||||
try {
|
||||
const user = c.get('user')!;
|
||||
const { limit } = c.req.valid('query');
|
||||
|
||||
const orgId = c.req.header('cio-org-id')!;
|
||||
const result = await getRecommendedCourses(orgId, user.id);
|
||||
const orgId = c.req.header('cio-org-id')!;
|
||||
const result = await getRecommendedCourses(orgId, user.id, limit);
|
||||
|
||||
return c.json(
|
||||
{
|
||||
success: true,
|
||||
data: result
|
||||
},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to fetch recommended courses');
|
||||
return c.json(
|
||||
{
|
||||
success: true,
|
||||
data: result
|
||||
},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
return handleError(c, error, 'Failed to fetch recommended courses');
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
/**
|
||||
* GET /organization/courses
|
||||
* Gets courses for an organization with role-based filtering (used in dashboard)
|
||||
|
||||
@@ -469,9 +469,9 @@ export async function getUserEnrolledCourses(orgId: string, userId: string) {
|
||||
* @param userId - User ID to exclude enrolled courses
|
||||
* @returns Array of recommended courses
|
||||
*/
|
||||
export async function getRecommendedCourses(orgId: string, userId: string) {
|
||||
export async function getRecommendedCourses(orgId: string, userId: string, limit?: number) {
|
||||
try {
|
||||
return getExploreCourses({ orgId, profileId: userId });
|
||||
return getExploreCourses({ orgId, profileId: userId, limit });
|
||||
} catch (error) {
|
||||
if (error instanceof AppError) throw error;
|
||||
throw new AppError(
|
||||
|
||||
Reference in New Issue
Block a user