Skip to content

Commit

Permalink
formatting Vanguard Image file
Browse files Browse the repository at this point in the history
  • Loading branch information
eethansmith committed Dec 6, 2023
1 parent 0e9f9b2 commit dfec730
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// App.js or your main component file
import React, { useState } from 'react';
import './App.css';
import homeImage from './menu-con.jpg';
import homeImage from './resources/menu-con.jpg';
import StockHoldings from './StockHoldings';
import StockGraph from './StockGraphing';
import HistoricHoldings from './HistoricHoldings';
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/StockHoldings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,23 @@ function StockHoldings({ onStockSelect }) {
return () => clearInterval(interval);
}, []);

// Function to load images asynchronously
// Function to load images
const loadImage = async (ticker) => {
try {
const image = await import(`./resources/${ticker}.png`);
return image.default;
} catch (error) {
console.error('Error loading image:', error);
return ''; // Fallback image or placeholder
// Attempt to load without '.L' if it fails
if (ticker.endsWith('.L')) {
try {
const modifiedTicker = ticker.replace('.L', '');
const image = await import(`./resources/${modifiedTicker}.png`);
return image.default;
} catch (innerError) {
console.error('Error loading image:', innerError);
return '';
}
}
}
};

Expand Down
File renamed without changes
File renamed without changes

0 comments on commit dfec730

Please sign in to comment.