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

100% Statements 4/4
100% Branches 8/8
100% Functions 4/4
100% Lines 4/4

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                          141x                           2x                                             4x           645x                      
import { CollapsibleCard } from "../../ui/collapsible";
import type { ProFormSectionProps } from "./types";
import { RUSH_ORDER_PREMIUMS } from "./constants";
import { Zap } from "lucide-react";
 
/**
 * RushOrdersSection component displays rush order configuration.
 * Includes a checkbox to enable rush orders and a conditional premium select.
 */
export function RushOrdersSection({
	pro,
	onUpdateField,
}: ProFormSectionProps) {
	return (
		<CollapsibleCard
			title="Rush Orders"
			description="Can this pro accept rush orders?"
			icon={<Zap className="h-5 w-5" />}
			defaultOpen={pro.acceptsRushOrders}
		>
			<div className="space-y-4 pt-4">
				<div className="flex items-center space-x-3">
					<input
						type="checkbox"
						id="admin-accepts-rush-orders"
						checked={pro.acceptsRushOrders || false}
						onChange={(e) =>
							onUpdateField("acceptsRushOrders", e.target.checked)
						}
						className="h-4 w-4 text-primary-600 focus:ring-primary-500 border-border-default rounded"
					/>
					<label
						htmlFor="admin-accepts-rush-orders"
						className="text-sm font-medium text-foreground-default"
					>
						Accepts rush orders with expedited delivery
					</label>
				</div>
				{pro.acceptsRushOrders && (
					<div className="space-y-2 ml-7">
						<label
							htmlFor="admin-rush-order-premium"
							className="text-sm font-medium text-foreground-default"
						>
							Rush Order Premium
						</label>
						<select
							id="admin-rush-order-premium"
							value={pro.rushOrderPremium || ""}
							onChange={(e) =>
								onUpdateField("rushOrderPremium", e.target.value || null)
							}
							className="flex h-10 w-full rounded-md border border-border-default bg-background-elevated px-3 py-2 text-sm text-foreground-default focus:outline-none focus:ring-2 focus:ring-primary-500/40 focus:border-primary-500"
						>
							<option value="">Select premium</option>
							{RUSH_ORDER_PREMIUMS.map((option) => (
								<option key={option.value} value={option.value}>
									{option.label}
								</option>
							))}
						</select>
					</div>
				)}
			</div>
		</CollapsibleCard>
	);
}