nomadro/src/modules/social/components/HomeSkillsPreview.tsx
Eric 9b7ffb24dc Ship social-first admin console, soft trials, and safer join gates.
Rebuild admin.nomadro.com around community ops, add configurable free peeks instead of nav locks, humanize user copy, and harden UGC/liveness admin APIs with backup/self-test scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 23:47:04 +08:00

140 lines
3.5 KiB
TypeScript

"use client";
import { useEffect, useState } from "react";
import Link from "next/link";
import { ArrowLeftRight, ArrowUpRight } from "lucide-react";
import { socialApi } from "@social/lib/api";
import { socialPath } from "@social/lib/socialPath";
import { socialTx } from "@social/lib/socialTx";
import SectionSpark from "./SectionSpark";
type SkillItem = {
id: string;
author: string;
city: string;
offer: string;
want: string;
};
const SEED: SkillItem[] = [
{
id: "seed-1",
author: "Mia",
city: "清迈",
offer: "英语口语陪练",
want: "帮拍短视频 / 剪辑",
},
{
id: "seed-2",
author: "Ken",
city: "里斯本",
offer: "帮看代码 / 架构 review",
want: "签证 / D7 经验咨询",
},
{
id: "seed-3",
author: "Lin",
city: "成都",
offer: "小红书运营陪跑",
want: "摄影设备借用一天",
},
{
id: "seed-4",
author: "Jay",
city: "线上",
offer: "简历 / LinkedIn 点评",
want: "葡萄牙语入门交换",
},
];
export default function HomeSkillsPreview({
/** When true, render on /team (找搭子) instead of the homepage. */
inPage = false,
}: {
inPage?: boolean;
}) {
const [items, setItems] = useState<SkillItem[]>(SEED);
useEffect(() => {
let cancelled = false;
void socialApi
.listSkills({ limit: 4 })
.then((res) => {
if (cancelled) return;
const live = res?.items || [];
if (live.length) {
setItems(
live.slice(0, 4).map((s) => ({
id: s.id,
author: s.author,
city: s.city,
offer: s.offer,
want: s.want,
})),
);
}
})
.catch(() => {
/* keep SEED */
});
return () => {
cancelled = true;
};
}, []);
return (
<section
className={`section section-compact social-section-alt${inPage ? " home-skills-on-page" : ""}`}
id={inPage ? undefined : "skills"}
aria-label={socialTx("技能交换")}
>
<div className="container">
<div className="section-header reveal">
<SectionSpark label="skills" />
<span className="section-tag">
<span>{socialTx("技能板")}</span>
<span>{socialTx("互换互助")}</span>
</span>
<h2>
<span className="social-title-emoji" aria-hidden>
🔄
</span>
{socialTx("技能交换")}
</h2>
<p>
{socialTx(
"教英语换拍视频、帮忙看代码换签证咨询——写清楚你能给什么、想换什么。",
)}
</p>
</div>
<div className="home-skills-grid reveal">
{items.map((item) => (
<Link
key={item.id}
href={socialPath("/skills")}
className="home-skill-card"
>
<span className="home-skill-city">{item.city}</span>
<strong>{item.author}</strong>
<p>
<em>{socialTx("能提供")}</em> {item.offer}
</p>
<p>
<em>{socialTx("想换到")}</em> {item.want}
</p>
</Link>
))}
</div>
<div className="social-section-actions reveal">
<Link href={socialPath("/skills")} className="btn btn-primary">
<ArrowLeftRight size={15} /> {socialTx("去发互换")}
<ArrowUpRight size={14} />
</Link>
</div>
</div>
</section>
);
}