mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-23 16:05:24 +00:00
Compare commits
No commits in common. "5d808669dd423e90cb94462527cc6fb04d4ed093" and "f7b01bfb655b5bf3caf09a7ab732e09d70688e35" have entirely different histories.
5d808669dd
...
f7b01bfb65
@ -6,6 +6,7 @@ import { useRouter } from 'next/router';
|
|||||||
import { useBadge } from '@/hooks/badges/useBadge';
|
import { useBadge } from '@/hooks/badges/useBadge';
|
||||||
import GenericButton from '@/components/buttons/GenericButton';
|
import GenericButton from '@/components/buttons/GenericButton';
|
||||||
import UserProgressFlow from './UserProgressFlow';
|
import UserProgressFlow from './UserProgressFlow';
|
||||||
|
import { Tooltip } from 'primereact/tooltip';
|
||||||
import RepoSelector from '@/components/profile/RepoSelector';
|
import RepoSelector from '@/components/profile/RepoSelector';
|
||||||
import MoreInfo from '@/components/MoreInfo';
|
import MoreInfo from '@/components/MoreInfo';
|
||||||
|
|
||||||
@ -88,40 +89,31 @@ const UserProgress = () => {
|
|||||||
const generateTasks = completedCourseIds => {
|
const generateTasks = completedCourseIds => {
|
||||||
const updatedTasks = allTasks.map(task => {
|
const updatedTasks = allTasks.map(task => {
|
||||||
if (task.status === 'Connect GitHub') {
|
if (task.status === 'Connect GitHub') {
|
||||||
const isGithubConnected = session?.account?.provider === 'github';
|
|
||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
completed: isGithubConnected,
|
completed: session?.account?.provider === 'github' ? true : false,
|
||||||
subTasks: task.subTasks.map(subTask => ({
|
subTasks: task.subTasks.map(subTask => ({
|
||||||
...subTask,
|
...subTask,
|
||||||
completed: isGithubConnected,
|
completed: session?.account?.provider === 'github' ? true : false,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// For course tasks
|
|
||||||
const userCourse = session?.user?.userCourses?.find(uc => uc.courseId === task.courseId);
|
const userCourse = session?.user?.userCourses?.find(uc => uc.courseId === task.courseId);
|
||||||
const courseCompleted = completedCourseIds.includes(task.courseId);
|
const courseCompleted = completedCourseIds.includes(task.courseId);
|
||||||
const repoSubmitted = userCourse?.submittedRepoLink ? true : false;
|
const repoSubmitted = userCourse?.submittedRepoLink ? true : false;
|
||||||
|
|
||||||
const updatedSubTasks = task.subTasks.map(subTask => {
|
|
||||||
let isSubTaskActuallyCompleted = false;
|
|
||||||
if (subTask.status.includes('Complete the course')) {
|
|
||||||
isSubTaskActuallyCompleted = courseCompleted;
|
|
||||||
} else if (subTask.status.includes('Submit your project repository')) {
|
|
||||||
isSubTaskActuallyCompleted = repoSubmitted;
|
|
||||||
}
|
|
||||||
// Add more conditions here if other types of subtasks exist in the future
|
|
||||||
return { ...subTask, completed: isSubTaskActuallyCompleted };
|
|
||||||
});
|
|
||||||
|
|
||||||
// A task is considered complete if all of its subtasks are complete.
|
|
||||||
const taskOverallCompleted = updatedSubTasks.every(st => st.completed);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...task,
|
...task,
|
||||||
completed: taskOverallCompleted,
|
completed: courseCompleted && (task.courseId === null || repoSubmitted),
|
||||||
subTasks: updatedSubTasks,
|
subTasks: task.subTasks.map(subTask => ({
|
||||||
|
...subTask,
|
||||||
|
completed: subTask.status.includes('Complete')
|
||||||
|
? courseCompleted
|
||||||
|
: subTask.status.includes('repository')
|
||||||
|
? repoSubmitted
|
||||||
|
: false,
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user