Skip to content

Commit 2b83967

Browse files
Merge pull request #508 from CodebilityDev/fix/filter-hire-codevs
PR: Fix Hire Codevs Showcase Qualification Filter
2 parents f889328 + b16e8e3 commit 2b83967

4 files changed

Lines changed: 114 additions & 1185 deletions

File tree

‎apps/codebility/app/(marketing)/profiles/_components/CodevCard.tsx‎

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ interface Props {
3131
color: string;
3232
}
3333

34-
const STATUS_CONFIG: Record<
35-
InternalStatus,
36-
{ label: string; className: string }
37-
> = {
34+
const STATUS_CONFIG: Record<InternalStatus, { label: string; className: string }> = {
3835
TRAINING: {
3936
label: "Training",
4037
className:
@@ -118,22 +115,20 @@ const CodevCard = ({ codev, color }: Props) => {
118115
: {};
119116
}, [codev.level, codev.codev_points]);
120117

121-
// Line 119: Enhanced card wrapper with click redirect
122118
return (
123119
<div
124120
className="h-64"
125121
onMouseEnter={() => setHovered(true)}
126122
onMouseLeave={() => setHovered(false)}
127123
>
128-
<div
129-
onClick={() =>
130-
(window.location.href = `https://www.codebility.tech/profiles/${codev.id}`)
131-
}
132-
className="group relative flex h-full w-full cursor-pointer flex-col items-center justify-between rounded-lg border border-white/20 bg-white/10 p-4 shadow-2xl backdrop-blur-md transition-all duration-300 hover:scale-[1.02] hover:bg-white/20 dark:border-white/10 dark:bg-white/5 dark:hover:bg-white/10"
124+
<div
125+
onClick={() => window.location.href = `https://www.codebility.tech/profiles/${codev.id}`}
126+
className="group relative flex h-full w-full flex-col items-center justify-between rounded-lg border border-white/20 bg-white/10 p-4 shadow-2xl backdrop-blur-md transition-all duration-300 cursor-pointer hover:bg-white/20 hover:scale-[1.02] dark:border-white/10 dark:bg-white/5 dark:hover:bg-white/10"
133127
>
134128
{/* Background decoration */}
135129
<div className="from-customBlue-50/30 dark:from-customBlue-950/10 absolute inset-0 bg-gradient-to-br to-purple-50/30 opacity-0 transition-opacity duration-300 group-hover:opacity-100 dark:to-purple-950/10" />
136130
<div className="absolute -right-4 -top-4 h-32 w-32 rounded-full bg-gradient-to-br from-yellow-400/10 to-orange-400/10 opacity-0 blur-2xl transition-opacity duration-500 group-hover:opacity-100" />
131+
137132
<div className="grid w-full grid-cols-4 gap-2">
138133
<div className="col-span-1" />
139134
<div className="relative col-span-2 flex justify-center">
@@ -203,12 +198,7 @@ const CodevCard = ({ codev, color }: Props) => {
203198
<TooltipProvider>
204199
<Tooltip delayDuration={100}>
205200
<TooltipTrigger asChild>
206-
{/* Line 217: Added stopPropagation to prevent card click when button is clicked */}
207-
<Link
208-
href={`/profiles/${codev.id}`}
209-
target="_blank"
210-
onClick={(e) => e.stopPropagation()}
211-
>
201+
<Link href={`/profiles/${codev.id}`} target="_blank" onClick={(e) => e.stopPropagation()}>
212202
<Button
213203
variant="outline"
214204
size="icon"
@@ -247,17 +237,10 @@ const CodevCard = ({ codev, color }: Props) => {
247237
/>
248238
) : null}
249239
</div>
250-
<div
251-
className="relative z-20"
252-
onMouseEnter={(e) => e.stopPropagation()}
253-
onMouseLeave={(e) => e.stopPropagation()}
254-
onClick={(e) => e.stopPropagation()}
255-
>
256-
<CodevHireCodevButton codevId={codev.id} />
257-
</div>
240+
<CodevHireCodevButton codevId={codev.id} hovered={hovered} />
258241
</div>
259242
</div>
260243
);
261244
};
262245

263-
export default CodevCard;
246+
export default CodevCard;

‎apps/codebility/app/(marketing)/profiles/page.tsx‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import { Suspense } from "react";
22
import { UsersSkeleton } from "@/components/ui/skeleton/UsersSkeleton";
33
import { getCodevs } from "@/lib/server/codev.service";
44
import { Codev } from "@/types/home/codev";
5-
import {
6-
getPrioritizedAndFilteredCodevs,
7-
prioritizeCodevs,
8-
} from "@/utils/codev-priority"; // Import the utility
5+
import { prioritizeCodevs } from "@/utils/codev-priority";
6+
import { getQualifiedCodevs } from "@/utils/codev-qualification";
97

108
import Section from "../_shared/CodevsSection";
119
import CodevContainer from "./_components/CodevContainer";
@@ -16,22 +14,33 @@ export const dynamic = "force-dynamic";
1614
export const revalidate = 0;
1715

1816
export default async function Profiles() {
17+
// Fetch all passed codevs (includes admins, mentors, codevs)
1918
const [{ data: allCodevs, error }] = await Promise.all([
20-
getCodevs({ filters: { role_id: 10 } }), // show only Codevs with role_id 10 which is Codev
19+
getCodevs({ filters: { application_status: "passed" } }),
2120
]);
2221

2322
if (error) {
2423
throw new Error("Failed to fetch profiles data");
2524
}
2625

26+
// Convert to array safely
2727
const codevsArray: Codev[] = Array.isArray(allCodevs) ? allCodevs : [];
2828

29-
// Use the utility function with filterAdminAndFailed set to true
30-
const sortedCodevs = getPrioritizedAndFilteredCodevs(
31-
codevsArray,
32-
{ activeStatus: ["active"] },
33-
true,
34-
);
29+
// Filter by qualification criteria (100+ points, passed, available)
30+
// This handles ALL filtering logic - no internal_status restrictions
31+
const qualifiedCodevs = getQualifiedCodevs(codevsArray);
32+
33+
// Apply priority sorting only (no additional filtering)
34+
// Prioritize by: Active projects > No projects, Available > Unavailable
35+
const sortedCodevs = prioritizeCodevs(qualifiedCodevs);
36+
37+
// Debug logging in development
38+
if (process.env.NODE_ENV === "development") {
39+
console.log("📊 PROFILES PAGE STATS:");
40+
console.log(` Total codevs fetched: ${codevsArray.length}`);
41+
console.log(` Qualified codevs: ${qualifiedCodevs.length}`);
42+
console.log(` Final displayed: ${sortedCodevs.length}`);
43+
}
3544

3645
return (
3746
<>
@@ -54,4 +63,4 @@ export default async function Profiles() {
5463
<CodevHireCodevModal />
5564
</>
5665
);
57-
}
66+
}

0 commit comments

Comments
 (0)