/** * File: page.tsx * Created by: AI Assistant * Date: 2025-11-29 * Purpose: Forum list page for kreatiVortex platform * Part of: kreatiVortex - Platform Pembelajaran Tari Online */ 'use client'; import { useParams } from 'next/navigation'; import { Link } from '@/i18n/routing'; import ActionButton from '@/components/ActionButton'; import { useFetch } from '@/hooks/useFetch'; import { useTranslations } from 'next-intl'; interface ForumData { id: string; title: string; creator: { user: { name: string; }; }; _count: { posts: number; }; updatedAt: string; type: string; } interface ClassData { id: string; name: string; code: string; description: string; } export default function ForumPage() { const params = useParams(); const classId = params.classId as string; const t = useTranslations('Forum'); const { data: forums, loading } = useFetch(`/api/forums?classId=${classId}`); const { data: classData } = useFetch(`/api/classes/${classId}`); return (

{classData ? `${t('classForum')}: ${classData.name}` : t('classForum')}

{classData ? classData.description : t('classForumSubtitle')}

{t('createButton')}
{loading ? (
Loading...
) : (
{forums?.map((forum) => (
{forum.type}

{forum.title}

{forum.creator.user.name.charAt(0)} {forum.creator.user.name} {new Date(forum.updatedAt).toLocaleDateString()}
{forum._count.posts}
{t('posts')}
))} {(!forums || forums.length === 0) && (
{t('noForums')}
)}
)}
); }