mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: course page changes
This commit is contained in:
parent
f299ecb278
commit
47b354db12
1 changed files with 185 additions and 175 deletions
|
|
@ -60,6 +60,16 @@ const CourseClient = (props: any) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getLearningTags()
|
getLearningTags()
|
||||||
|
|
||||||
|
// Collapse chapters by default if more than 5 activities in total
|
||||||
|
if (course?.chapters) {
|
||||||
|
const totalActivities = course.chapters.reduce((sum: number, chapter: any) => sum + (chapter.activities?.length || 0), 0)
|
||||||
|
const defaultExpanded: {[key: string]: boolean} = {}
|
||||||
|
course.chapters.forEach((chapter: any) => {
|
||||||
|
defaultExpanded[chapter.chapter_uuid] = totalActivities <= 5
|
||||||
|
})
|
||||||
|
setExpandedChapters(defaultExpanded)
|
||||||
|
}
|
||||||
}, [org, course])
|
}, [org, course])
|
||||||
|
|
||||||
const getActivityTypeLabel = (activityType: string) => {
|
const getActivityTypeLabel = (activityType: string) => {
|
||||||
|
|
@ -117,16 +127,18 @@ const CourseClient = (props: any) => {
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<GeneralWrapperStyled>
|
<GeneralWrapperStyled>
|
||||||
<div className="pb-3 flex flex-col md:flex-row justify-between items-start md:items-center">
|
<div className="pb-2 pt-5 flex flex-col md:flex-row justify-between items-start md:items-center">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-md font-bold text-gray-400 pb-2">Course</p>
|
<p className="text-md font-bold text-gray-400 pb-2">Course</p>
|
||||||
<h1 className="text-3xl md:text-3xl -mt-3 font-bold">{course.name}</h1>
|
<h1 className="text-3xl md:text-3xl -mt-3 font-bold">{course.name}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-col md:flex-row gap-8 pt-2">
|
||||||
|
<div className="w-full md:w-3/4 space-y-4">
|
||||||
{props.course?.thumbnail_image && org ? (
|
{props.course?.thumbnail_image && org ? (
|
||||||
<div
|
<div
|
||||||
className="inset-0 ring-1 ring-inset ring-black/10 rounded-lg shadow-xl relative w-auto h-[200px] md:h-[400px] bg-cover bg-center mb-4"
|
className="inset-0 ring-1 ring-inset ring-black/10 rounded-lg shadow-xl relative w-full h-[200px] md:h-[400px] bg-cover bg-center"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${getCourseThumbnailMediaDirectory(
|
backgroundImage: `url(${getCourseThumbnailMediaDirectory(
|
||||||
org?.org_uuid,
|
org?.org_uuid,
|
||||||
|
|
@ -137,7 +149,7 @@ const CourseClient = (props: any) => {
|
||||||
></div>
|
></div>
|
||||||
) : (
|
) : (
|
||||||
<div
|
<div
|
||||||
className="inset-0 ring-1 ring-inset ring-black/10 rounded-lg shadow-xl relative w-auto h-[400px] bg-cover bg-center mb-4"
|
className="inset-0 ring-1 ring-inset ring-black/10 rounded-lg shadow-xl relative w-full h-[400px] bg-cover bg-center"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url('../empty_thumbnail.png')`,
|
backgroundImage: `url('../empty_thumbnail.png')`,
|
||||||
backgroundSize: 'auto',
|
backgroundSize: 'auto',
|
||||||
|
|
@ -145,24 +157,37 @@ const CourseClient = (props: any) => {
|
||||||
></div>
|
></div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{course?.trail?.runs?.find((run: any) => run.course_id == course.id) && (
|
||||||
<ActivityIndicators
|
<ActivityIndicators
|
||||||
course_uuid={props.course.course_uuid}
|
course_uuid={props.course.course_uuid}
|
||||||
orgslug={orgslug}
|
orgslug={orgslug}
|
||||||
course={course}
|
course={course}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="flex flex-col md:flex-row md:space-x-10 space-y-6 md:space-y-0 pt-10">
|
<div className="course_metadata_left space-y-2">
|
||||||
<div className="course_metadata_left w-full md:basis-3/4 space-y-2">
|
|
||||||
<h2 className="py-3 text-2xl font-bold">About</h2>
|
|
||||||
<div className="">
|
<div className="">
|
||||||
<p className="py-5 whitespace-pre-wrap">{course.about}</p>
|
<p className="py-5 whitespace-pre-wrap">{course.about}</p>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='course_metadata_right w-full md:w-1/4 space-y-4'>
|
||||||
|
{/* Actions Box */}
|
||||||
|
<CoursesActions courseuuid={courseuuid} orgslug={orgslug} course={course} />
|
||||||
|
|
||||||
|
{/* Authors & Updates Box */}
|
||||||
|
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden p-4">
|
||||||
|
<CourseProvider courseuuid={course.course_uuid}>
|
||||||
|
<CourseAuthors authors={course.authors} />
|
||||||
|
</CourseProvider>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{learnings.length > 0 && learnings[0]?.text !== 'null' && (
|
{learnings.length > 0 && learnings[0]?.text !== 'null' && (
|
||||||
<div>
|
<div className="w-full">
|
||||||
<h2 className="py-3 text-2xl font-bold">
|
<h2 className="py-5 text-xl md:text-2xl font-bold">What you will learn</h2>
|
||||||
What you will learn
|
|
||||||
</h2>
|
|
||||||
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden px-5 py-5 space-y-2">
|
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden px-5 py-5 space-y-2">
|
||||||
{learnings.map((learning: any) => {
|
{learnings.map((learning: any) => {
|
||||||
// Handle both new format (object with text and emoji) and legacy format (string)
|
// Handle both new format (object with text and emoji) and legacy format (string)
|
||||||
|
|
@ -203,7 +228,8 @@ const CourseClient = (props: any) => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<h2 className="py-3 text-xl md:text-2xl font-bold">Course Lessons</h2>
|
<div className="w-full my-5 mb-10">
|
||||||
|
<h2 className="py-5 text-xl md:text-2xl font-bold">Course Lessons</h2>
|
||||||
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden">
|
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden">
|
||||||
{course.chapters.map((chapter: any) => {
|
{course.chapters.map((chapter: any) => {
|
||||||
const isExpanded = expandedChapters[chapter.chapter_uuid] ?? true; // Default to expanded
|
const isExpanded = expandedChapters[chapter.chapter_uuid] ?? true; // Default to expanded
|
||||||
|
|
@ -231,37 +257,34 @@ const CourseClient = (props: any) => {
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={`py-3 transition-all duration-200 ${isExpanded ? 'block' : 'hidden'}`}>
|
<div className={`transition-all duration-200 ${isExpanded ? 'block' : 'hidden'}`}>
|
||||||
<div className="py-3">
|
<div className="">
|
||||||
{chapter.activities.map((activity: any) => {
|
{chapter.activities.map((activity: any) => {
|
||||||
return (
|
return (
|
||||||
<div key={activity.activity_uuid} className="activity-container">
|
<Link
|
||||||
<div className="group hover:bg-neutral-50 transition-colors px-4 py-3">
|
key={activity.activity_uuid}
|
||||||
|
href={
|
||||||
|
getUriWithOrg(orgslug, '') +
|
||||||
|
`/course/${courseuuid}/activity/${activity.activity_uuid.replace('activity_', '')}`
|
||||||
|
}
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
prefetch={false}
|
||||||
|
className="block group activity-container transition-all duration-200 px-4 py-4"
|
||||||
|
>
|
||||||
<div className="flex space-x-3 items-center">
|
<div className="flex space-x-3 items-center">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
{isActivityDone(activity) ? (
|
{isActivityDone(activity) ? (
|
||||||
<div className="relative cursor-pointer">
|
<div className="relative cursor-pointer">
|
||||||
<Square size={18} className="stroke-[2] text-teal-600" />
|
<Square size={16} className="stroke-[2] text-teal-600" />
|
||||||
<Check size={18} className="stroke-[2.5] text-teal-600 absolute top-0 left-0" />
|
<Check size={16} className="stroke-[2.5] text-teal-600 absolute top-0 left-0" />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="text-neutral-300 cursor-pointer">
|
<div className="text-neutral-300 cursor-pointer">
|
||||||
<Square size={18} className="stroke-[2]" />
|
<Square size={16} className="stroke-[2]" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Link
|
<div className="flex flex-col grow">
|
||||||
className="flex flex-col grow"
|
|
||||||
href={
|
|
||||||
getUriWithOrg(orgslug, '') +
|
|
||||||
`/course/${courseuuid}/activity/${activity.activity_uuid.replace(
|
|
||||||
'activity_',
|
|
||||||
''
|
|
||||||
)}`
|
|
||||||
}
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
prefetch={false}
|
|
||||||
>
|
|
||||||
<div className="flex items-center space-x-2 w-full">
|
<div className="flex items-center space-x-2 w-full">
|
||||||
<p className="font-semibold text-neutral-600 group-hover:text-neutral-800 transition-colors">{activity.name}</p>
|
<p className="font-semibold text-neutral-600 group-hover:text-neutral-800 transition-colors">{activity.name}</p>
|
||||||
{isActivityCurrent(activity) && (
|
{isActivityCurrent(activity) && (
|
||||||
|
|
@ -270,28 +293,27 @@ const CourseClient = (props: any) => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-1.5 mt-1 text-neutral-400">
|
<div className="flex items-center space-x-1.5 mt-0.5 text-neutral-400">
|
||||||
{activity.activity_type === 'TYPE_DYNAMIC' && (
|
{activity.activity_type === 'TYPE_DYNAMIC' && (
|
||||||
<StickyNote size={11} />
|
<StickyNote size={10} />
|
||||||
)}
|
)}
|
||||||
{activity.activity_type === 'TYPE_VIDEO' && (
|
{activity.activity_type === 'TYPE_VIDEO' && (
|
||||||
<Video size={11} />
|
<Video size={10} />
|
||||||
)}
|
)}
|
||||||
{activity.activity_type === 'TYPE_DOCUMENT' && (
|
{activity.activity_type === 'TYPE_DOCUMENT' && (
|
||||||
<File size={11} />
|
<File size={10} />
|
||||||
)}
|
)}
|
||||||
{activity.activity_type === 'TYPE_ASSIGNMENT' && (
|
{activity.activity_type === 'TYPE_ASSIGNMENT' && (
|
||||||
<Backpack size={11} />
|
<Backpack size={10} />
|
||||||
)}
|
)}
|
||||||
<span className="text-xs font-medium">{getActivityTypeLabel(activity.activity_type)}</span>
|
<span className="text-xs font-medium">{getActivityTypeLabel(activity.activity_type)}</span>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</div>
|
||||||
<div className="text-neutral-300 group-hover:text-neutral-400 transition-colors cursor-pointer">
|
<div className="text-neutral-300 group-hover:text-neutral-400 transition-colors cursor-pointer">
|
||||||
<ArrowRight size={16} />
|
<ArrowRight size={14} />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -301,18 +323,6 @@ const CourseClient = (props: any) => {
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='course_metadata_right basis-1/4 space-y-4'>
|
|
||||||
{/* Actions Box */}
|
|
||||||
<CoursesActions courseuuid={courseuuid} orgslug={orgslug} course={course} />
|
|
||||||
|
|
||||||
{/* Authors & Updates Box */}
|
|
||||||
<div className="bg-white shadow-md shadow-gray-300/25 outline outline-1 outline-neutral-200/40 rounded-lg overflow-hidden p-4">
|
|
||||||
<CourseProvider courseuuid={course.course_uuid}>
|
|
||||||
<CourseAuthors authors={course.authors} />
|
|
||||||
</CourseProvider>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</GeneralWrapperStyled>
|
</GeneralWrapperStyled>
|
||||||
|
|
||||||
{isMobile && (
|
{isMobile && (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue