-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.tsx
44 lines (38 loc) · 1.15 KB
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { cookies } from "next/headers";
import Highline from "@/components/Highline";
import { useSupabaseServer } from "@/utils/supabase/server";
import Search from "./_components/search";
export const dynamic = "force-dynamic";
export default async function Home({
params: { locale },
searchParams,
}: {
params: { locale: "en" | "pt" };
searchParams?: { [key: string]: string | string[] | undefined };
}) {
const cookieStore = cookies();
const supabase = useSupabaseServer(cookieStore);
const { q: searchValue } = searchParams as {
[key: string]: string;
};
const highlines = searchValue
? (
await supabase
.from("highline")
.select("*")
.ilike("name", `%${searchValue}%`)
).data
: (await supabase.from("highline").select("*").limit(10)).data;
return (
<div className="mt-2 space-y-6 px-2">
<Search />
<section className="flex flex-wrap justify-center gap-6">
{highlines && highlines?.length > 0
? highlines.map((highline) => (
<Highline key={highline.id} highline={highline} />
))
: null}
</section>
</div>
);
}