fix: trail related bugs + general design improvements

This commit is contained in:
swve 2023-12-14 16:41:28 +01:00
parent 53f40f3f34
commit 5b3c2fab24
17 changed files with 128 additions and 71 deletions

View file

@ -69,7 +69,6 @@ function OrgEditGeneral(props: any) {
initialValues={orgValues}
onSubmit={(values, { setSubmitting }) => {
setTimeout(() => {
alert(JSON.stringify(values, null, 2));
setSubmitting(false);
updateOrg(values)
}, 400);

View file

@ -4,7 +4,7 @@ import { useAuth } from '@components/Security/AuthContext';
import ToolTip from '@components/StyledElements/Tooltip/Tooltip'
import LearnHouseDashboardLogo from '@public/dashLogo.png';
import Avvvatars from 'avvvatars-react';
import { ArrowLeft, Book, Home, School, Settings } from 'lucide-react'
import { ArrowLeft, Book, BookCopy, Home, School, Settings } from 'lucide-react'
import Image from 'next/image';
import Link from 'next/link'
import React, { use, useEffect } from 'react'
@ -52,7 +52,7 @@ function LeftMenu() {
<Link className='bg-white/5 rounded-lg p-2 hover:bg-white/10 transition-all ease-linear' href={`/dash`} ><Home size={18} /></Link>
</ToolTip>
<ToolTip content={"Courses"} slateBlack sideOffset={8} side='right' >
<Link className='bg-white/5 rounded-lg p-2 hover:bg-white/10 transition-all ease-linear' href={`/dash/courses`} ><Book size={18} /></Link>
<Link className='bg-white/5 rounded-lg p-2 hover:bg-white/10 transition-all ease-linear' href={`/dash/courses`} ><BookCopy size={18} /></Link>
</ToolTip>
<ToolTip content={"Organization"} slateBlack sideOffset={8} side='right' >
<Link className='bg-white/5 rounded-lg p-2 hover:bg-white/10 transition-all ease-linear' href={`/dash/org/settings/general`} ><School size={18} /></Link>

View file

@ -2,11 +2,12 @@
import { useOrg } from '@components/Contexts/OrgContext';
import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement';
import ConfirmationModal from '@components/StyledElements/ConfirmationModal/ConfirmationModal';
import { DotsHorizontalIcon } from '@radix-ui/react-icons';
import { getUriWithOrg } from '@services/config/config';
import { deleteCourseFromBackend } from '@services/courses/courses';
import { getCourseThumbnailMediaDirectory } from '@services/media/media';
import { revalidateTags } from '@services/utils/ts/requests';
import { FileEdit, X } from 'lucide-react';
import { FileEdit, MoreHorizontal, Settings, X } from 'lucide-react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import React, { use, useEffect } from 'react'
@ -55,12 +56,12 @@ const AdminEditsArea = (props: { orgSlug: string, courseId: string, course: any,
action="update"
ressourceType="course"
checkMethod='roles' orgId={props.course.org_id}>
<div className="flex space-x-1 absolute justify-center mx-auto z-20 bottom-14 left-1/2 transform -translate-x-1/2">
<div className="flex space-x-2 absolute z-20 bottom-14 right-[15px] transform">
<Link href={getUriWithOrg(props.orgSlug, "/dash/courses/course/" + removeCoursePrefix(props.courseId) + "/general")}>
<div
className=" hover:cursor-pointer p-1 px-4 bg-orange-600 rounded-xl items-center justify-center flex shadow-xl"
className=" hover:cursor-pointer p-1 px-4 bg-slate-700 rounded-xl items-center flex shadow-xl"
rel="noopener noreferrer">
<FileEdit size={14} className="text-orange-200 font-bold" />
<Settings size={14} className="text-slate-200 font-bold" />
</div>
</Link>
<ConfirmationModal

View file

@ -8,6 +8,7 @@ interface Props {
course: any
orgslug: string
course_uuid: string
activity: any
current_activity?: any
}
@ -24,15 +25,11 @@ function ActivityIndicators(props: Props) {
function isActivityDone(activity: any) {
const runs = course.trail.runs;
for (let run of runs) {
for (let step of run.steps) {
if (step.activity_id === activity.id && step.complete === true) {
return false;
}
}
let run = props.course.trail.runs.find((run: any) => run.course_id == props.course.id);
if (run) {
return run.steps.find((step: any) => step.activity_id == activity.id);
}
return false;
}
function isActivityCurrent(activity: any) {

View file

@ -1,21 +1,29 @@
'use client';
import { useOrg } from '@components/Contexts/OrgContext';
import { getAPIUrl, getBackendUrl, getUriWithOrg } from '@services/config/config';
import { removeCourse } from '@services/courses/activity';
import { getCourseThumbnailMediaDirectory } from '@services/media/media';
import { revalidateTags } from '@services/utils/ts/requests';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { use, useEffect } from 'react';
import { mutate } from 'swr';
interface TrailCourseElementProps {
course: any
run: any
orgslug: string
}
function TrailCourseElement(props: TrailCourseElementProps) {
const org = useOrg() as any;
const courseid = props.course.course_uuid.replace("course_", "")
const course = props.course
const router = useRouter();
const course_total_steps = props.run.course_total_steps
const course_completed_steps = props.run.steps.length
const orgID = org?.id;
const course_progress = Math.round((course_completed_steps / course_total_steps) * 100)
async function quitCourse(course_uuid: string) {
// Close activity
@ -25,14 +33,18 @@ function TrailCourseElement(props: TrailCourseElementProps) {
router.refresh();
// Mutate
mutate(`${getAPIUrl()}trail/org_slug/${props.orgslug}/trail`);
mutate(`${getAPIUrl()}trail/org/${orgID}/trail`);
}
useEffect(() => {
}
, [props.course, org]);
return (
<div className='trailcoursebox flex p-3 bg-white rounded-xl' style={{ boxShadow: '0px 4px 7px 0px rgba(0, 0, 0, 0.03)' }}>
<Link href={getUriWithOrg(props.orgslug, "/course/" + courseid)}>
<div className="course_tumbnail inset-0 ring-1 ring-inset ring-black/10 rounded-lg relative h-[50px] w-[72px] bg-cover bg-center" style={{ backgroundImage: `url(${getCourseThumbnailMediaDirectory(props.course.course_object.org_id, props.course.course_object.course_uuid, props.course.course_object.thumbnail)})`, boxShadow: '0px 4px 7px 0px rgba(0, 0, 0, 0.03)' }}></div>
<div className="course_tumbnail inset-0 ring-1 ring-inset ring-black/10 rounded-lg relative h-[50px] w-[72px] bg-cover bg-center" style={{ backgroundImage: `url(${getCourseThumbnailMediaDirectory(org.org_uuid, props.course.course_uuid, props.course.thumbnail_image)})`, boxShadow: '0px 4px 7px 0px rgba(0, 0, 0, 0.03)' }}></div>
</Link>
<div className="course_meta pl-5 flex-grow space-y-1">
<div className="course_top">
@ -40,19 +52,19 @@ function TrailCourseElement(props: TrailCourseElementProps) {
<div className="course_basic flex flex-col flex-end -space-y-2">
<p className='p-0 font-bold text-sm text-gray-700'>Course</p>
<div className="course_progress flex items-center space-x-2">
<h2 className='font-bold text-xl'>{course.course_object.name}</h2>
<h2 className='font-bold text-xl'>{course.name}</h2>
<div className='bg-slate-300 rounded-full w-[10px] h-[5px]'></div>
<h2>{course.progress}%</h2>
<h2>{course_progress}%</h2>
</div>
</div>
<div className="course_actions flex-grow flex flex-row-reverse">
<button onClick={() => quitCourse(course.course_uuid)} className="bg-red-200 text-red-700 hover:bg-red-300 rounded-full text-xs h-5 px-2 font-bold">Quit Course</button>
<button onClick={() => quitCourse(course.course_uuid)} className="bg-red-200 text-red-700 hover:bg-red-300 rounded-full text-xs h-5 px-2 font-bold">Quit Course</button>
</div>
</div>
</div>
<div className="course_progress indicator w-full">
<div className="w-full bg-gray-200 rounded-full h-1.5 ">
<div className={`bg-teal-600 h-1.5 rounded-full`} style={{ width: `${course.progress}%` }} ></div>
<div className={`bg-teal-600 h-1.5 rounded-full`} style={{ width: `${course_progress}%` }} ></div>
</div>
</div>