From 623a03cc02b2e87a187aca29db5f3c787713fc74 Mon Sep 17 00:00:00 2001
From: Navan Chauhan <navanchauhan@gmail.com>
Date: Sun, 27 Apr 2025 21:03:25 -0600
Subject: add market option

---
 client/src/SubmitBidPage.jsx | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

(limited to 'client/src/SubmitBidPage.jsx')

diff --git a/client/src/SubmitBidPage.jsx b/client/src/SubmitBidPage.jsx
index 65a9eb8..94a0c32 100644
--- a/client/src/SubmitBidPage.jsx
+++ b/client/src/SubmitBidPage.jsx
@@ -1,37 +1,46 @@
-import React, { useState, useEffect } from 'react';
-import { Form, InputNumber, DatePicker, Button, Message, Typography, Card } from '@arco-design/web-react';
+import React, { useState, useEffect, useContext } from 'react';
+import { Form, InputNumber, DatePicker, Button, Message, Typography, Card, Select } from '@arco-design/web-react';
 import '@arco-design/web-react/dist/css/arco.css';
 import dayjs from 'dayjs';
 import utc from 'dayjs/plugin/utc';
 import timezone from 'dayjs/plugin/timezone';
 import API_BASE_URL from './config';
+import { MarketContext, MARKET_FULL_NAMES } from './App';
 
 dayjs.extend(utc);
 dayjs.extend(timezone);
 
+const MARKET_TIMEZONES = {
+  ISONE: 'America/New_York',
+  NYISO: 'America/New_York',
+  MISO: 'America/Chicago'
+};
+
 function SubmitBidPage() {
+  const { selectedMarket } = useContext(MarketContext);
   const [form] = Form.useForm();
   const [loading, setLoading] = useState(false);
   const [localNow, setLocalNow] = useState('');
-  const [newEnglandNow, setNewEnglandNow] = useState('');
+  const [marketNow, setMarketNow] = useState('');
 
   useEffect(() => {
     const updateTime = () => {
       const now = dayjs();
       const localFormatted = now.format('dddd, MMMM D, h:mm A');
 
-      const newEngland = now.tz('America/New_York');
-      const newEnglandFormatted = newEngland.format('dddd, MMMM D, h:mm A');
+      const marketTz = MARKET_TIMEZONES[selectedMarket] || 'America/New_York';
+      const marketTime = now.tz(marketTz);
+      const marketFormatted = marketTime.format('dddd, MMMM D, h:mm A');
 
       setLocalNow(localFormatted);
-      setNewEnglandNow(newEnglandFormatted);
+      setMarketNow(marketFormatted);
     };
 
     updateTime();
-    const interval = setInterval(updateTime, 1000); // update every second
+    const interval = setInterval(updateTime, 1000);
 
     return () => clearInterval(interval);
-  }, []);
+  }, [selectedMarket]);
 
   const handleSubmit = async (values) => {
     setLoading(true);
@@ -39,10 +48,14 @@ function SubmitBidPage() {
       const picked = dayjs(values.timestamp);
       const adjusted = picked.minute(0).second(0).millisecond(0);
 
+      const marketTz = MARKET_TIMEZONES[selectedMarket] || 'America/New_York';
+      const timestampInMarketTz = adjusted.tz(marketTz).format();
+
       const payload = {
-        timestamp: adjusted.tz('America/New_York').format(),
+        timestamp: timestampInMarketTz,
         quantity: values.quantity,
         price: values.price,
+        market: selectedMarket,
         user_id: 1 // Hardcoded user id for now
       };
 
@@ -73,12 +86,11 @@ function SubmitBidPage() {
     <div style={{ padding: 20, backgroundColor: 'var(--color-fill-2)' }}>
       <Typography.Title heading={4}>Submit New Bid</Typography.Title>
       <Card style={{ marginTop: 16 }}>
-        {/* 🕰️ Show Current Time Info */}
         <Typography.Paragraph>
           <strong>Current Local Time:</strong> {localNow}
         </Typography.Paragraph>
         <Typography.Paragraph>
-          <strong>Current New England Time:</strong> {newEnglandNow}
+          <strong>Current {MARKET_FULL_NAMES[selectedMarket]} Time:</strong> {marketNow}
         </Typography.Paragraph>
 
         <Form
@@ -105,8 +117,8 @@ function SubmitBidPage() {
               style={{ width: '100%' }}
               format="YYYY-MM-DD HH:00"
               placeholder="Select date and hour"
-              timezone='America/New_York'
               disabledMinutes={() => Array.from({ length: 60 }, (_, i) => i !== 0)}
+              timezone={MARKET_TIMEZONES[selectedMarket]}
             />
           </Form.Item>
 
-- 
cgit v1.2.3

