12/02/2026
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
'use client';
|
||||
import { useEffect, useState } from 'react'
|
||||
import { renderSummary } from "@/lib/utils"
|
||||
|
||||
export default function ProductSummary({ item }: any) {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
@@ -22,33 +23,4 @@ export default function ProductSummary({ item }: any) {
|
||||
}
|
||||
|
||||
|
||||
function renderSummary(data: any) {
|
||||
if (!data) return null;
|
||||
|
||||
if (typeof data === 'string' && data.includes('<')) {
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(data, 'text/html')
|
||||
|
||||
return Array.from(doc.body.childNodes)
|
||||
.filter(
|
||||
node =>
|
||||
node.nodeType === 1 &&
|
||||
node.textContent &&
|
||||
node.textContent.trim() !== ''
|
||||
)
|
||||
.map((node, index) => (
|
||||
<div key={index} className="item-circle">
|
||||
{node.textContent!.trim()}
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
return data
|
||||
.split(/\r?\n/)
|
||||
.filter((line: string) => line.trim() !== '')
|
||||
.map((line: string, index: number) => (
|
||||
<div key={index} className="item-circle">
|
||||
{line.trim()}
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user