import Link from "next/link";
import type { Metadata } from "next";
import { getSolutionList } from "@/services/solution.service";

export const metadata: Metadata = {
  title: "解决方案",
};

export default async function SolutionListPage() {
  const solutions = await getSolutionList().catch(() => []);

  return (
    <div className="mx-auto max-w-4xl px-6 py-24">
      <h1 className="mb-12 text-4xl font-bold text-slate-900">解决方案</h1>
      <ul className="space-y-6">
        {solutions.map((solution) => (
          <li key={solution.id} className="border-b border-slate-100 pb-6">
            <Link
              href={`/solutions/${solution.meta.slug}`}
              className="text-2xl font-semibold text-slate-900 hover:text-primary"
            >
              {solution.title}
            </Link>
            {solution.industry && (
              <p className="mt-1 text-sm text-slate-500">{solution.industry}</p>
            )}
            {solution.summary && (
              <p className="mt-2 text-slate-600">{solution.summary}</p>
            )}
          </li>
        ))}
        {solutions.length === 0 && (
          <p className="text-slate-500">暂无解决方案，或后端服务未连接。</p>
        )}
      </ul>
    </div>
  );
}
