// 考勤页面
// 依据：02-architecture-design.md §3.1 路由结构
// 路由：/parent/attendance

"use client";

import { useChildAttendance } from "@/hooks/useChildAttendance";
import { useChildSwitcher } from "@/hooks/useChildSwitcher";
import { AttendanceCalendar } from "@/components/AttendanceCalendar";

export default function AttendancePage() {
  const { currentChild } = useChildSwitcher();
  const { attendance, loading, error } = useChildAttendance();

  if (loading) {
    return <span className="skeleton h-64 w-full rounded" />;
  }

  if (error) {
    return (
      <div className="rounded border border-danger p-4 text-sm text-danger">
        加载失败：{error.message}
      </div>
    );
  }

  return (
    <div className="space-y-6">
      <h1 className="font-serif text-2xl">{currentChild?.name}的考勤</h1>
      <AttendanceCalendar records={attendance} />
    </div>
  );
}
