Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 103x 103x 103x 103x 103x 103x 2x 2x 2x 101x 101x 101x 101x 101x 103x 2x 2x 2x 99x 99x 99x 99x 99x 103x 2x 2x 2x 97x 103x 103x 158x 158x 11x 11x 11x 11x 11x 11x 158x 158x 164x 164x 120x 164x 26x 164x 18x 164x 164x 164x 164x 158x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 158x 20x 20x 20x 20x 158x 1x 1x 1x 1x 158x 158x 158x 158x 158x 158x 158x 158x 158x 632x 632x 632x 632x 90x 542x 158x 384x 632x 632x 90x 542x 632x 632x 632x 632x 632x 632x 632x 632x 474x 474x 474x 474x 474x 632x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 158x 110x 110x 110x 110x 110x 110x 110x 1540x 1540x 1540x 1540x 1540x 1540x 1540x 1540x 24x 1540x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 1870x 1870x 1870x 1870x 1870x 1870x 1870x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 1760x 1760x 1760x 1760x 1760x 1760x 1760x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 110x 158x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 158x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 2x 2x 2x 2x 2x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 14x 14x 14x 158x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 158x 158x 158x 158x 158x 158x 158x 144x 144x 144x 14x 14x 2x 2x 2x 12x 12x 12x 14x 158x 158x 158x 158x 158x | 'use client';
import { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { motion, AnimatePresence } from 'framer-motion';
import {
Code2,
Github,
Briefcase,
DollarSign,
ChevronLeft,
ChevronRight,
Check,
Loader2,
Plus,
} from 'lucide-react';
import { Card, CardContent } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Badge } from '@/components/ui/badge';
import { Switch } from '@/components/ui/switch';
import { Checkbox } from '@/components/ui/checkbox';
import { createClient } from '@/lib/supabase/client';
import { toast } from '@/hooks/use-toast';
const STEPS = [
{ id: 'skills', title: 'Skills', icon: Code2 },
{ id: 'github', title: 'GitHub', icon: Github },
{ id: 'work', title: 'Work', icon: Briefcase },
{ id: 'rates', title: 'Rates', icon: DollarSign },
];
const COMMON_LANGUAGES = [
'JavaScript',
'TypeScript',
'Python',
'Java',
'Go',
'Rust',
'C++',
'C#',
'PHP',
'Ruby',
'Swift',
'Kotlin',
'Dart',
'Scala',
];
const COMMON_FRAMEWORKS = [
'React',
'Next.js',
'Vue.js',
'Angular',
'Node.js',
'Express',
'Django',
'Flask',
'FastAPI',
'Spring Boot',
'Laravel',
'Rails',
'Flutter',
'React Native',
'SwiftUI',
'TensorFlow',
'PyTorch',
];
const COMMON_TOOLS = [
'Git',
'Docker',
'Kubernetes',
'AWS',
'GCP',
'Azure',
'PostgreSQL',
'MongoDB',
'Redis',
'GraphQL',
'REST API',
'CI/CD',
'Linux',
'Terraform',
'Nginx',
'Firebase',
];
const WORK_TYPES = [
{ id: 'full_time', label: 'Full-time Employment' },
{ id: 'contract', label: 'Contract Work' },
{ id: 'freelance', label: 'Freelance Projects' },
{ id: 'consulting', label: 'Consulting' },
{ id: 'open_source', label: 'Open Source Collaboration' },
];
const developerSetupSchema = z.object({
primaryLanguages: z.array(z.string()).min(1, 'Select at least one language'),
frameworks: z.array(z.string()),
tools: z.array(z.string()),
specializations: z.array(z.string()),
githubUsername: z.string().optional(),
yearsExperience: z.number().min(0).max(50),
openToWork: z.boolean(),
workTypes: z.array(z.string()),
preferredRoles: z.array(z.string()),
hourlyRateUsd: z.number().min(0).optional(),
projectMinBudgetInr: z.number().min(0).optional(),
remoteOnly: z.boolean(),
willingToRelocate: z.boolean(),
preferredLocations: z.array(z.string()),
});
type DeveloperSetupForm = z.infer<typeof developerSetupSchema>;
export default function DeveloperSetupPage() {
const [currentStep, setCurrentStep] = useState(0);
const [loading, setLoading] = useState(false);
const [profileId, setProfileId] = useState<string | null>(null);
const [customLanguage, setCustomLanguage] = useState('');
const [customFramework, setCustomFramework] = useState('');
const [customTool, setCustomTool] = useState('');
const router = useRouter();
const form = useForm<DeveloperSetupForm>({
resolver: zodResolver(developerSetupSchema),
defaultValues: {
primaryLanguages: [],
frameworks: [],
tools: [],
specializations: [],
githubUsername: '',
yearsExperience: 0,
openToWork: false,
workTypes: [],
preferredRoles: [],
hourlyRateUsd: undefined,
projectMinBudgetInr: undefined,
remoteOnly: true,
willingToRelocate: false,
preferredLocations: [],
},
});
const { watch, setValue, handleSubmit } = form;
const formValues = watch();
useEffect(() => {
const supabase = createClient();
async function checkProfile() {
const {
data: { user },
} = await supabase.auth.getUser();
if (!user) {
router.push('/login');
return;
}
const { data: profile } = await supabase
.from('profiles')
.select('id')
.eq('user_id', user.id)
.single();
if (!profile) {
router.push('/profile');
return;
}
const { data: existingDeveloper } = await supabase
.from('developer_profiles')
.select('id')
.eq('profile_id', profile.id)
.single();
if (existingDeveloper) {
router.push('/developer');
return;
}
setProfileId(profile.id);
}
checkProfile();
}, [router]);
const toggleItem = (field: keyof DeveloperSetupForm, item: string) => {
const current = formValues[field] as string[];
if (current.includes(item)) {
setValue(
field,
current.filter((i) => i !== item)
);
} else {
setValue(field, [...current, item]);
}
};
const addCustomItem = (
field: keyof DeveloperSetupForm,
value: string,
setter: (v: string) => void
) => {
if (value.trim() && !(formValues[field] as string[]).includes(value.trim())) {
setValue(field, [...(formValues[field] as string[]), value.trim()]);
setter('');
}
};
const canProceed = () => {
switch (currentStep) {
case 0:
return formValues.primaryLanguages.length > 0;
case 1:
return true;
case 2:
return true;
case 3:
return true;
default:
return false;
}
};
const onSubmit = async (data: DeveloperSetupForm) => {
if (!profileId) return;
setLoading(true);
const supabase = createClient();
try {
const { error } = await supabase.from('developer_profiles').insert({
profile_id: profileId,
primary_languages: data.primaryLanguages,
frameworks: data.frameworks,
tools: data.tools,
specializations: data.specializations,
github_username: data.githubUsername || null,
github_connected: false,
years_experience: data.yearsExperience,
open_to_work: data.openToWork,
work_types: data.workTypes,
preferred_roles: data.preferredRoles,
hourly_rate_usd: data.hourlyRateUsd || null,
project_min_budget_inr: data.projectMinBudgetInr ? data.projectMinBudgetInr * 100 : null,
remote_only: data.remoteOnly,
willing_to_relocate: data.willingToRelocate,
preferred_locations: data.preferredLocations,
});
if (error) throw error;
await supabase.from('profiles').update({ profile_type: 'developer' }).eq('id', profileId);
toast({ title: 'Success', description: 'Developer profile created successfully!' });
router.refresh(); // Refresh to update navigation and sidebar state
router.push('/developer');
} catch (error) {
console.error('Error creating developer profile:', error);
toast({
title: 'Error',
description: 'Failed to create developer profile',
variant: 'destructive',
});
} finally {
setLoading(false);
}
};
const nextStep = () => {
if (currentStep < STEPS.length - 1 && canProceed()) {
setCurrentStep(currentStep + 1);
}
};
const prevStep = () => {
if (currentStep > 0) {
setCurrentStep(currentStep - 1);
}
};
return (
<div className="mx-auto max-w-3xl space-y-8">
<div>
<h1 className="text-3xl font-bold">Set Up Your Developer Profile</h1>
<p className="text-muted-foreground">
Showcase your technical skills and connect with opportunities
</p>
</div>
{/* Progress Steps */}
<div className="flex items-center justify-between">
{STEPS.map((step, index) => (
<div key={step.id} className="flex items-center">
<div
className={`flex h-10 w-10 items-center justify-center rounded-full border-2 transition-colors ${
index < currentStep
? 'border-primary bg-primary text-primary-foreground'
: index === currentStep
? 'border-primary text-primary'
: 'border-muted text-muted-foreground'
}`}
>
{index < currentStep ? (
<Check className="h-5 w-5" />
) : (
<step.icon className="h-5 w-5" />
)}
</div>
<span
className={`ml-2 hidden text-sm font-medium sm:block ${
index <= currentStep ? 'text-foreground' : 'text-muted-foreground'
}`}
>
{step.title}
</span>
{index < STEPS.length - 1 && (
<div
className={`mx-2 h-0.5 w-12 sm:mx-4 sm:w-24 ${
index < currentStep ? 'bg-primary' : 'bg-muted'
}`}
/>
)}
</div>
))}
</div>
<Card>
<CardContent className="pt-6">
<AnimatePresence mode="wait">
<motion.div
key={currentStep}
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
exit={{ opacity: 0, x: -20 }}
transition={{ duration: 0.2 }}
>
{currentStep === 0 && (
<div className="space-y-6">
<div>
<h2 className="mb-2 text-xl font-semibold">Programming Languages</h2>
<p className="mb-4 text-sm text-muted-foreground">
Select your primary programming languages
</p>
<div className="mb-4 flex flex-wrap gap-2">
{COMMON_LANGUAGES.map((lang) => (
<Badge
key={lang}
variant={
formValues.primaryLanguages.includes(lang) ? 'default' : 'outline'
}
className="cursor-pointer transition-colors hover:bg-primary/90"
onClick={() => toggleItem('primaryLanguages', lang)}
>
{lang}
{formValues.primaryLanguages.includes(lang) && (
<Check className="ml-1 h-3 w-3" />
)}
</Badge>
))}
</div>
<div className="flex gap-2">
<Input
placeholder="Add custom language..."
value={customLanguage}
onChange={(e) => setCustomLanguage(e.target.value)}
onKeyDown={(e) =>
e.key === 'Enter' &&
(e.preventDefault(),
addCustomItem('primaryLanguages', customLanguage, setCustomLanguage))
}
/>
<Button
variant="outline"
onClick={() =>
addCustomItem('primaryLanguages', customLanguage, setCustomLanguage)
}
>
<Plus className="h-4 w-4" />
</Button>
</div>
</div>
<div>
<h2 className="mb-2 text-xl font-semibold">Frameworks & Libraries</h2>
<div className="mb-4 flex flex-wrap gap-2">
{COMMON_FRAMEWORKS.map((fw) => (
<Badge
key={fw}
variant={formValues.frameworks.includes(fw) ? 'default' : 'outline'}
className="cursor-pointer transition-colors hover:bg-primary/90"
onClick={() => toggleItem('frameworks', fw)}
>
{fw}
</Badge>
))}
</div>
<div className="flex gap-2">
<Input
placeholder="Add custom framework..."
value={customFramework}
onChange={(e) => setCustomFramework(e.target.value)}
onKeyDown={(e) =>
e.key === 'Enter' &&
(e.preventDefault(),
addCustomItem('frameworks', customFramework, setCustomFramework))
}
/>
<Button
variant="outline"
onClick={() =>
addCustomItem('frameworks', customFramework, setCustomFramework)
}
>
<Plus className="h-4 w-4" />
</Button>
</div>
</div>
<div>
<h2 className="mb-2 text-xl font-semibold">Tools & Platforms</h2>
<div className="mb-4 flex flex-wrap gap-2">
{COMMON_TOOLS.map((tool) => (
<Badge
key={tool}
variant={formValues.tools.includes(tool) ? 'default' : 'outline'}
className="cursor-pointer transition-colors hover:bg-primary/90"
onClick={() => toggleItem('tools', tool)}
>
{tool}
</Badge>
))}
</div>
<div className="flex gap-2">
<Input
placeholder="Add custom tool..."
value={customTool}
onChange={(e) => setCustomTool(e.target.value)}
onKeyDown={(e) =>
e.key === 'Enter' &&
(e.preventDefault(), addCustomItem('tools', customTool, setCustomTool))
}
/>
<Button
variant="outline"
onClick={() => addCustomItem('tools', customTool, setCustomTool)}
>
<Plus className="h-4 w-4" />
</Button>
</div>
</div>
</div>
)}
{currentStep === 1 && (
<div className="space-y-6">
<div>
<h2 className="mb-4 text-xl font-semibold">GitHub Integration</h2>
<p className="mb-6 text-sm text-muted-foreground">
Connect your GitHub to import repositories and showcase your contributions
</p>
<div className="space-y-4">
<div>
<Label htmlFor="githubUsername">GitHub Username</Label>
<div className="mt-1 flex items-center gap-2">
<span className="text-muted-foreground">github.com/</span>
<Input
id="githubUsername"
placeholder="your-username"
value={formValues.githubUsername}
onChange={(e) => setValue('githubUsername', e.target.value)}
/>
</div>
<p className="mt-1 text-xs text-muted-foreground">
You can connect your GitHub account later from the dashboard
</p>
</div>
<div>
<Label htmlFor="yearsExperience">Years of Experience</Label>
<Input
id="yearsExperience"
type="number"
min={0}
max={50}
value={formValues.yearsExperience}
onChange={(e) =>
setValue('yearsExperience', parseInt(e.target.value) || 0)
}
className="mt-1"
/>
</div>
</div>
</div>
</div>
)}
{currentStep === 2 && (
<div className="space-y-6">
<div>
<h2 className="mb-4 text-xl font-semibold">Work Preferences</h2>
<div className="space-y-4">
<div className="flex items-center justify-between rounded-lg border p-4">
<div>
<p className="font-medium">Open to Work</p>
<p className="text-sm text-muted-foreground">
Show that you are available for opportunities
</p>
</div>
<Switch
checked={formValues.openToWork}
onCheckedChange={(checked) => setValue('openToWork', checked)}
/>
</div>
{formValues.openToWork && (
<>
<div>
<Label>Work Types</Label>
<div className="mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2">
{WORK_TYPES.map((type) => (
<div
key={type.id}
className={`flex cursor-pointer items-center gap-2 rounded-lg border p-3 transition-colors ${
formValues.workTypes.includes(type.id)
? 'border-primary bg-primary/5'
: 'hover:bg-muted'
}`}
onClick={() => toggleItem('workTypes', type.id)}
>
<Checkbox checked={formValues.workTypes.includes(type.id)} />
<span className="text-sm">{type.label}</span>
</div>
))}
</div>
</div>
<div className="flex items-center justify-between rounded-lg border p-4">
<div>
<p className="font-medium">Remote Only</p>
<p className="text-sm text-muted-foreground">
Only interested in remote work
</p>
</div>
<Switch
checked={formValues.remoteOnly}
onCheckedChange={(checked) => setValue('remoteOnly', checked)}
/>
</div>
{!formValues.remoteOnly && (
<div className="flex items-center justify-between rounded-lg border p-4">
<div>
<p className="font-medium">Willing to Relocate</p>
<p className="text-sm text-muted-foreground">
Open to relocating for the right opportunity
</p>
</div>
<Switch
checked={formValues.willingToRelocate}
onCheckedChange={(checked) =>
setValue('willingToRelocate', checked)
}
/>
</div>
)}
</>
)}
</div>
</div>
</div>
)}
{currentStep === 3 && (
<div className="space-y-6">
<div>
<h2 className="mb-4 text-xl font-semibold">Rates (Optional)</h2>
<p className="mb-6 text-sm text-muted-foreground">
Set your rates to help potential clients understand your pricing
</p>
<div className="space-y-6">
<div>
<Label htmlFor="hourlyRate">Hourly Rate (USD)</Label>
<div className="relative mt-1">
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground">
$
</span>
<Input
id="hourlyRate"
type="number"
min={0}
placeholder="e.g., 50"
value={formValues.hourlyRateUsd || ''}
onChange={(e) =>
setValue('hourlyRateUsd', parseInt(e.target.value) || undefined)
}
className="pl-8"
/>
<span className="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground">
/hour
</span>
</div>
</div>
<div>
<Label htmlFor="projectBudget">Minimum Project Budget (INR)</Label>
<div className="relative mt-1">
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground">
₹
</span>
<Input
id="projectBudget"
type="number"
min={0}
placeholder="e.g., 50000"
value={formValues.projectMinBudgetInr || ''}
onChange={(e) =>
setValue('projectMinBudgetInr', parseInt(e.target.value) || undefined)
}
className="pl-8"
/>
</div>
<p className="mt-1 text-xs text-muted-foreground">
Leave empty if you are open to projects of any size
</p>
</div>
</div>
</div>
</div>
)}
</motion.div>
</AnimatePresence>
<div className="mt-8 flex justify-between border-t pt-6">
<Button variant="outline" onClick={prevStep} disabled={currentStep === 0}>
<ChevronLeft className="mr-2 h-4 w-4" />
Back
</Button>
{currentStep < STEPS.length - 1 ? (
<Button onClick={nextStep} disabled={!canProceed()}>
Next
<ChevronRight className="ml-2 h-4 w-4" />
</Button>
) : (
<Button onClick={handleSubmit(onSubmit)} disabled={loading}>
{loading ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Creating...
</>
) : (
<>
<Check className="mr-2 h-4 w-4" />
Create Developer Profile
</>
)}
</Button>
)}
</div>
</CardContent>
</Card>
</div>
);
}
|