import { data, redirect } from "react-router";
import type { LoaderFunctionArgs } from "react-router";
import { getBandBySlug } from "~/lib/db.server";

export async function loader({ params }: LoaderFunctionArgs) {
  const band = getBandBySlug(params.slug!);
  if (!band) throw data("Not found", { status: 404 });
  return redirect(`/bands/of/${band.id}`);
}

export default function BandBySlug() {
  return null;
}
