"use client"; import { useEffect, useRef, useState, useSyncExternalStore, type FormEvent, } from "react"; import Link from "next/link"; import { useRouter, useSearchParams } from "next/navigation"; import { ArrowUpRight, Camera, Check, Globe2, Send, } from "lucide-react"; import SiteShell from "./SiteShell"; import AvatarSelfieModal, { type SelfieCapturePayload, } from "./AvatarSelfieModal"; import { PageIntro } from "./SocialUI"; import { useSocialConfig } from "./SocialExperience"; import { socialApi } from "@social/lib/api"; import { isSocialAvatarFaceCheckEnabled } from "@social/lib/avatarFaceCheck"; import { getSocialLive } from "@social/lib/socialLive"; import { useCaptureCapability } from "@social/lib/useCaptureCapability"; import { getLivenessState, isFaceOk, isLivenessVerified, clearFaceOk, getLivenessServerSnapshot, getLivenessSnapshot, markFaceOk, markLivenessVerified, subscribeLivenessState, } from "@social/lib/livenessGate"; import { JOIN_AVAILABILITY_OPTIONS, JOIN_GENDER_OPTIONS, JOIN_INTENT_OPTIONS, JOIN_LIVENESS_RETURN, JOIN_PROFILE_RETURN, isJoinPaid, clearJoinProfileDone, isJoinProfileDone, markJoinProfileDone, type JoinProfileDraft, } from "@social/lib/joinFlow"; import { archiveJoinLead } from "@social/lib/joinArchive"; import { flagOpenJoinModalSoon, openSocialJoinModal } from "@social/lib/joinModal"; import { setRosterPublished } from "@social/lib/discoveryRoster"; import { loadJson, saveJson } from "@social/lib/storage"; import { useLocalState } from "@social/lib/useLocalState"; import { socialPath } from "@social/lib/socialPath"; import { useSocialI18n } from "@social/lib/useSocialI18n"; import { socialTx } from "@social/lib/socialTx"; import type { SocialRosterProfile } from "@social/lib/types"; export function CommunityFeedback() { const [draft, setDraft] = useLocalState<{ kind: "反馈" | "建议"; text: string; contact: string; }>("feedback-draft", { kind: "建议", text: "", contact: "" }); const [delivery, setDelivery] = useLocalState("feedback-delivery", "draft"); const [status, setStatus] = useState(""); const [busy, setBusy] = useState(false); const lock = useRef(false); const update = (key: keyof typeof draft, value: string) => { setDraft((current) => ({ ...current, [key]: value })); setDelivery("draft"); setStatus(""); }; const reset = () => { setDraft({ kind: "建议", text: "", contact: "" }); setDelivery("draft"); setStatus(""); }; const submit = async (event: FormEvent) => { event.preventDefault(); if (!draft.text.trim() || lock.current || delivery === "sent") return; lock.current = true; setBusy(true); try { await socialApi.postFeedback({ ...draft, text: draft.text.trim(), contact: draft.contact.trim(), }); setDelivery("sent"); setStatus(socialTx("已提交,感谢反馈。")); } catch (e) { // 草稿仍在本机表单里;不要再装成「没网」——多数是服务端挂了 setDelivery("local"); const msg = e instanceof Error ? e.message : ""; setStatus( msg && msg.length < 120 ? socialTx(`提交失败:${msg}。内容还在表单里,修好后点重试。`) : socialTx("提交失败。内容还在表单里,请稍后点重试。"), ); } finally { lock.current = false; setBusy(false); } }; return (
{socialTx("说说你的想法")}

{socialTx("哪里用得不顺手?告诉我们")}

{socialTx("我们会看,但不保证马上回复。提交成功后会清空表单。")}

{delivery === "sent" ? (

{status || socialTx("已提交")}

{socialTx("回社区首页")}
) : (
void submit(event)}>
{(["建议", "反馈"] as const).map((kind) => ( ))}