'use client'; import { useEffect, useState } from 'react'; import { Questionnaire } from '@/components/onboarding'; import type { Locale } from '@/i18n-config'; interface Dictionary { onboarding: Record; } interface QuestionsPageProps { params: Promise<{ locale: Locale }>; } export default function QuestionsPage({ params }: QuestionsPageProps) { const [dict, setDict] = useState(null); const [locale, setLocale] = useState('zh-CN'); const [loading, setLoading] = useState(true); useEffect(() => { async function loadDictionary() { const { locale: loc } = await params; setLocale(loc); try { const response = await fetch(`/api/dictionary?locale=${loc}`); if (response.ok) { const dictionary = await response.json(); setDict(dictionary); } } catch (error) { console.error('Failed to load dictionary:', error); } finally { setLoading(false); } } loadDictionary(); }, [params]); if (loading || !dict) { return (
Loading...
); } return ; }