From a0a35ca6f19213123e9fb102096ebeff7a90cb2c Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Sun, 27 Apr 2025 20:13:54 -0600 Subject: move to router --- client/src/App.js | 161 ++++++++++++++++++---------------------------------- client/src/index.js | 12 ++-- 2 files changed, 62 insertions(+), 111 deletions(-) (limited to 'client/src') diff --git a/client/src/App.js b/client/src/App.js index d130e08..4e08a17 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -1,9 +1,12 @@ -import React, { useEffect, useState } from 'react'; -import { Typography, Spin, Message, Card, Grid, PageHeader } from '@arco-design/web-react'; +import React from 'react'; +import { Routes, Route, Navigate, Link} from 'react-router-dom'; +import MarketDataPage from './MarketDataPage'; +import BidsPage from './BidsPage'; +import SubmitBidPage from './SubmitBidPage'; +import { Menu } from '@arco-design/web-react'; +import { PageHeader, Typography } from '@arco-design/web-react'; import '@arco-design/web-react/dist/css/arco.css'; -import { VChart } from '@visactor/react-vchart'; -const { Row, Col } = Grid; const ghostBgStyle = { backgroundImage: 'radial-gradient(var(--color-fill-3) 1px, rgba(0, 0, 0, 0) 1px)', backgroundSize: '16px 16px', @@ -11,111 +14,55 @@ const ghostBgStyle = { }; function App() { - const [fiveMinData, setFiveMinData] = useState([]); - const [dayAheadData, setDayAheadData] = useState([]); - const [loading, setLoading] = useState(true); - - useEffect(() => { - Promise.all([ - fetch('http://127.0.0.1:8000/market/real-time'), - fetch('http://127.0.0.1:8000/market/day-ahead') - ]) - .then(async ([res1, res2]) => { - if (!res1.ok || !res2.ok) throw new Error('Failed to fetch data'); - const json1 = await res1.json(); - const json2 = await res2.json(); - setFiveMinData(json1); - setDayAheadData(json2); - }) - .catch((err) => { - console.error(err); - Message.error('Failed to load market data.'); - }) - .finally(() => setLoading(false)); - }, []); - - const getChartSpec = (data, title) => ({ - type: 'line', - data: { - values: data.map(d => ({ - timestamp: new Date(d.timestamp).toLocaleString(), - lmp: d.lmp, - energy: d.energy, - congestion: d.congestion, - loss: d.loss - })), - transforms: [ - { - type: 'fold', - options: { - key: 'name', - value: 'value', - fields: ['lmp', 'energy', 'congestion', 'loss'] - } - } - ] - }, - xField: 'timestamp', - yField: 'value', - seriesField: 'name', - smooth: true, - legend: { - position: 'top' - }, - tooltip: { - formatter: (datum) => ({ - name: datum.name, - value: datum.value.toFixed(2) - }) - }, - dataZoom: [ - { - orient: 'bottom', - height: 20, - start: title === 'fiveMin' ? 0.9 : 0.05, - end: 1 - } - ] - }); - return ( - <> -
- PolyEnergy - } subTitle={ - Virtual Energy Trading - } /> -
-
- Market Data Visualization - {loading ? ( - - ) : ( - <> -
- - - - - - - - - - - - -
- - )} +
+ +
+ + PolyEnergy + + } + subTitle={ + + Virtual Energy Trading + + } + /> + + + Market Data + + + Submit Bid + + + My Bids + + +
+ + + } /> + } /> + } /> + } /> +
- ); } diff --git a/client/src/index.js b/client/src/index.js index 10d3d73..bebdf88 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -4,6 +4,9 @@ import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; import { initVChartArcoTheme } from '@visactor/vchart-arco-theme'; +import { BrowserRouter } from 'react-router-dom';import { ConfigProvider } from '@arco-design/web-react'; +import enUS from '@arco-design/web-react/es/locale/en-US'; + initVChartArcoTheme({ defaultMode: 'light', @@ -13,11 +16,12 @@ initVChartArcoTheme({ const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + + + + + ); -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals(); -- cgit v1.2.3