/* ProductDetail — fullscreen overlay; zoomed hero + tabs (Overview/Specs/HowTo/Assembly) */ const ProductDetail = ({ lang, product, onClose }) => { const [tab, setTab] = React.useState('overview'); const [currentImageIndex, setCurrentImageIndex] = React.useState(0); // Image carousel state if (!product) return null; const cat = window.CATALOG.categories[product.category]; // Determine if this is an accessory product const isAccessory = cat && cat.folder === 'accessories'; const specLabel = (s) => lang === 'el' ? (s.label_el || s.label) : (s.label_en || s.label); const specValue = (s) => lang === 'el' ? (s.value_el || s.value) : (s.value_en || s.value); const sectionLabel = (sec) => { const map = { 'ΠΡΟΔΙΑΓΡΑΦΕΣ': lang === 'el' ? 'Προδιαγραφές' : 'Specifications', 'ΔΙΑΣΤΑΣΕΙΣ': lang === 'el' ? 'Διαστάσεις' : 'Dimensions', 'ΥΠΟΛΟΓΙΣΤΗΣ': lang === 'el' ? 'Υπολογιστής' : 'Computer', 'ΠΛΗΡΟΦΟΡΙΕΣ': lang === 'el' ? 'Πληροφορίες' : 'Information', }; return map[sec] || sec; }; // Get all images for carousel const images = product.images || [product.hero]; const currentImage = images[currentImageIndex] || product.hero; // Group specs by section for the table const grouped = {}; product.specs.forEach(s => { const sec = s.section || '—'; if (!grouped[sec]) grouped[sec] = []; grouped[sec].push(s); }); // Pick a few highlight specs for overview const wantedHighlights = [ 'Μέγιστο βάρος εξασκούμενου','Βάρος εξασκούμενου','Μέγιστη ταχύτητα', 'Ιπποδύναμη μοτέρ','Επίπεδα αντίστασης','Διαστάσεις τάπητα τρεξίματος', 'Μέγιστο βάρος φόρτωσης','Διαστάσεις, συναρμολογημένο', 'Πεντάλ με ιμάντα','Αναδίπλωση','Εγγύηση','ΕΓΓΥΗΣΗ ' ]; const highlights = []; wantedHighlights.forEach(lbl => { const s = product.specs.find(x => (x.label_el || x.label) === lbl); if (s && !highlights.find(h => (h.label_el || h.label) === lbl)) highlights.push(s); }); while (highlights.length < 4 && highlights.length < product.specs.length) { const next = product.specs[highlights.length]; if (!highlights.find(h => (h.label_el || h.label) === (next.label_el || next.label))) highlights.push(next); else break; } const stop = (e) => e.stopPropagation(); // Get bilingual product name const productName = lang === 'el' ? (product.name_el || product.name || product.code) : (product.name_en || product.name || product.code); return (
| {specLabel(s)} | {specValue(s)} |
|---|
{t('video_placeholder', lang)}
{t('tab_' + kind, lang)}