From 2c5b7da8165e3f8b90748e8ced1de0e3e8d52309 Mon Sep 17 00:00:00 2001 From: lazydancer Date: Sun, 22 Dec 2024 17:33:11 -0500 Subject: Initial --- frontend/src/DataDisplay.js | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 frontend/src/DataDisplay.js (limited to 'frontend/src/DataDisplay.js') diff --git a/frontend/src/DataDisplay.js b/frontend/src/DataDisplay.js new file mode 100644 index 0000000..294f4fb --- /dev/null +++ b/frontend/src/DataDisplay.js @@ -0,0 +1,94 @@ +import React from 'react'; +import { motion, AnimatePresence } from 'framer-motion'; +import './DataDisplay.css'; // Import the CSS file for transitions + + +const DataDisplay = ({ data }) => { + console.log("DataDisplay Data: ", data); + const getIcon = (name) => { + // Replace these with actual icon components or image tags + if (name === 'system') return + + ; + if (name === 'station') return + + ; + if (name === 'buy') return + + ; + if (name === 'sell') return + + ; + + return ''; // Default icon or empty + }; + + if (!data) { + return

Loading ...

+ } + + const handleItemClick = async (typeId) => { + try { + const response = await fetch(`http://localhost:8000/open_market_window/${typeId}`, { method: 'POST' }); + console.log('Server Response:', response.data); + // Handle response or set state as needed + } catch (error) { + console.error('Error posting to server:', error); + // Handle error + } + } + + + const containerVariants = { + hidden: { opacity: 0, y: -20 }, + visible: { opacity: 1, y: 0 }, + exit: { opacity: 0, y: -20 } + }; + + return ( +
+ + {data.map((location, index) => ( + +
+ + {getIcon(location.location_type)} + +

{location.location}

+
+
+ {location.actions.length > 0 ? ( +
+ {location.actions.map((action, actionIndex) => ( + +
{getIcon(action.action_type)}
+
handleItemClick(action.type_id)} className={`${index === 0 ? 'font-semibold' : ''}`} style={{ cursor: 'pointer' }}>{action.item}
+
{action.quantity}
+
{action.price ? `$${action.price.toLocaleString()}` : '-'}
+
+ ))} +
+ ) : ( +

+ )} +
+
+ ))} +
+ + +
+ ); + + }; + +export default DataDisplay; \ No newline at end of file -- cgit v1.3