| 1 | "use client"; |
| 2 | |
| 3 | import { useId, useState } from "react"; |
| 4 | import { ONBOARDING_CHECK_COPY } from "@/lib/content/onboarding-check"; |
| 5 | import { pickText, pickTextLocale } from "@/lib/i18n/dictionaries"; |
| 6 | import { recordFunnel } from "./usage-counting"; |
| 7 | |
| 8 | export function OnboardingCheck({ kind, locale }: { kind: "install" | "quickstart"; locale: string }) { |
| 9 | const [checked, setChecked] = useState(false); |
| 10 | const description = useId(); |
| 11 | const copy = ONBOARDING_CHECK_COPY[kind]; |
| 12 | return ( |
| 13 | <div className="onboarding-check" lang={pickTextLocale(locale)}> |
| 14 | <button type="button" className="onboarding-check-btn" disabled={checked} aria-describedby={description} onClick={() => { |
| 15 | if (checked) return; |
| 16 | recordFunnel(kind === "install" ? "install_confirmed" : "quickstart_confirmed"); |
| 17 | setChecked(true); |
| 18 | }}>{pickText(copy.label, locale)}</button> |
| 19 | <p id={description} className="text-sm" role="status">{pickText(checked ? ONBOARDING_CHECK_COPY.checked : copy.detail, locale)}</p> |
| 20 | </div> |
| 21 | ); |
| 22 | } |
| 23 |