'use client'; import { Label } from '@/components/ui/label'; import { BranchAutocomplete } from '@/components/ui/branch-autocomplete'; import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; interface BranchSelectorProps { useCurrentBranch: boolean; onUseCurrentBranchChange: (useCurrent: boolean) => void; branchName: string; onBranchNameChange: (branchName: string) => void; branchSuggestions: string[]; branchCardCounts?: Record; // Map of branch name to unarchived card count currentBranch?: string; disabled?: boolean; testIdPrefix?: string; } export function BranchSelector({ useCurrentBranch, onUseCurrentBranchChange, branchName, onBranchNameChange, branchSuggestions, branchCardCounts, currentBranch, disabled = false, testIdPrefix = 'branch', }: BranchSelectorProps) { // Validate: if "other branch" is selected, branch name is required const isBranchRequired = !useCurrentBranch; const hasError = isBranchRequired && !branchName.trim(); return (
onUseCurrentBranchChange(value === 'current')} disabled={disabled} data-testid={`${testIdPrefix}-radio-group`} aria-labelledby={`${testIdPrefix}-label`} >
{!useCurrentBranch && (
{hasError && (

Branch name is required when "Other branch" is selected.

)}
)} {disabled ? (

Branch cannot be changed after work has started.

) : (

{useCurrentBranch ? 'Work will be done in the currently selected branch. A worktree will be created if needed.' : 'Work will be done in this branch. A worktree will be created if needed.'}

)}
); }