// ================================================================================== // PROPERTY SELECTOR COMPONENT // Displays and allows selection of user properties // ================================================================================== const PropertySelector = ({ userProperties, selectedProperty, onPropertyChange, onSettingsClick, canManageProperties, variant }) => { const showSettings = canManageProperties && onSettingsClick; const headerClass = showSettings ? "flex items-center justify-between mb-2" : "text-center mb-2"; const isSidebar = variant === 'sidebar'; const theme = (typeof window !== 'undefined' && window.OTOSidebarTheme) ? window.OTOSidebarTheme : {}; const cardClass = isSidebar ? (theme.propertyCard || 'bg-black/10 border border-black/20 rounded-xl p-4') : 'bg-primary-dark rounded-lg p-4 border border-primary/30'; const labelClass = isSidebar ? (theme.propertyLabel || 'text-white/70 text-[10px] font-semibold uppercase tracking-wider') : 'text-white/60 text-[10px] font-semibold uppercase tracking-wider'; const borderClass = isSidebar ? (theme.propertyBorder || 'border-black/20') : 'border-primary/30'; const buttonHoverClass = isSidebar ? (theme.propertyButtonHover || 'hover:bg-black/15') : 'hover:bg-primary/50'; const dashedBorderClass = isSidebar ? (theme.propertyDashedBorder || 'border-2 border-dashed border-black/20 rounded-lg') : 'border-2 border-dashed border-primary/30 rounded-lg'; const selectClass = isSidebar ? (theme.propertySelect || 'w-full bg-black/15 border border-black/25 text-white rounded-lg px-3 py-2.5 pr-8 text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-black/20 cursor-pointer appearance-none transition-all hover:border-black/40') : 'w-full bg-primary border border-primary/50 text-white rounded-lg px-3 py-2.5 pr-8 text-sm font-semibold focus:outline-none focus:border-white/30 focus:ring-1 focus:ring-white/20 cursor-pointer appearance-none transition-all hover:border-primary/70'; // Case 1: No properties assigned if (!userProperties || userProperties.length === 0) { return (
Selected Property
{showSettings && ( )}
No property access
); } // Case 2: Single property - compact static display if (userProperties.length === 1) { const property = userProperties[0]; return (
Selected Property
{showSettings && ( )}
{property.property_code}
{property.name}
{property.address &&
{property.address}
}
{property.city}, {property.state} {property.zip || ''}
); } // Case 3: Multiple properties - compact dropdown const sortedProperties = [...userProperties].sort((a, b) => { if (a.property_code === 'OTO') return -1; if (b.property_code === 'OTO') return 1; return a.property_code.localeCompare(b.property_code); }); return (
Selected Property
{showSettings && ( )}
{selectedProperty && (
{selectedProperty.name}
{selectedProperty.address &&
{selectedProperty.address}
}
{selectedProperty.city}, {selectedProperty.state} {selectedProperty.zip || ''}
)}
); }; if (typeof window !== 'undefined') window.PropertySelector = PropertySelector;