function Sidebar({ active = 'bank', onSelect, planId, branchLimit, branchUser }) {
// Use sales features context
const { features, isFeatureEnabled, getFeatureLimit } = window.useSalesFeatures ? window.useSalesFeatures() : { features: {}, isFeatureEnabled: () => true, getFeatureLimit: () => 999 };
const Item = ({ id, label, icon = '📋', locked = false, activeId, onClick, onLockedClick }) => (
{
e.preventDefault();
if (locked) {
if (onLockedClick) onLockedClick();
return;
}
onClick?.(id);
try { location.hash = '#' + id; } catch {}
}}
>
{icon}
{label}
{locked ? 🔒 : null}
);
// Determine if this is a branch user early so feature checks can use it
const isBranch = !!branchUser;
// Feature access checks with better fallback logic for Gold plan
const isBankEnabled = isFeatureEnabled('bank_accounts_enabled') || (planId === 'sales-gold' || planId === 'sales-premium' || planId === 'sales-basic');
// Allow branch users to access suppliers/dealers even if the feature flag is not enabled
const isSupplierEnabled = isFeatureEnabled('suppliers_enabled') || isBranch || (planId === 'sales-basic' || planId === 'sales-gold' || planId === 'sales-premium');
const isGstEnabled = isFeatureEnabled('gst_calculator_enabled') || (planId === 'sales-gold' || planId === 'sales-premium');
const isPaymentHistoryEnabled = isFeatureEnabled('payment_history_enabled') || (planId === 'sales-gold' || planId === 'sales-premium');
const isSupplyHistoryEnabled = isFeatureEnabled('supply_history_enabled') || (planId === 'sales-premium');
const isBranchEnabled = isFeatureEnabled('branch_management_enabled') || (planId === 'sales-basic' || planId === 'sales-gold' || planId === 'sales-premium');
// Legacy fallback for existing planId checks
const canUseBranch = isBranchEnabled || planId === 'sales-gold' || planId === 'sales-premium';
return (
);
}
// Register globally for the in-browser JSX loader
window.Sidebar = Sidebar;