"use client"; import { useActionState } from "react"; import { createActivationCode, type CreateCodeState } from "./actions"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; // 激活码生成卡片:点按钮生成,大号显示 6 位码,15 分钟有效 export function ActivationCard({ childId, childName, }: { childId: number; childName: string; }) { const [state, formAction, pending] = useActionState( createActivationCode, null, ); return (

{childName}

{state?.code ? "激活码 15 分钟内有效,只用一次" : "在孩子的 iPad 上打开网站,输入激活码"}

{state?.code ? ( {state.code} ) : (
)}
); }