import { loadUserPublishedTrails } from "@/data/queries";
import { TrailsList } from "../../../TrailsList";
import { EmptyState } from "../../../EmptyState";

export default async function ProfilePublishedPage({
  params,
}: {
  params: Promise<{ handle: string }>;
}) {
  const { handle: rawHandle } = await params;
  const handle = decodeURIComponent(rawHandle).replace(/^@/, "");
  const trails = await loadUserPublishedTrails(handle);

  if (trails.length === 0) {
    return <EmptyState message="no trails published yet" />;
  }

  return <TrailsList trails={trails} />;
}
