{form.type === "report" ? t("reportPageTitle") : t("title")}
{form.type === "report" ? t("reportPageSubtitle") : t("subtitle")}
{t("successTitle")}
{t("successDesc")}
"use client"; import { Suspense, useEffect, useState } from "react"; import { useSearchParams } from "next/navigation"; import { useTranslation } from "@/i18n/navigation"; import Footer from "@/app/components/Footer"; import { apiFetch } from "@/app/lib/api-client"; type FeedbackType = "suggestion" | "bug" | "report"; function FeedbackForm() { const { t } = useTranslation("feedback"); const searchParams = useSearchParams(); const initialType = searchParams.get("type") === "report" ? "report" : "suggestion"; const reportTarget = searchParams.get("target") || ""; const [submitted, setSubmitted] = useState(false); const [form, setForm] = useState({ type: initialType as FeedbackType, email: "", title: "", content: "", targetId: reportTarget, }); useEffect(() => { if (reportTarget) { setForm((prev) => ({ ...prev, type: "report", targetId: reportTarget, title: prev.title || t("reportTitle").replace("{target}", reportTarget), content: prev.content || t("reportContent").replace("{target}", reportTarget), })); } }, [reportTarget, t]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); await apiFetch("/api/feedback", { method: "POST", body: JSON.stringify(form), }); setSubmitted(true); }; return (
{form.type === "report" ? t("reportPageSubtitle") : t("subtitle")}
{t("successDesc")}