diff --git a/components/BuyBoxWarningBadge.tsx b/components/BuyBoxWarningBadge.tsx index f5796de..9aa1358 100644 --- a/components/BuyBoxWarningBadge.tsx +++ b/components/BuyBoxWarningBadge.tsx @@ -1,28 +1,66 @@ -import React from 'react'; +import React, { useState } from 'react'; interface BuyBoxWarningBadgeProps { asin: string; buyBoxLostMap?: Map }>; } +const COUNTRY_FLAGS: Record = { + DE: '🇩🇪', + FR: '🇫🇷', + IT: '🇮🇹', + UK: '🇬🇧', + ES: '🇪🇸', +}; + export const BuyBoxWarningBadge: React.FC = ({ asin, buyBoxLostMap }) => { + const [isHovered, setIsHovered] = useState(false); + if (!buyBoxLostMap || !asin) return null; const data = buyBoxLostMap.get(asin.toUpperCase()); if (!data || data.countries.length === 0) return null; - const tooltipContent = data.countries - .map(c => `${c}: ${data.reasons[c] || 'Unknown'}`) - .join('\n'); - return (
setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} > - ⚠️ - BB Lost - {data.countries.join(', ')} +
+ ⚠️ + BB Lost + {data.countries.join(', ')} +
+ + {/* Hover Popup */} + {isHovered && ( +
+
+ + ⚠️ Buy Box Lost + +
+
+ {data.countries.map(country => ( +
+ {COUNTRY_FLAGS[country] || '🏳️'} +
+ + {country} + + + {data.reasons[country] || 'Unknown'} + +
+
+ ))} +
+
+ )}
); };