@@ -1128,14 +1207,117 @@ export default function IndustriesSectorsKeywords() {
);
}
+ // Handle stat card click - filters table to show matching keywords
+ const handleStatClick = (statType: StatType) => {
+ // Toggle off if clicking same stat
+ if (activeStatFilter === statType) {
+ setActiveStatFilter(null);
+ setShowNotAddedOnly(false);
+ setDifficultyFilter('');
+ return;
+ }
+
+ setActiveStatFilter(statType);
+ setShowBrowseTable(true);
+ setCurrentPage(1);
+
+ // Apply filters based on stat type
+ switch (statType) {
+ case 'available':
+ setShowNotAddedOnly(true);
+ setDifficultyFilter('');
+ break;
+ case 'high_volume':
+ // Volume >= 10K - needs sort by volume desc
+ setShowNotAddedOnly(false);
+ setDifficultyFilter('');
+ setSortBy('volume');
+ setSortDirection('desc');
+ break;
+ case 'premium_traffic':
+ // Premium traffic - sort by volume
+ setShowNotAddedOnly(false);
+ setDifficultyFilter('');
+ setSortBy('volume');
+ setSortDirection('desc');
+ break;
+ case 'long_tail':
+ // Long tail - can't filter by word count server-side, just show all sorted
+ setShowNotAddedOnly(false);
+ setDifficultyFilter('');
+ setSortBy('keyword');
+ setSortDirection('asc');
+ break;
+ case 'quick_wins':
+ // Quick wins - low difficulty + available
+ setShowNotAddedOnly(true);
+ setDifficultyFilter('1'); // Very Easy (level 1 = backend 0-20)
+ setSortBy('difficulty');
+ setSortDirection('asc');
+ break;
+ default:
+ setShowNotAddedOnly(false);
+ setDifficultyFilter('');
+ }
+ };
+
+ // Build smart suggestions from sector stats
+ const smartSuggestions = useMemo(() => {
+ if (!sectorStats) return [];
+ return buildSmartSuggestions(sectorStats, { showOnlyWithResults: true });
+ }, [sectorStats]);
+
return (
<>
-
+
+
+ {/* TEST TEXT - REMOVE AFTER VERIFICATION */}
+
+ Test Text
+
+
, color: 'blue' }}
/>
+ {/* Sector Metric Cards - Show when site is selected */}
+ {activeSite && (
+
+
+
+ Keyword Stats {activeSector ? `— ${activeSector.name}` : '— All Sectors'}
+
+
+ Click a card to filter the table below
+
+
+
+
+ )}
+
+ {/* Smart Suggestions Panel */}
+ {activeSite && sectorStats && smartSuggestions.length > 0 && (
+
+ {
+ // Apply the filter from the suggestion
+ if (suggestion.filterParams.statType) {
+ handleStatClick(suggestion.filterParams.statType as StatType);
+ }
+ }}
+ isLoading={loadingSectorStats}
+ />
+
+ )}
+
{/* High Opportunity Keywords Section - Loads First */}
@@ -1218,7 +1400,7 @@ export default function IndustriesSectorsKeywords() {
<>