diff --git a/components/BuyBoxWarningBadge.tsx b/components/BuyBoxWarningBadge.tsx index 0eeb21d..2b84b5e 100644 --- a/components/BuyBoxWarningBadge.tsx +++ b/components/BuyBoxWarningBadge.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, memo } from 'react'; interface BuyBoxWarningBadgeProps { asin: string; @@ -13,7 +13,7 @@ const COUNTRY_FLAGS: Record = { ES: '🇪🇸', }; -export const BuyBoxWarningBadge: React.FC = ({ asin, buyBoxLostMap }) => { +export const BuyBoxWarningBadge: React.FC = memo(({ asin, buyBoxLostMap }) => { const [isHovered, setIsHovered] = useState(false); if (!buyBoxLostMap || !asin) return null; @@ -27,45 +27,45 @@ export const BuyBoxWarningBadge: React.FC = ({ asin, bu if (!data || data.countries.length === 0) return null; return ( -
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} - > -
+
+
setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + > ⚠️ BB Lost {data.countries.slice(0, 3).join(', ')}{data.countries.length > 3 ? '...' : ''} -
- {/* Hover Popup */} - {isHovered && ( -
-
- - ⚠️ Buy Box Lost Reason - -
-
- {data.countries.map(country => ( -
- {COUNTRY_FLAGS[country] || '🏳️'} -
- - {country} - - - {data.reasons[country] || 'Unknown'} - + {/* Hover Popup */} + {isHovered && ( +
+
+ + ⚠️ Buy Box Lost Reason + +
+
+ {data.countries.map(country => ( +
+ {COUNTRY_FLAGS[country] || '🏳️'} +
+ + {country} + + + {data.reasons[country] || 'Unknown'} + +
-
- ))} + ))} +
-
- )} + )} +
); -}; +});