diff --git a/apps/api/src/services/courses/courses.py b/apps/api/src/services/courses/courses.py index 805997b5..f7405e3d 100644 --- a/apps/api/src/services/courses/courses.py +++ b/apps/api/src/services/courses/courses.py @@ -152,10 +152,10 @@ async def get_course_meta( async def get_authors(): authors_statement = ( select(ResourceAuthor, User) - .join(User, ResourceAuthor.user_id == User.id) + .join(User, ResourceAuthor.user_id == User.id) # type: ignore .where(ResourceAuthor.resource_uuid == course.course_uuid) .order_by( - ResourceAuthor.id.asc() + ResourceAuthor.id.asc() # type: ignore ) ) return db_session.exec(authors_statement).all() diff --git a/apps/api/src/services/payments/payments_users.py b/apps/api/src/services/payments/payments_users.py index 506070f2..4791e766 100644 --- a/apps/api/src/services/payments/payments_users.py +++ b/apps/api/src/services/payments/payments_users.py @@ -1,6 +1,6 @@ from fastapi import HTTPException, Request from sqlmodel import Session, select -from typing import Any, List +from typing import Any from src.db.courses.courses import Course, CourseRead, AuthorWithRole from src.db.payments.payments_courses import PaymentsCourse from src.db.payments.payments_users import PaymentsUser, PaymentStatusEnum, ProviderSpecificData diff --git a/apps/web/components/Dashboard/Pages/Course/EditCourseContributors/EditCourseContributors.tsx b/apps/web/components/Dashboard/Pages/Course/EditCourseContributors/EditCourseContributors.tsx index 5a62ef5f..2327492e 100644 --- a/apps/web/components/Dashboard/Pages/Course/EditCourseContributors/EditCourseContributors.tsx +++ b/apps/web/components/Dashboard/Pages/Course/EditCourseContributors/EditCourseContributors.tsx @@ -123,7 +123,7 @@ function EditCourseContributors(props: EditCourseContributorsProps) { - {['CREATOR', 'CONTRIBUTOR', 'MAINTAINER', 'REPORTER'].map((role) => ( + {['CONTRIBUTOR', 'MAINTAINER', 'REPORTER'].map((role) => ( updateContributor(contributor.user_id, { authorship: role as ContributorRole })} @@ -180,23 +180,12 @@ function EditCourseContributors(props: EditCourseContributorsProps) { const sortContributors = (contributors: Contributor[] | undefined) => { if (!contributors) return []; - return [...contributors].sort((a, b) => { - // First sort by role priority - const rolePriority: Record = { - 'CREATOR': 0, - 'MAINTAINER': 1, - 'CONTRIBUTOR': 2, - 'REPORTER': 3 - }; - - const roleDiff = rolePriority[a.authorship] - rolePriority[b.authorship]; - if (roleDiff !== 0) return roleDiff; - - // Then sort by name - const nameA = `${a.user.first_name} ${a.user.last_name}`.toLowerCase(); - const nameB = `${b.user.first_name} ${b.user.last_name}`.toLowerCase(); - return nameA.localeCompare(nameB); - }); + // Find the creator and other contributors + const creator = contributors.find(c => c.authorship === 'CREATOR'); + const otherContributors = contributors.filter(c => c.authorship !== 'CREATOR'); + + // Return array with creator at the top, followed by other contributors in their original order + return creator ? [creator, ...otherContributors] : otherContributors; }; return (