import React from "react"; import { Link } from "react-router"; interface PricingFormProps { pricePerHour: number | string; pricePerDay: number | string; pricePerWeek: number | string; pricePerMonth: number | string; replacementCost: number | string; selectedPricingUnit: string; showAdvancedPricing: boolean; enabledTiers: { hour: boolean; day: boolean; week: boolean; month: boolean; }; onChange: ( e: React.ChangeEvent ) => void; onPricingUnitChange: (e: React.ChangeEvent) => void; onToggleAdvancedPricing: () => void; onTierToggle: (tier: string) => void; } const PricingForm: React.FC = ({ pricePerHour, pricePerDay, pricePerWeek, pricePerMonth, replacementCost, selectedPricingUnit, showAdvancedPricing, enabledTiers, onChange, onPricingUnitChange, onToggleAdvancedPricing, onTierToggle, }) => { // Map pricing unit to field name and label const pricingUnitMap: Record< string, { field: string; label: string; value: number | string } > = { hour: { field: "pricePerHour", label: "Hour", value: pricePerHour }, day: { field: "pricePerDay", label: "Day", value: pricePerDay }, week: { field: "pricePerWeek", label: "Week", value: pricePerWeek }, month: { field: "pricePerMonth", label: "Month", value: pricePerMonth }, }; // When advanced pricing is on, show ALL 4 options // When advanced pricing is off, show only the 3 non-selected options const advancedPricingOptions = showAdvancedPricing ? Object.entries(pricingUnitMap) : Object.entries(pricingUnitMap).filter( ([key]) => key !== selectedPricingUnit ); const selectedUnit = pricingUnitMap[selectedPricingUnit]; return (
Pricing

{showAdvancedPricing ? ( "Set multiple pricing tiers for flexible rental rates." ) : ( <> Village Share charges a 10% Community Upkeep Fee to help keep us running.{" "} Calculate what you can earn here )}

{/* Pricing Unit Dropdown - Only show when advanced pricing is OFF */} {!showAdvancedPricing && ( <>
{/* Primary Price Input */}
$
)} {/* Advanced Pricing Toggle */}
{/* Advanced Pricing Section */} {showAdvancedPricing && (

Set multiple pricing tiers. Check the boxes for the tiers you want to use.

{advancedPricingOptions.map(([key, { field, label, value }]) => (
onTierToggle(key)} />
$
))}
)}
{/* Replacement Cost */}
The cost to replace the item if lost
$
); }; export default PricingForm;