import { redirect, notFound } from "next/navigation";
import { getSetting } from "@/lib/settings";

export const dynamic = "force-dynamic";

// Handles the admin-configurable short link to /tips (e.g. pray.vertexsoft.lk/abcd).
// Next.js only falls through to this dynamic catch-all for paths that don't
// match any real route (community, shop, login, etc. all still work normally).
export default async function ShortLinkPage({ params }: { params: Promise<{ shortlink: string }> }) {
  const { shortlink } = await params;
  const configuredSlug = await getSetting("tipShortLinkSlug", "");

  if (configuredSlug && shortlink === configuredSlug) {
    redirect("/tips");
  }

  return notFound();
}
