All files / src/components/admin/pro-form-sections BusinessDetailsSection.tsx

100% Statements 8/8
92.85% Branches 26/28
100% Functions 8/8
100% Lines 8/8

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                                      177x                                           1x                                             4x           280x                                       7x                                       4x           885x                                     1x                        
import { CollapsibleCard } from "../../ui/collapsible";
import { Input } from "../../ui/input";
import { MultiSelect } from "../../ui/multi-select";
import { TagInput } from "../../ui/tag-input";
import type { ProFormSectionProps } from "./types";
import { LANGUAGES, TEAM_SIZES, TIMELINE_SUGGESTIONS } from "./constants";
import { Package } from "lucide-react";
import { Select } from "../../ui/select";
 
/**
 * BusinessDetailsSection component displays additional business information fields.
 * Includes timeline capabilities, pricing tier, years in business, team size, and languages spoken.
 */
export function BusinessDetailsSection({
	pro,
	onUpdateField,
	customerSegments = [],
	isLoadingTaxonomy = false,
}: ProFormSectionProps) {
	return (
		<CollapsibleCard
			title="Business Details"
			description="Additional information about the business"
			icon={<Package className="h-5 w-5" />}
			defaultOpen={!!pro.customerSegmentId || !!pro.yearsInBusiness}
		>
			<div className="space-y-4 pt-4">
				<div className="space-y-2">
					<label
						htmlFor="admin-timeline-capabilities"
						className="block text-xs font-semibold uppercase tracking-wider text-foreground-muted"
					>
						Timeline Capabilities
					</label>
					<p className="text-xs text-foreground-muted">
						Typical project timelines. Type custom values or click suggestions.
					</p>
					<TagInput
						id="admin-timeline-capabilities"
						values={pro.timelineCapabilities || []}
						onChange={(values) =>
							onUpdateField(
								"timelineCapabilities",
								values.length > 0 ? values : null,
							)
						}
						suggestions={[...TIMELINE_SUGGESTIONS]}
						placeholder="e.g., 2-3 weeks for modular kitchen..."
					/>
				</div>
				<div className="space-y-2">
					<label
						htmlFor="admin-customer-segment"
						className="block text-xs font-semibold uppercase tracking-wider text-foreground-muted"
					>
						Pricing Tier
					</label>
					{isLoadingTaxonomy ? (
						<div className="animate-pulse h-10 bg-background-subtle rounded" />
					) : (
						<Select
							id="admin-customer-segment"
							value={pro.customerSegmentId || ""}
							onChange={(e) =>
								onUpdateField("customerSegmentId", e.target.value || null)
							}
							className="w-full"
						>
							<option value="">Select pricing tier</option>
							{customerSegments.map((seg) => (
								<option key={seg.id} value={seg.id}>
									{seg.name} {seg.priceIndicator && `(${seg.priceIndicator})`}
								</option>
							))}
						</Select>
					)}
				</div>
				<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
					<div className="space-y-2">
						<label
							htmlFor="admin-years-in-business"
							className="block text-xs font-semibold uppercase tracking-wider text-foreground-muted"
						>
							Years in Business
						</label>
						<Input
							id="admin-years-in-business"
							type="number"
							value={pro.yearsInBusiness?.toString() || ""}
							onChange={(e) =>
								onUpdateField(
									"yearsInBusiness",
									e.target.value ? parseInt(e.target.value, 10) : null,
								)
							}
							placeholder="e.g., 5"
							min="0"
						/>
					</div>
					<div className="space-y-2">
						<label
							htmlFor="admin-team-size"
							className="block text-xs font-semibold uppercase tracking-wider text-foreground-muted"
						>
							Team Size
						</label>
						<Select
							id="admin-team-size"
							value={pro.teamSize || ""}
							onChange={(e) =>
								onUpdateField("teamSize", e.target.value || null)
							}
							className="w-full"
						>
							<option value="">Select team size</option>
							{TEAM_SIZES.map((size) => (
								<option key={size.value} value={size.value}>
									{size.label}
								</option>
							))}
						</Select>
					</div>
				</div>
				<div className="space-y-2">
					<label
						htmlFor="admin-languages-spoken"
						className="block text-xs font-semibold uppercase tracking-wider text-foreground-muted"
					>
						Languages Spoken
					</label>
					<MultiSelect
						id="admin-languages-spoken"
						options={[...LANGUAGES]}
						selected={pro.languagesSpoken || []}
						onChange={(values) =>
							onUpdateField(
								"languagesSpoken",
								values.length > 0 ? values : null,
							)
						}
						placeholder="Select languages"
					/>
				</div>
			</div>
		</CollapsibleCard>
	);
}