// src/components/store/CategorySection.jsx import { useState } from 'react'; import { ChevronDown } from 'lucide-react'; import ProductCard from './ProductCard'; import { parsePeriod } from './StoreHelpers'; export default function CategorySection({ categoryName, products, getCategoryIcon }) { const availablePeriods = new Set(); products.forEach(p => { if (p.pricing?.type === 'recurrent' && p.pricing.recurrent) { Object.keys(p.pricing.recurrent).forEach(period => { const periodData = p.pricing.recurrent[period]; if (periodData.enabled == 1 || periodData.enabled === true) availablePeriods.add(period); }); } }); const sortedPeriods = Array.from(availablePeriods).sort((a, b) => parsePeriod(a).weight - parsePeriod(b).weight); const defaultPeriod = sortedPeriods.includes('1M') ? '1M' : sortedPeriods[0]; const [sectionPeriod, setSectionPeriod] = useState(defaultPeriod); return (
{getCategoryIcon(categoryName)}

{categoryName}

{products.length} instance{products.length > 1 ? 's' : ''} disponible{products.length > 1 ? 's' : ''}
{sortedPeriods.length > 0 && (
Facturation :
)}
{products.map((product) => ( ))}
); }