SPB Git forge

spb/toveli

Public
14commits 1branches 0releases
1.1 MBsize
maindefault branch
3 h agolast push
TypeScript 50.6% JavaScript 46.1% SQL 2.1% Shell 0.6% CSS 0.5%
1.4 KB · 29 lines tsx
Raw Blame History
1import type { Metadata } from "next";2import { Suspense } from "react";3import { unifiedSearch, unifiedPoints } from "@/lib/search";4import { dbAvailable } from "@/lib/db";5import { fromUrl, describe, type SP } from "@/lib/search-params";6import { ResultsView } from "./results-view";7import { Empty } from "@/components/ui";89export const dynamic = "force-dynamic";10export async function generateMetadata({ searchParams }: { searchParams: Promise<SP> }): Promise<Metadata> {11  const p = fromUrl(await searchParams);12  const what = p.market === "rent" ? "Logements à louer" : "Propriétés à vendre";13  const where = p.city ?? p.region ?? "au Québec";14  return { title: `${what} ${p.city ? "à " : p.region ? "— " : ""}${where}`, description: `${what} ${where} : liste, carte, filtres et estimation de valeur sur Toveli.` };15}1617export default async function Recherche({ searchParams }: { searchParams: Promise<SP> }) {18  const sp = await searchParams;19  if (!dbAvailable()) return <div className="mx-auto max-w-7xl px-4 py-10"><Empty title="Données en cours de chargement" hint="La base Toveli n'est pas encore disponible. Réessayez dans quelques minutes." /></div>;20  const p = fromUrl(sp);21  const res = await unifiedSearch(p);22  const points = await unifiedPoints({ ...p, limit: 1500, offset: 0 });23  return (24    <Suspense>25      <ResultsView initial={res} points={points} params={p} title={describe(p, res.total)} />26    </Suspense>27  );28}29