mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: assignments activity page init
This commit is contained in:
parent
182cd73001
commit
29600d9b6c
12 changed files with 564 additions and 105 deletions
|
|
@ -22,7 +22,6 @@ export function AssignmentProvider({ children, assignment_uuid }: { children: Re
|
|||
(url) => swrFetcher(url, accessToken)
|
||||
)
|
||||
|
||||
// Define a key for the course object based on assignment data
|
||||
const course_id = assignment?.course_id
|
||||
|
||||
const { data: course_object, error: courseObjectError } = useSWR(
|
||||
|
|
@ -38,12 +37,14 @@ export function AssignmentProvider({ children, assignment_uuid }: { children: Re
|
|||
)
|
||||
|
||||
useEffect(() => {
|
||||
setAssignmentsFull({ assignment_object: assignment, assignment_tasks: assignment_tasks, course_object: course_object, activity_object: activity_object })
|
||||
}, [assignment, assignment_tasks, course_object, activity_object])
|
||||
if (assignment && assignment_tasks && (!course_id || course_object) && (!activity_id || activity_object)) {
|
||||
setAssignmentsFull({ assignment_object: assignment, assignment_tasks: assignment_tasks, course_object: course_object, activity_object: activity_object })
|
||||
}
|
||||
}, [assignment, assignment_tasks, course_object, activity_object, course_id, activity_id])
|
||||
|
||||
if (assignmentError || assignmentTasksError || courseObjectError) return <div></div>
|
||||
if (assignmentError || assignmentTasksError || courseObjectError || activityObjectError) return <div></div>
|
||||
|
||||
if (!assignment || !assignment_tasks || (course_id && !course_object)) return <div></div>
|
||||
if (!assignment || !assignment_tasks || (course_id && !course_object) || (activity_id && !activity_object)) return <div></div>
|
||||
|
||||
return <AssignmentContext.Provider value={assignmentsFull}>{children}</AssignmentContext.Provider>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue