// useChildLessonPlanDetail:获取子女备课详情(只读) // 依据:02-architecture-design.md §4.2 GraphQL 接入 // 对标 /parent/lesson-plans/[planId]/view 页面(家长只读视角) "use client"; import { useQuery, type CombinedError } from "urql"; import { CHILD_LESSON_PLAN_DETAIL } from "@/lib/graphql/operations"; import type { LessonPlanDetail } from "@/types"; import { useChildStore } from "@/store/child-store"; interface ChildLessonPlanDetailResponse { childLessonPlanDetail: LessonPlanDetail; } export function useChildLessonPlanDetail(planId: string): { lessonPlan: LessonPlanDetail | null; loading: boolean; error: CombinedError | undefined; } { const currentChildId = useChildStore((s) => s.currentChildId); const [result] = useQuery({ query: CHILD_LESSON_PLAN_DETAIL, variables: { childId: currentChildId, planId }, pause: !currentChildId || !planId, }); return { lessonPlan: result.data?.childLessonPlanDetail ?? null, loading: result.fetching, error: result.error, }; }