"use client"; import { useMemo, useRef, useState, type FormEvent } from "react"; import Link from "next/link"; import { ArrowUpRight, BookOpen, BriefcaseBusiness, Check, Globe2, HeartHandshake, Send, Sparkles, } from "lucide-react"; import SiteShell from "./SiteShell"; import { BookmarkButton, DemoBadge, EmptyState, PageIntro, SearchField, SocialDialog, } from "./SocialUI"; import { TEAM_KIND_LABEL } from "@social/lib/seed"; import { socialApi } from "@social/lib/api"; import { useLocalState } from "@social/lib/useLocalState"; import { resolveSocialCatalog } from "@social/lib/resolveCatalog"; import { useSocialConfig } from "./SocialExperience"; import { socialPath } from "@social/lib/socialPath"; import type { SocialGig, SocialTeamKind } from "@social/lib/types"; const NOTE_PROMPTS = [ "做过类似项目…", "每周可投入…", "作品在这里…", "想一起做成…", ] as const; function ApplicationForm({ gig }: { gig: SocialGig }) { const [draft, setDraft] = useLocalState(`gig-draft:${gig.id}`, { name: "", contact: "", note: "", }); const [delivery, setDelivery] = useLocalState( `gig-delivery:${gig.id}`, "draft", ); const [status, setStatus] = useState(""); const [busy, setBusy] = useState(false); const lock = useRef(false); const filled = Number(Boolean(draft.name.trim())) + Number(Boolean(draft.contact.trim())) + Number(Boolean(draft.note.trim())); const update = (key: keyof typeof draft, value: string) => { setDraft((current) => ({ ...current, [key]: value })); setDelivery("draft"); setStatus(""); }; const submit = async (event: FormEvent) => { event.preventDefault(); if ( lock.current || delivery === "sent" || !draft.name.trim() || !draft.contact.trim() ) return; lock.current = true; setBusy(true); try { await socialApi.applyGig(gig.id, { name: draft.name.trim(), contact: draft.contact.trim(), note: draft.note.trim(), }); setDelivery("sent"); setStatus("申请已提交。对方看到后会再联系你——先不急。"); } catch { setDelivery("local"); setStatus("申请已先留在本机。有网后再点一次即可重试。"); } finally { lock.current = false; setBusy(false); } }; if (delivery === "sent") { return (
已表达兴趣

{status || "对方看到后会再联系你。"}

{gig.title} {TEAM_KIND_LABEL[gig.kind || "parttime"]}
去群里打个招呼 逛逛共创
); } return (
{TEAM_KIND_LABEL[gig.kind || "parttime"]} {gig.title}

{gig.role}

{gig.pay} {gig.remote ? "线上也能做" : "可以见面做"} {gig.tags.slice(0, 4).map((tag) => ( {tag} ))}
{filled === 0 ? "先简单介绍自己" : filled < 3 ? `还差 ${3 - filled} 项(简介可选)` : "可以提交了"}
void submit(e)}>