-
Notifications
You must be signed in to change notification settings - Fork 182
feat: replace real API calls with mock freelancer data in Find Talent… #848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRefactors the services search hook to use in-memory mockFreelancers instead of network requests. Implements client-side filtering by keyword, category, and price range, plus pagination. Preserves URL parameter parsing and updating. On error, clears services and pagination, and consistently manages loading state. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as UI Component
participant H as use-services-api Hook
participant U as URL Utils (parse/update)
participant M as Mock Data (mockFreelancers)
C->>H: searchServices(params)
H->>U: parseURLParams()<br/>updateURL(params)
H->>M: filter(keyword, category, price)
Note over H,M: Client-side filtering replaces network fetch
H->>H: paginate(page, limit)
alt success
H-->>C: { services: pageItems, pagination }
else error
H-->>C: { services: [], pagination: undefined, error }
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/hooks/api-connections/use-services-api.ts
(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/hooks/api-connections/use-services-api.ts (1)
src/types/service.types.ts (1)
FreelancerDisplay
(66-83)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build (18.x)
- GitHub Check: build (20.x)
// Mock data for freelancers - simulating database response | ||
const mockFreelancers: FreelancerDisplay[] = [ | ||
{ | ||
id: "1", | ||
name: "Sarah Johnson", | ||
title: "Senior React Developer", | ||
avatar: "/avatars/sarah.jpg", | ||
rating: 4.9, | ||
reviewCount: 127, | ||
location: "San Francisco, USA", | ||
hourlyRate: 75, | ||
description: "Experienced React developer with 5+ years building scalable web applications. Specialized in modern React patterns and state management.", | ||
skills: ["React", "TypeScript", "Node.js", "GraphQL", "AWS"], | ||
projectsCompleted: 89, | ||
responseTime: "Under 1 hour", | ||
category: "development" | ||
}, | ||
{ | ||
id: "2", | ||
name: "Michael Chen", | ||
title: "UI/UX Designer", | ||
avatar: "/avatars/michael.jpg", | ||
rating: 4.8, | ||
reviewCount: 95, | ||
location: "New York, USA", | ||
hourlyRate: 60, | ||
description: "Creative UI/UX designer focused on creating intuitive and beautiful user experiences. Expert in design systems and prototyping.", | ||
skills: ["Figma", "Adobe XD", "Sketch", "Prototyping", "User Research"], | ||
projectsCompleted: 67, | ||
responseTime: "Under 1 hour", | ||
category: "design" | ||
}, | ||
{ | ||
id: "3", | ||
name: "Elena Rodriguez", | ||
title: "Full Stack Developer", | ||
avatar: "/avatars/elena.jpg", | ||
rating: 4.7, | ||
reviewCount: 143, | ||
location: "Barcelona, Spain", | ||
hourlyRate: 55, | ||
description: "Passionate full-stack developer with expertise in both frontend and backend technologies. Loves clean code and modern architecture.", | ||
skills: ["JavaScript", "Python", "Django", "React", "PostgreSQL"], | ||
projectsCompleted: 112, | ||
responseTime: "1-2 hours", | ||
category: "development" | ||
}, | ||
{ | ||
id: "4", | ||
name: "David Kim", | ||
title: "Digital Marketing Specialist", | ||
avatar: "/avatars/david.jpg", | ||
rating: 4.6, | ||
reviewCount: 78, | ||
location: "Toronto, Canada", | ||
hourlyRate: 45, | ||
description: "Results-driven digital marketing expert with proven track record in SEO, SEM, and social media campaigns.", | ||
skills: ["SEO", "Google Ads", "Facebook Ads", "Analytics", "Content Marketing"], | ||
projectsCompleted: 54, | ||
responseTime: "1-2 hours", | ||
category: "marketing" | ||
}, | ||
{ | ||
id: "5", | ||
name: "Alexandra Smith", | ||
title: "Blockchain Developer", | ||
avatar: "/avatars/alexandra.jpg", | ||
rating: 4.9, | ||
reviewCount: 91, | ||
location: "London, UK", | ||
hourlyRate: 85, | ||
description: "Blockchain and smart contract developer with deep knowledge of Ethereum, Solidity, and DeFi protocols.", | ||
skills: ["Solidity", "Web3.js", "Ethereum", "DeFi", "Smart Contracts"], | ||
projectsCompleted: 43, | ||
responseTime: "Under 1 hour", | ||
category: "blockchain" | ||
}, | ||
{ | ||
id: "6", | ||
name: "James Wilson", | ||
title: "Data Scientist", | ||
avatar: "/avatars/james.jpg", | ||
rating: 4.8, | ||
reviewCount: 116, | ||
location: "Berlin, Germany", | ||
hourlyRate: 70, | ||
description: "Data scientist specializing in machine learning and AI. Expert in Python, R, and advanced analytics.", | ||
skills: ["Python", "Machine Learning", "TensorFlow", "Pandas", "Statistics"], | ||
projectsCompleted: 76, | ||
responseTime: "Under 1 hour", | ||
category: "data" | ||
}, | ||
{ | ||
id: "7", | ||
name: "Maria Garcia", | ||
title: "Business Consultant", | ||
avatar: "/avatars/maria.jpg", | ||
rating: 4.7, | ||
reviewCount: 89, | ||
location: "Miami, USA", | ||
hourlyRate: 65, | ||
description: "Strategic business consultant helping companies optimize operations and drive growth through data-driven insights.", | ||
skills: ["Business Strategy", "Financial Analysis", "Process Optimization", "Consulting", "Project Management"], | ||
projectsCompleted: 62, | ||
responseTime: "1-2 hours", | ||
category: "business" | ||
}, | ||
{ | ||
id: "8", | ||
name: "Ahmed Hassan", | ||
title: "Cybersecurity Expert", | ||
avatar: "/avatars/ahmed.jpg", | ||
rating: 4.9, | ||
reviewCount: 134, | ||
location: "Dubai, UAE", | ||
hourlyRate: 90, | ||
description: "Cybersecurity specialist with extensive experience in penetration testing, security audits, and vulnerability assessments.", | ||
skills: ["Penetration Testing", "Network Security", "Risk Assessment", "Compliance", "Incident Response"], | ||
projectsCompleted: 98, | ||
responseTime: "Under 1 hour", | ||
category: "security" | ||
}, | ||
{ | ||
id: "9", | ||
name: "Lisa Thompson", | ||
title: "Mobile App Developer", | ||
avatar: "/avatars/lisa.jpg", | ||
rating: 4.6, | ||
reviewCount: 102, | ||
location: "Tokyo, Japan", | ||
hourlyRate: 65, | ||
description: "Mobile app developer specializing in React Native and Flutter. Creates beautiful, performant cross-platform applications.", | ||
skills: ["React Native", "Flutter", "iOS", "Android", "Firebase"], | ||
projectsCompleted: 71, | ||
responseTime: "1-2 hours", | ||
category: "development" | ||
}, | ||
{ | ||
id: "10", | ||
name: "Roberto Silva", | ||
title: "DevOps Engineer", | ||
avatar: "/avatars/roberto.jpg", | ||
rating: 4.8, | ||
reviewCount: 87, | ||
location: "Buenos Aires, Argentina", | ||
hourlyRate: 70, | ||
description: "DevOps engineer focused on automation, CI/CD, and cloud infrastructure. Expert in AWS, Docker, and Kubernetes.", | ||
skills: ["AWS", "Docker", "Kubernetes", "CI/CD", "Terraform"], | ||
projectsCompleted: 58, | ||
responseTime: "Under 1 hour", | ||
category: "development" | ||
} | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoist mockFreelancers
to module scope to satisfy hook dependencies
searchServices
closes over mockFreelancers
, but the array lives in component scope and is omitted from the dependency list. react-hooks/exhaustive-deps
will flag this (and our lint gate treats it as an error), blocking the build. Hoisting the mock data to module scope keeps the dependency list stable without recreating the array every render.
- const mockFreelancers: FreelancerDisplay[] = [
+const mockFreelancers: FreelancerDisplay[] = [
{
id: "1",
name: "Sarah Johnson",
title: "Senior React Developer",
@@
}
];
+export function useServicesApi(): UseServicesApiReturn {
+ …
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/hooks/api-connections/use-services-api.ts around lines 202 to 354, the
mockFreelancers array is declared inside the hook scope and is closed over by
searchServices, causing a lint error from react-hooks/exhaustive-deps; move the
mockFreelancers declaration to module scope (above the hook export) so it is
stable across renders, update any imports/refs accordingly, and remove it from
the hook dependency list (or leave dependencies unchanged) so the hook
dependencies no longer include a re-created array.
✅ Frontend CI/CD Pipeline Completed Successfully!
Ready for review and deployment! 🚀 |
… section
📝 Pull Request Title
🛠️ Issue
📚 Description
✅ Changes applied
🔍 Evidence/Media (screenshots/videos)
Summary by CodeRabbit
New Features
Bug Fixes