"use client"; import { useState } from "react"; import { Link, useLocale } from "@/i18n/navigation"; import { useTranslation } from "@/i18n/navigation"; import { getPayEnv, getRecommendedChannel, mustUseWxPay, redirectToPay, getDeviceFromEnv, } from "@/app/lib/payment"; import type { PayChannel, PayEnv } from "@/app/lib/payment"; const MEDIA_NAMES_ZH = ["36氪", "少数派", "极客公园", "虎嗅", "创业邦", "澎湃新闻"]; const MEDIA_NAMES_EN = ["36Kr", "sspai", "GeekPark", "Huxiu", "Cyzone", "The Paper"]; const avatarPhotos = [ "https://i.pravatar.cc/150?img=32", "https://i.pravatar.cc/150?img=33", "https://i.pravatar.cc/150?img=25", "https://i.pravatar.cc/150?img=52", "https://i.pravatar.cc/150?img=44", "https://i.pravatar.cc/150?img=55", "https://i.pravatar.cc/150?img=47", "https://i.pravatar.cc/150?img=57", "https://i.pravatar.cc/150?img=48", "https://i.pravatar.cc/150?img=59", "https://i.pravatar.cc/150?img=49", ]; const features = [ { icon: "🍹", key: "feature1" as const }, { icon: "❤️", key: "feature2" as const }, { icon: "🧪", key: "feature3" as const }, { icon: "🌎", key: "feature4" as const }, { icon: "💬", key: "feature5" as const }, ]; export default function HeroSection() { const { t } = useTranslation("common"); const { t: tHero } = useTranslation("hero"); const locale = useLocale(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleJoin = async (e: React.FormEvent) => { e.preventDefault(); const em = email.trim(); if (!em) { setError(locale === "zh" ? "请输入邮箱" : "Please enter your email"); return; } setError(null); setLoading(true); try { const res = await fetch("/api/meetup/ensure-user", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: em, password: password || undefined }), credentials: "include", }); const data = await res.json(); if (!res.ok || !data?.ok) { throw new Error(data?.error || (locale === "zh" ? "操作失败" : "Operation failed")); } await fetch("/api/auth/sync-session", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token: data.token, record: data.record }), }); const returnUrl = typeof window !== "undefined" ? `${window.location.origin}/${locale}/join/paid` : "/zh/join/paid"; const env: PayEnv = typeof window !== "undefined" ? (navigator.userAgent.includes("MicroMessenger") ? "wechat" : "pc") : "pc"; const channel: PayChannel = mustUseWxPay(env) ? "wxpay" : getRecommendedChannel(env); redirectToPay({ user_id: data.user_id, return_url: returnUrl, channel, device: getDeviceFromEnv(env), useJoinConfig: true, }); } catch (err) { setError(err instanceof Error ? err.message : "操作失败"); } finally { setLoading(false); } }; return (
{/* Left Column */}
🏆 {tHero("badge")}

{tHero("title")}
{tHero("titleSuffix")}

{tHero("subtitle")}

{features.map((f) => (
{f.icon} {tHero(f.key)}
))}
{avatarPhotos.slice(0, 8).map((src, i) => ( ))}
{tHero("membersJoined")}

{tHero("mediaPress")}

{(locale === "zh" ? MEDIA_NAMES_ZH : MEDIA_NAMES_EN).map( (name) => ( {name} ) )}
{/* Right Column: Video + Email */}
{ setEmail(e.target.value); setError(null); }} placeholder={tHero("emailPlaceholder")} className="w-full border border-gray-200 dark:border-gray-700 rounded-lg px-4 py-3 text-sm placeholder-gray-400 dark:placeholder-gray-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-[#ff4d4f]/20 focus:border-[#ff4d4f] transition-colors mb-3" /> { setPassword(e.target.value); setError(null); }} placeholder={locale === "zh" ? "密码(老用户必填)" : "Password (required for existing users)"} className="w-full border border-gray-200 dark:border-gray-700 rounded-lg px-4 py-3 text-sm placeholder-gray-400 dark:placeholder-gray-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-[#ff4d4f]/20 focus:border-[#ff4d4f] transition-colors mb-3" /> {error && (

{error}

)}

{locale === "zh" ? "新用户将自动注册,支付成功后需修改默认密码" : "New users auto-register; change default password after payment"}

📍 {tHero("quickLinks.nextStop")} 🍹 {tHero("quickLinks.meetups")} ❤️ {tHero("quickLinks.dating")} 📊 {tHero("quickLinks.tools")} 🤖 {tHero("quickLinks.ai")} 💰 {tHero("quickLinks.gigs")} 📊 {tHero("quickLinks.report")} 💬 {tHero("quickLinks.join")}
); }