Replace reverse-proxy/iframe approach with @ebook/@community/@navmini imports under /nav /book /community so localhost:3000 serves all three products directly. Co-authored-by: Cursor <cursoragent@cursor.com>
136 lines
4.8 KiB
TypeScript
136 lines
4.8 KiB
TypeScript
"use client";
|
|
|
|
import { useMemo, useState } from "react";
|
|
import Link from "next/link";
|
|
import { useI18n } from "@community/lib/i18n";
|
|
import { localizedToolCategories, localizedToolLinks } from "@community/lib/toolCopy";
|
|
import SiteShell from "@community/components/SiteShell";
|
|
import RingNext from "@community/components/RingNext";
|
|
import { useRingSteps } from "@community/lib/rings";
|
|
|
|
const FEATURED = ["weekend", "day-plan", "bill-split", "mood", "scam-alerts", "deposit-return"];
|
|
|
|
/** Utility drawer — not a product mega-menu. */
|
|
export default function ToolsHubPage() {
|
|
const { t, locale } = useI18n();
|
|
const rings = useRingSteps();
|
|
const [filter, setFilter] = useState("all");
|
|
const [q, setQ] = useState("");
|
|
const [showAll, setShowAll] = useState(false);
|
|
|
|
const tools = useMemo(() => localizedToolLinks(locale), [locale]);
|
|
const categories = useMemo(() => localizedToolCategories(locale), [locale]);
|
|
|
|
const featured = useMemo(
|
|
() => FEATURED.map((id) => tools.find((tool) => tool.id === id)).filter((tool): tool is NonNullable<typeof tool> => !!tool),
|
|
[tools]
|
|
);
|
|
|
|
const filtered = useMemo(() => {
|
|
let list = filter === "all" ? tools : tools.filter((tool) => tool.category === filter);
|
|
if (q.trim()) {
|
|
const s = q.toLowerCase();
|
|
list = list.filter((tool) => tool.title.toLowerCase().includes(s) || tool.desc.toLowerCase().includes(s));
|
|
}
|
|
return list;
|
|
}, [filter, q, tools]);
|
|
|
|
const visible = showAll || q.trim() || filter !== "all" ? filtered : filtered.slice(0, 12);
|
|
|
|
return (
|
|
<SiteShell showFooter>
|
|
<div className="tools-hub-page">
|
|
<div className="container">
|
|
<nav className="detail-nav">
|
|
<Link href="/community">{t.common.backHome}</Link>
|
|
</nav>
|
|
<div className="section-header">
|
|
<span className="section-tag">{t.tools.tag}</span>
|
|
<h1>{t.tools.title}</h1>
|
|
<p>{t.tools.subtitle}</p>
|
|
</div>
|
|
|
|
<RingNext title={t.ring.continue} steps={rings.afterTools} />
|
|
|
|
<div className="tools-featured">
|
|
<div className="tools-featured-head">
|
|
<strong>✨ {t.tools.tag}</strong>
|
|
<span>{featured.length} · {t.tools.featuredHint}</span>
|
|
</div>
|
|
<div className="tools-featured-grid tools-featured-grid-compact">
|
|
{featured.map((tool) => (
|
|
<Link key={tool.id} href={tool.href} className="tools-featured-card">
|
|
<span>{tool.emoji}</span>
|
|
<div>
|
|
<h3>{tool.title}</h3>
|
|
<p>{tool.desc}</p>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="tools-hub-toolbar">
|
|
<input
|
|
className="tools-hub-search"
|
|
placeholder={t.tools.searchPlaceholder}
|
|
value={q}
|
|
onChange={(e) => setQ(e.target.value)}
|
|
/>
|
|
<div className="tools-hub-filters">
|
|
{categories.map((c) => (
|
|
<button
|
|
key={c.key}
|
|
className={`filter-btn${filter === c.key ? " active" : ""}`}
|
|
onClick={() => setFilter(c.key)}
|
|
>
|
|
{c.label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="tools-hub-grid">
|
|
{visible.map((tool) => (
|
|
<Link key={tool.id} href={tool.href} className="tools-hub-card">
|
|
<span className="tools-hub-emoji">{tool.emoji}</span>
|
|
<h3>{tool.title}</h3>
|
|
<p>{tool.desc}</p>
|
|
<span className="tools-hub-go">{t.tools.open}</span>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
{!showAll && !q.trim() && filter === "all" && filtered.length > 12 && (
|
|
<div className="tools-hub-more">
|
|
<button type="button" className="btn btn-ghost" onClick={() => setShowAll(true)}>
|
|
{t.tools.showAll.replace("{n}", String(filtered.length))}
|
|
</button>
|
|
</div>
|
|
)}
|
|
{filtered.length === 0 && (
|
|
<div className="notif-empty">
|
|
<p className="dest-empty">{t.tools.empty}</p>
|
|
<div className="dating-empty-actions">
|
|
<button
|
|
type="button"
|
|
className="btn btn-sm"
|
|
onClick={() => {
|
|
setQ("");
|
|
setFilter("all");
|
|
setShowAll(false);
|
|
}}
|
|
>
|
|
{t.tools.clearFilter}
|
|
</button>
|
|
<Link href="/community/next-stop" className="btn btn-primary btn-sm">
|
|
{t.tools.goNextStop}
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</SiteShell>
|
|
);
|
|
}
|