'use client';
export default function ProductSummary({ item }: any) {
return (
Thông số sản phẩm
{renderSummary(item)}
)
}
function renderSummary(data:any) {
if (!data) return null;
if (typeof data === 'string' && data.includes('<')) {
if (typeof window === 'undefined') return null;
const parser = new DOMParser();
const doc = parser.parseFromString(data, 'text/html');
return Array.from(doc.body.childNodes)
.filter(
node =>
node.nodeType === 1 && node.textContent !== null && node.textContent.trim() !== ''
)
.map((node, index) => (
{node.textContent?.trim()}
));
}
return data
.split(/\r?\n/)
.filter((line:any) => line.trim() !== '')
.map((line:any, index:any) => (
{line.trim()}
));
}