import { Flame } from "lucide-react"; import { redirect } from "next/navigation"; import { todayStr } from "@/lib/dates"; import { getSessionUser } from "@/lib/auth"; import { streakOf } from "@/lib/streak"; import { dayTasks } from "@/lib/tasks"; import { TaskCard } from "./task-card"; export default async function KidPage() { const user = await getSessionUser(); if (!user) redirect("/join"); if (user.role !== "child") redirect("/parent"); const today = todayStr(); const [tasks, streak] = await Promise.all([ dayTasks(user.id, today), streakOf(user.id), ]); const doneCount = tasks.filter((t) => t.status === "done").length; const allDone = tasks.length > 0 && doneCount === tasks.length; return (

你好,{user.displayName}

{today}

{streak} 天
{tasks.length === 0 ? (

🎉

今天没有任务

连击自动保持,去玩吧!

) : ( <>

已完成 {doneCount} / {tasks.length} 项

{tasks.map((t) => ( ))}
{allDone && (

💪

今天全部完成,太棒了!

)} )}
); }