// src/pages/app/Store.jsx import { useState, useEffect } from 'react'; import { Server, Database, Cloud, Globe, Loader, AlertCircle } from 'lucide-react'; import { getProductList } from '../../services/billing_api'; import CategorySection from '../../components/store/CategorySection'; export default function Store() { const [groupedProducts, setGroupedProducts] = useState({}); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); const CATEGORY_ORDER = ["Web Hosting", "VPS", "Database", "Cloud"]; const CATEGORY_MAP = { 1: "Web Hosting", 4: "VPS", 3: "Database", 2: "Cloud" }; useEffect(() => { const fetchCatalog = async () => { try { const data = await getProductList(); const products = data.list || []; const grid = products.reduce((acc, product) => { const catId = product.product_category_id; const catName = CATEGORY_MAP[catId] || 'Autres Services'; if (!acc[catName]) acc[catName] = []; acc[catName].push(product); return acc; }, {}); setGroupedProducts(grid); } catch (err) { setError("Impossible de contacter le serveur d'approvisionnement."); } finally { setIsLoading(false); } }; fetchCatalog(); }, []); const getCategoryIcon = (text) => { const t = text.toLowerCase(); if (t.includes('vps') || t.includes('serveur')) return ; if (t.includes('cloud') || t.includes('nextcloud')) return ; if (t.includes('data') || t.includes('db') || t.includes('base')) return ; return ; }; const sortedCategoryNames = Object.keys(groupedProducts).sort((a, b) => { let indexA = CATEGORY_ORDER.indexOf(a); let indexB = CATEGORY_ORDER.indexOf(b); if (indexA === -1) indexA = 999; if (indexB === -1) indexB = 999; return indexA - indexB; }); return (

CATALOGUE NEXUS

Déployez de nouvelles instances et étendez votre infrastructure. Facturation flexible.

{isLoading &&
} {error &&
{error}
} {!isLoading && !error && sortedCategoryNames.map((categoryName) => ( ))}
); }