role-selection.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use client';
  2. import type { PBLAgent, PBLProjectInfo } from '@/lib/pbl/types';
  3. import { useI18n } from '@/lib/hooks/use-i18n';
  4. import { PBLGuideInline } from './guide';
  5. interface PBLRoleSelectionProps {
  6. readonly projectInfo: PBLProjectInfo;
  7. readonly agents: PBLAgent[];
  8. readonly onSelectRole: (agentName: string) => void;
  9. }
  10. export function PBLRoleSelection({ projectInfo, agents, onSelectRole }: PBLRoleSelectionProps) {
  11. const { t } = useI18n();
  12. // Only show non-system development roles
  13. const selectableAgents = agents.filter(
  14. (a) => !a.is_system_agent && a.role_division === 'development',
  15. );
  16. return (
  17. <div className="flex flex-col items-center h-full overflow-y-auto p-8 bg-gradient-to-b from-background to-muted/30">
  18. <div className="max-w-2xl w-full space-y-8 my-auto">
  19. {/* Project Info */}
  20. <div className="text-center space-y-3">
  21. <h1 className="text-3xl font-bold tracking-tight">{projectInfo.title}</h1>
  22. <p className="text-muted-foreground text-lg">{projectInfo.description}</p>
  23. </div>
  24. {/* Role Selection */}
  25. <div className="space-y-4">
  26. <h2 className="text-xl font-semibold text-center">{t('pbl.roleSelection.title')}</h2>
  27. <p className="text-sm text-muted-foreground text-center">
  28. {t('pbl.roleSelection.description')}
  29. </p>
  30. <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
  31. {selectableAgents.map((agent) => (
  32. <button
  33. key={agent.name}
  34. onClick={() => onSelectRole(agent.name)}
  35. className="group relative flex flex-col items-start gap-2 rounded-xl border-2 border-muted bg-card p-5 text-left transition-all hover:border-primary hover:shadow-md"
  36. >
  37. <div className="flex items-center gap-2">
  38. <div className="h-8 w-8 rounded-full bg-primary/10 flex items-center justify-center text-primary font-bold text-sm">
  39. {agent.name.charAt(0).toUpperCase()}
  40. </div>
  41. <h3 className="font-semibold text-base">{agent.name}</h3>
  42. </div>
  43. {agent.actor_role && (
  44. <p className="text-sm text-muted-foreground line-clamp-2">{agent.actor_role}</p>
  45. )}
  46. </button>
  47. ))}
  48. </div>
  49. </div>
  50. {/* How it works guide */}
  51. <PBLGuideInline />
  52. </div>
  53. </div>
  54. );
  55. }