diff --git a/frontend/src/components/shared/ResearchLeadershipAnalysis/ResearchLeadershipAnalysis.module.css b/frontend/src/components/shared/ResearchLeadershipAnalysis/ResearchLeadershipAnalysis.module.css index 0e7f3e1..75b8ef3 100644 --- a/frontend/src/components/shared/ResearchLeadershipAnalysis/ResearchLeadershipAnalysis.module.css +++ b/frontend/src/components/shared/ResearchLeadershipAnalysis/ResearchLeadershipAnalysis.module.css @@ -1,7 +1,7 @@ .analysisContainer { - background: #ffffff; + background: #1a1a1a; border-radius: 12px; - box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); + box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); padding: 24px; margin: 20px 0; position: relative; @@ -14,7 +14,7 @@ } .header h3 { - color: #2c3e50; + color: #ffffff; font-size: 24px; font-weight: 700; margin: 0 0 8px 0; @@ -25,7 +25,7 @@ } .header p { - color: #7f8c8d; + color: #b0b0b0; font-size: 16px; margin: 0; font-weight: 400; @@ -39,10 +39,10 @@ } .analysisCard { - background: #f8f9fa; + background: #2a2a2a; border-radius: 8px; padding: 20px; - border: 1px solid #e9ecef; + border: 1px solid #404040; transition: all 0.3s ease; } @@ -52,7 +52,7 @@ } .analysisCard h4 { - color: #2c3e50; + color: #ffffff; font-size: 18px; font-weight: 600; margin: 0 0 16px 0; @@ -72,14 +72,14 @@ align-items: center; gap: 12px; padding: 12px; - background: white; + background: #1a1a1a; border-radius: 6px; - border: 1px solid #e9ecef; + border: 1px solid #404040; transition: all 0.2s ease; } .statItem:hover { - background: #f8f9fa; + background: #2a2a2a; border-color: #667eea; } @@ -125,7 +125,7 @@ .name { font-weight: 600; - color: #2c3e50; + color: #ffffff; font-size: 14px; margin-bottom: 4px; white-space: nowrap; @@ -137,7 +137,7 @@ display: flex; gap: 12px; font-size: 12px; - color: #6c757d; + color: #b0b0b0; } .citations { @@ -155,14 +155,14 @@ justify-content: space-between; align-items: center; padding: 8px 12px; - background: white; + background: #1a1a1a; border-radius: 4px; - border: 1px solid #e9ecef; + border: 1px solid #404040; } .year { font-weight: 600; - color: #2c3e50; + color: #ffffff; font-size: 14px; } @@ -170,7 +170,7 @@ display: flex; gap: 12px; font-size: 12px; - color: #6c757d; + color: #b0b0b0; } .summaryStats { @@ -182,9 +182,9 @@ .summaryItem { text-align: center; padding: 16px; - background: white; + background: #1a1a1a; border-radius: 6px; - border: 1px solid #e9ecef; + border: 1px solid #404040; } .summaryValue { @@ -196,7 +196,7 @@ .summaryLabel { font-size: 12px; - color: #6c757d; + color: #b0b0b0; font-weight: 500; } @@ -225,7 +225,7 @@ } .loading p { - color: #7f8c8d; + color: #b0b0b0; font-size: 14px; margin: 0; } @@ -278,72 +278,4 @@ .summaryValue { font-size: 20px; } -} - -/* Dark mode support */ -@media (prefers-color-scheme: dark) { - .analysisContainer { - background: #1a1a1a; - box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); - } - - .header h3 { - color: #ffffff; - } - - .header p { - color: #b0b0b0; - } - - .analysisCard { - background: #2a2a2a; - border-color: #404040; - } - - .analysisCard h4 { - color: #ffffff; - } - - .statItem { - background: #1a1a1a; - border-color: #404040; - } - - .statItem:hover { - background: #2a2a2a; - } - - .name { - color: #ffffff; - } - - .metrics { - color: #b0b0b0; - } - - .trendItem { - background: #1a1a1a; - border-color: #404040; - } - - .year { - color: #ffffff; - } - - .trendMetrics { - color: #b0b0b0; - } - - .summaryItem { - background: #1a1a1a; - border-color: #404040; - } - - .summaryLabel { - color: #b0b0b0; - } - - .loading p { - color: #b0b0b0; - } } \ No newline at end of file diff --git a/frontend/src/components/shared/WorldMapPapers/WorldMapPapers.jsx b/frontend/src/components/shared/WorldMapPapers/WorldMapPapers.jsx index e0072d8..0886d76 100644 --- a/frontend/src/components/shared/WorldMapPapers/WorldMapPapers.jsx +++ b/frontend/src/components/shared/WorldMapPapers/WorldMapPapers.jsx @@ -217,133 +217,76 @@ const getCountryCentroid = (countryCode) => countryCentroids[countryCode] || [0, const OPENALEX_API_BASE = 'https://api.openalex.org'; -const WorldMapPapers = ({ searchQuery, onPaperSelect, onApiCallsUpdate }) => { +const WorldMapPapers = ({ searchQuery, onPaperSelect, onApiCallsUpdate, triggerSearch = false, searchResults = null }) => { const [papers, setPapers] = useState([]); const [loading, setLoading] = useState(false); const [tooltipContent, setTooltipContent] = useState(''); const [mapError, setMapError] = useState(false); const [fetchError, setFetchError] = useState(null); - // Sample data structure for fallback - const samplePapers = [ - { - id: 1, - title: "Attention Is All You Need", - authors: ["Vaswani, A.", "Shazeer, N.", "Parmar, N."], - citations: 45000, - country: "US", - coordinates: [-95.7129, 37.0902], - year: 2017, - institution: "Google Research" - }, - { - id: 2, - title: "BERT: Pre-training of Deep Bidirectional Transformers", - authors: ["Devlin, J.", "Chang, M.W.", "Lee, K."], - citations: 38000, - country: "US", - coordinates: [-95.7129, 37.0902], - year: 2018, - institution: "Google AI" - }, - { - id: 3, - title: "Deep Learning", - authors: ["LeCun, Y.", "Bengio, Y.", "Hinton, G."], - citations: 35000, - country: "CA", - coordinates: [-106.3468, 56.1304], - year: 2015, - institution: "University of Toronto" - }, - { - id: 4, - title: "ImageNet Classification with Deep Convolutional Neural Networks", - authors: ["Krizhevsky, A.", "Sutskever, I.", "Hinton, G.E."], - citations: 32000, - country: "CA", - coordinates: [-106.3468, 56.1304], - year: 2012, - institution: "University of Toronto" - }, - { - id: 5, - title: "Generative Adversarial Networks", - authors: ["Goodfellow, I.", "Pouget-Abadie, J.", "Mirza, M."], - citations: 30000, - country: "US", - coordinates: [-95.7129, 37.0902], - year: 2014, - institution: "University of Montreal" - }, - { - id: 6, - title: "ResNet: Deep Residual Learning for Image Recognition", - authors: ["He, K.", "Zhang, X.", "Ren, S."], - citations: 28000, - country: "CN", - coordinates: [104.1954, 35.8617], - year: 2015, - institution: "Microsoft Research" - }, - { - id: 7, - title: "YOLO: Real-Time Object Detection", - authors: ["Redmon, J.", "Divvala, S.", "Girshick, R."], - citations: 25000, - country: "US", - coordinates: [-95.7129, 37.0902], - year: 2016, - institution: "University of Washington" - }, - { - id: 8, - title: "Transformer: A Novel Neural Network Architecture", - authors: ["Vaswani, A.", "Shazeer, N.", "Parmar, N."], - citations: 22000, - country: "GB", - coordinates: [-0.1278, 51.5074], - year: 2017, - institution: "Google DeepMind" - }, - { - id: 9, - title: "AlphaGo: Mastering the Game of Go", - authors: ["Silver, D.", "Huang, A.", "Maddison, C."], - citations: 20000, - country: "GB", - coordinates: [-0.1278, 51.5074], - year: 2016, - institution: "Google DeepMind" - }, - { - id: 10, - title: "GPT: Improving Language Understanding", - authors: ["Radford, A.", "Narasimhan, K.", "Salimans, T."], - citations: 18000, - country: "US", - coordinates: [-95.7129, 37.0902], - year: 2018, - institution: "OpenAI" - } - ]; - useEffect(() => { - const trimmedQuery = (searchQuery || '').trim(); - if (trimmedQuery.length > 0) { - fetchPapersByQuery(trimmedQuery); - } else { - setPapers(samplePapers); + // If search results are provided from parent, use those + if (searchResults && searchResults.length > 0) { + const mapped = searchResults.map((work, idx) => { + // Try to get first author institution country and coordinates + let country = null; + let coordinates = null; + let institution = null; + if (work.authorships && work.authorships.length > 0) { + const firstAuth = work.authorships[0]; + if (firstAuth.institutions && firstAuth.institutions.length > 0) { + const inst = firstAuth.institutions[0]; + country = inst.country_code || inst.country || null; + institution = inst.display_name || null; + // If OpenAlex provides lat/lon, use it (not always available) + if (inst.latitude && inst.longitude) { + coordinates = [inst.longitude, inst.latitude]; + } else if (country) { + coordinates = getCountryCentroid(country); + } + } + } + // Fallback: use country from work if available + if (!coordinates && work.country_code) { + coordinates = getCountryCentroid(work.country_code); + country = work.country_code; + } + // Fallback: skip if no coordinates + if (!coordinates) return null; + return { + id: work.id || idx, + title: work.title || work.display_name || 'Untitled', + authors: work.authorships ? work.authorships.map(a => a.author?.display_name || '').filter(Boolean) : [], + citations: work.citation_count || work.cited_by_count || 0, + country, + coordinates, + year: work.publication_year || null, + institution: institution || null + }; + }).filter(Boolean); + setPapers(mapped); + setLoading(false); + setFetchError(null); + } else if (triggerSearch && searchQuery && searchQuery.trim().length > 0) { + // Fallback to own API call if no results provided + fetchPapersByQuery(searchQuery.trim()); + } else if (!triggerSearch) { + // Reset to empty state when not searching + setPapers([]); setFetchError(null); setLoading(false); + // Update API calls for disclaimer + if (onApiCallsUpdate) { + onApiCallsUpdate([]); + } } // eslint-disable-next-line - }, [searchQuery]); + }, [triggerSearch, searchQuery, searchResults]); const fetchPapersByQuery = async (query) => { const trimmed = (query || '').trim(); if (!trimmed) { - setPapers(samplePapers); + setPapers([]); setFetchError(null); setLoading(false); // Update API calls for disclaimer @@ -522,6 +465,52 @@ const WorldMapPapers = ({ searchQuery, onPaperSelect, onApiCallsUpdate }) => {
{fetchError}
)} + {!loading && !fetchError && papers.length === 0 && searchQuery && ( ++ No research papers found for your search query. Try different keywords or filters to discover relevant research. +
++ Enter keywords in the search box above to find research papers and visualize their global impact on the world map. +
+