diff --git a/src/app/(app)/course/[courseId]/home/(hooks)/useTotalStudents.tsx b/src/app/(app)/course/[courseId]/home/(hooks)/useTotalStudents.tsx index 1034788..3968b75 100644 --- a/src/app/(app)/course/[courseId]/home/(hooks)/useTotalStudents.tsx +++ b/src/app/(app)/course/[courseId]/home/(hooks)/useTotalStudents.tsx @@ -4,8 +4,12 @@ import { useCourse } from "@/app/(app)/course/[courseId]/(hooks)/useCourse" import { useQuery } from "@tanstack/react-query" const useTotalStudentsQuery = ({ courseId }: { courseId: number }) => { - const studentQuery = useQuery({ - queryKey: [`courses/${courseId}/students`], + const studentQuery = useQuery< + unknown, + unknown, + { total_students: number; opted_in_students: number } + >({ + queryKey: [`courses/${courseId}/student-counts`], }) return { @@ -21,7 +25,8 @@ export const useTotalStudents = () => { }) return { - totalStudents: data?.count ?? 0, + totalStudents: data?.total_students ?? 0, + optedInStudents: data?.opted_in_students ?? 0, isLoading, error, refetch: getTotalStudentsAsync, diff --git a/src/app/(app)/course/[courseId]/home/page.tsx b/src/app/(app)/course/[courseId]/home/page.tsx index ac8f904..4299560 100644 --- a/src/app/(app)/course/[courseId]/home/page.tsx +++ b/src/app/(app)/course/[courseId]/home/page.tsx @@ -15,14 +15,14 @@ import { useTotalStudents } from "./(hooks)/useTotalStudents" const HomePage = () => { const { courseId } = useCourse() const { completionPercentage, nextStepTitle } = CalculateOnboardingCompletion() - const { totalStudents, error: totalStudentsError } = useTotalStudents() + const { totalStudents, optedInStudents, error: totalStudentsError } = useTotalStudents() const { data: pastAttributes, error: pastAttributesError } = usePastAttributes() useHandleErrors({ totalStudentsError, pastAttributesError }) const signUpStats = [ - { label: "Students Enrolled on Your LMS", value: 30 }, - { label: "Total Team Formation Acceptions", value: totalStudents }, + { label: "Students Enrolled on Your LMS", value: totalStudents }, + { label: "Total Team Formation Acceptions", value: optedInStudents }, ] const previousTeamFormation = [