Skip to content

Commit 15344f8

Browse files
Merge pull request #18 from devlopersabbir/revert-17-default
Revert "Search With Skills"
2 parents 1242bc6 + e41146e commit 15344f8

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/components/contents/ProfileGrid.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { db } from "@/database";
33
import { users } from "@/schemas";
44
import ProfileCard from "./ProfileCard";
55
import Paginations from "../pagination/Paginations";
6-
import { ilike, or, sql, arrayContains } from "drizzle-orm";
6+
import { ilike, or, sql } from "drizzle-orm";
77
import Notfound from "../shared/Notfound";
88
import Search from "../shared/search/Search";
99

@@ -16,29 +16,27 @@ const ProfileGrid = async ({ page, searchParams }: Props) => {
1616
const currentPage = parseInt(page); // like 1
1717
const itemPerPage = 5; // we want to show 5 item in per pages
1818
const offset = (currentPage - 1) * itemPerPage; // (1 - 1) * 3 = 0
19-
const searchSkills = searchParams ? searchParams.split(',') : []; // Assuming skills are searched by a comma-separated string in searchParams
2019

2120
const [lengths, profiles] = await Promise.all([
2221
db.select({ count: sql<number>`count(*)` }).from(users),
2322
searchParams
2423
? db
25-
.select()
26-
.from(users)
27-
.where(
28-
or(
29-
ilike(users.name, `%${searchParams}%`),
30-
ilike(users.location, `%${searchParams}%`),
31-
...(searchSkills.length > 0 ? [arrayContains(users.skills, searchSkills)] : [])
32-
),
33-
)
34-
.limit(itemPerPage)
35-
.offset(offset)
24+
.select()
25+
.from(users)
26+
.where(
27+
or(
28+
ilike(users.name, `%${searchParams}%`),
29+
ilike(users.location, `%${searchParams}%`),
30+
),
31+
)
32+
.limit(itemPerPage)
33+
.offset(offset)
3634
: db
37-
.select()
38-
.from(users)
39-
.orderBy(sql.raw("RANDOM()"))
40-
.limit(itemPerPage)
41-
.offset(offset),
35+
.select()
36+
.from(users)
37+
.orderBy(sql.raw("RANDOM()"))
38+
.limit(itemPerPage)
39+
.offset(offset),
4240
]);
4341
const count = lengths[0].count;
4442
return (

src/components/forms/SearchProfiles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const SearchProfiles = () => {
2929
type="text"
3030
value={queryString}
3131
className="text-lg p-6 text-gray-800 dark:text-white rounded-br-xl backdrop-blur-3xl bg-white/95 dark:bg-zinc-700 shadow-sm"
32-
placeholder="Search developer by name, skills or locations"
32+
placeholder="Search developer by name, and locations"
3333
/>
3434
<SearchIcon
3535
size={30}

0 commit comments

Comments
 (0)