'use client'; import React, { useState } from 'react'; import { useTranslations } from 'next-intl'; interface KeyValueItem { label: string; value: string; unit?: string; } interface VoltageTable { voltageLabel: string; metaItems: KeyValueItem[]; columns: Array<{ key: string; label: string }>; rows: Array<{ configuration: string; cells: string[] }>; } interface ProductTechnicalDataProps { data: { technicalItems: KeyValueItem[]; voltageTables: VoltageTable[]; }; } export default function ProductTechnicalData({ data }: ProductTechnicalDataProps) { const t = useTranslations('Products'); const [expandedTables, setExpandedTables] = useState>({}); if (!data) return null; const { technicalItems = [], voltageTables = [] } = data; const toggleTable = (idx: number) => { setExpandedTables((prev) => ({ ...prev, [idx]: !prev[idx], })); }; return (
{technicalItems.length > 0 && (

General Data

{technicalItems.map((item, idx) => (
{item.label}
{item.value}{' '} {item.unit && ( {item.unit} )}
))}
)} {voltageTables.map((table, idx) => { const isExpanded = expandedTables[idx]; const hasManyRows = table.rows.length > 10; return (

{table.voltageLabel !== 'Voltage unknown' && table.voltageLabel !== 'Spannung unbekannt' ? table.voltageLabel : 'Technical Specifications'}

{table.metaItems.length > 0 && (
{table.metaItems.map((item, mIdx) => (
{item.label}
{item.value} {item.unit}
))}
)}
{table.columns.map((col, cIdx) => ( ))} {table.rows.map((row, rIdx) => ( {row.cells.map((cell: any, cellIdx: number) => ( ))} ))}
Config. {col.label}
{row.configuration} {typeof cell === 'object' && cell !== null && 'value' in cell ? cell.value : cell}
{!isExpanded && hasManyRows && (
)}
{hasManyRows && (
)}
); })}
); }