-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
10 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
"use client"; | ||
|
||
import { useSearchProfiles } from "@lens-protocol/react-web"; | ||
import { ChevronLeft } from "lucide-react"; | ||
import Link from "next/link"; | ||
import { Button } from "~/components/ui/button"; | ||
import { LoadingSpinner } from "./LoadingIcon"; | ||
import { lensProfileToUser } from "./user/User"; | ||
|
||
export function HandleSearch({ query }: { query: string }) { | ||
export function HandleSearch({ query, maxResults = 10 }: { query: string; maxResults?: number }) { | ||
const { data: profiles, loading, error } = useSearchProfiles({ query }); | ||
|
||
if (!query) return null; | ||
if (error && query) throw new Error(error.message); | ||
|
||
const users = profiles?.map(lensProfileToUser); | ||
const users = profiles?.slice(0, maxResults).map(lensProfileToUser); | ||
const list = users.map((user) => user.name); | ||
|
||
if (loading) return <LoadingSpinner />; | ||
|
||
return ( | ||
<> | ||
<div className="h-16 flex flex-row gap-2 items-center justify-center sticky top-0 z-10 border-b backdrop-blur-md"> | ||
<Link href={"/"}> | ||
<Button variant="outline" size="sm"> | ||
<ChevronLeft size={15} /> | ||
</Button> | ||
</Link> | ||
</div> | ||
{query && list} | ||
<div className="flex flex-col gap-2 items-center justify-center">{list}</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters