Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
feat: alert when no search results found (#90)
Browse files Browse the repository at this point in the history
* Added the alert when no results found

* updated the details of the alert
  • Loading branch information
RajeevDash007 authored Jun 26, 2024
1 parent 4f5761a commit 24c2730
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions src/app/search/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import prisma from "@/models/db";
import Items from "@/components/list/Items";
import REACH from "@/config/reach";
import Form from "./form";
import Alert from "@/components/Alert";

export default async function Page({ searchParams }) {
const query = {
Expand Down Expand Up @@ -57,35 +58,46 @@ export default async function Page({ searchParams }) {
</h2>
<div className="overflow-hidden rounded-lg bg-white shadow">
<div className="p-6">
<Items
data={users.map((user) => ({
id: user.username,
image: user.image,
url: `/${user.username}`,
urlText: user.name,
description: user.bio,
socials: user.platforms.map((platform) => ({
icon: platform.name,
})),
meta: [
// biggest reach
{
icon: WifiIcon,
text: `Reach ${
REACH().data[
REACH().sortByLargest(user.platforms)[0].reach
].group
}`,
},
// lowest price
{
icon: ArrowUpIcon,
text: `From $${user.platforms[0].price}`,
},
],
tags: user.tags?.split(","),
}))}
/>
{users.length > 0 ? (
<Items
data={users.map((user) => ({
id: user.username,
image: user.image,
url: `/${user.username}`,
urlText: user.name,
description: user.bio,
socials: user.platforms.map((platform) => ({
icon: platform.name,
})),
meta: [
// biggest reach
{
icon: WifiIcon,
text: `Reach ${
REACH().data[
REACH().sortByLargest(user.platforms)[0].reach
].group
}`,
},
// lowest price
{
icon: ArrowUpIcon,
text: `From $${user.platforms[0].price}`,
},
],
tags: user.tags?.split(","),
}))}
/>
) : (
<Alert
type="info"
message="No results found"
details={[
"Try adjusting your search parameters.",
"Try to broaden your search criteria.",
]}
/>
)}
</div>
</div>
</section>
Expand Down

0 comments on commit 24c2730

Please sign in to comment.