/** * Settings Layout * * Provides a sidebar navigation for settings pages with grouped sections. * Used as a wrapper for all /settings/* routes. */ import React from 'react'; import { Outlet, Link, useLocation, useNavigate, useOutletContext } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { ArrowLeft, Building2, Palette, Layers, Globe, Key, Lock, Mail, Phone, CreditCard, AlertTriangle, Calendar, } from 'lucide-react'; import { SettingsSidebarSection, SettingsSidebarItem, } from '../components/navigation/SidebarComponents'; import UnfinishedBadge from '../components/ui/UnfinishedBadge'; import { Business, User, PlanPermissions } from '../types'; import { usePlanFeatures, FeatureKey } from '../hooks/usePlanFeatures'; interface ParentContext { user: User; business: Business; updateBusiness: (updates: Partial) => void; } // Map settings pages to their required plan features const SETTINGS_PAGE_FEATURES: Record = { '/settings/branding': 'white_label', '/settings/custom-domains': 'custom_domain', '/settings/api': 'api_access', '/settings/authentication': 'custom_oauth', '/settings/sms-calling': 'sms_reminders', }; const SettingsLayout: React.FC = () => { const { t } = useTranslation(); const location = useLocation(); const navigate = useNavigate(); const { canUse } = usePlanFeatures(); // Get context from parent route (BusinessLayout) const parentContext = useOutletContext(); // Check if a feature is locked (returns true if locked) const isLocked = (feature: FeatureKey | undefined): boolean => { if (!feature) return false; return !canUse(feature); }; // Get the current page's feature requirement (if any) const currentPageFeature = SETTINGS_PAGE_FEATURES[location.pathname]; const currentPageLocked = isLocked(currentPageFeature); return (
{/* Settings Sidebar */} {/* Content Area */}
); }; export default SettingsLayout;