diff --git a/src/app/component/BrokerManagement.jsx b/src/app/component/BrokerManagement.jsx index b68f4dd..a1a16a9 100644 --- a/src/app/component/BrokerManagement.jsx +++ b/src/app/component/BrokerManagement.jsx @@ -1,614 +1,7 @@ -// "use client"; -// import Image from "next/image"; -// import logo from "../assets/images.png" -// import React, { useState, useEffect } from 'react'; -// const getStatusIcon = (status) => { -// switch (status) { -// case 'active': -// return ; -// case 'inactive': -// return ; -// case 'expired': -// return ; -// default: -// return ; -// } -// }; -// const ToggleSwitch = ({ checked, onChange }) => ( -// -// ); -// const SlidePanel = ({ isOpen, onClose, title, children, width = "w-96" }) => ( -// <> - -// {isOpen && ( -//
-// )} - -//
-//
- -//
-//

{title}

-// -//
- -//
-// {children} -//
-//
-//
-// -// ); -// const BrokerManagement = () => { -// const [activeMainTab, setActiveMainTab] = useState('Brokers'); -// const [activeSubTab, setActiveSubTab] = useState('API Management'); -// const [filterStatus, setFilterStatus] = useState('All'); -// const [searchTerm, setSearchTerm] = useState(''); -// const [isPanelOpen, setIsPanelOpen] = useState(false); -// const [editingBroker, setEditingBroker] = useState(null); -// const [showAddPanel, setShowAddPanel] = useState(false); -// const [showEditPanel, setShowEditPanel] = useState(false); -// const [formData, setFormData] = useState({ -// name: '', -// apiId: '', -// broker: '', -// dateAdded: '', -// status: 'active', -// balance: '', -// onOff: true, -// secretKey: '' -// }); -// const [brokers, setBrokers] = useState([ -// { id: 1, name: 'MarketAxess', apiId: '88234', broker: 'Meta5', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: true, secretKey: 'sk-41ZBkLjY...' }, -// { id: 2, name: 'Tradeweb Markets', apiId: '89245', broker: 'Angel One', dateAdded: 'Mar 01, 2025', status: 'inactive', balance: '$175.50', onOff: true, secretKey: 'sk-98AbcDeF...' }, -// { id: 3, name: 'MarketAxess', apiId: '88234', broker: 'Meta5', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: false, secretKey: 'sk-34GhIjKl...' }, -// { id: 4, name: 'Tradeweb Markets', apiId: '89245', broker: 'Zerodha', dateAdded: 'Mar 01, 2025', status: 'expired', balance: '$175.50', onOff: true, secretKey: 'sk-56MnOpQr...' }, -// { id: 5, name: 'MarketAxess', apiId: '88234', broker: 'Dhan', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: true, secretKey: 'sk-78RsTuVw...' }, -// { id: 6, name: 'Tradeweb Markets', apiId: '89245', broker: 'Angel One', dateAdded: 'Mar 01, 2025', status: 'expired', balance: '$175.50', onOff: true, secretKey: 'sk-12XyZaBc...' }, -// { id: 7, name: 'MarketAxess', apiId: '88234', broker: 'Dhan', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: false, secretKey: 'sk-34DefGhi...' }, -// { id: 8, name: 'Tradeweb Markets', apiId: '89245', broker: 'Angel One', dateAdded: 'Mar 01, 2025', status: 'expired', balance: '$175.50', onOff: true, secretKey: 'sk-56JklMno...' }, -// { id: 9, name: 'MarketAxess', apiId: '88234', broker: 'Meta5', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: true, secretKey: 'sk-78PqrStu...' }, -// { id: 10, name: 'Tradeweb Markets', apiId: '89245', broker: 'Dhan', dateAdded: 'Mar 01, 2025', status: 'inactive', balance: '$175.50', onOff: true, secretKey: 'sk-98VwxYza...' }, -// ]); -// const handleAddBroker = () => { -// setEditingBroker(null); -// setFormData({ -// name: '', -// apiId: '', -// broker: '', -// dateAdded: new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }), -// status: 'active', -// balance: '$0.00', -// onOff: true, -// secretKey: '' -// }); -// setIsPanelOpen(true); -// setShowAddPanel(true); -// setShowEditPanel(false); -// }; -// const handleEditBroker = (broker) => { -// setEditingBroker(broker); -// setFormData({ ...broker }); -// setIsPanelOpen(true); -// setShowAddPanel(false); -// setShowEditPanel(true); -// }; -// const handleDeleteBroker = (id) => { -// if (window.confirm('Are you sure you want to delete this broker?')) { -// setBrokers(brokers.filter(b => b.id !== id)); -// } -// }; -// const handleSaveBroker = () => { -// if (!formData.name || !formData.apiId || !formData.broker) { -// alert('Please fill in all required fields'); -// return; -// } - -// if (editingBroker) { -// setBrokers(brokers.map(b => b.id === editingBroker.id ? { ...formData, id: editingBroker.id } : b)); -// } else { -// const newBroker = { -// ...formData, -// id: Math.max(...brokers.map(b => b.id)) + 1 -// }; -// setBrokers([...brokers, newBroker]); -// } -// setIsPanelOpen(false); -// setShowAddPanel(false); -// setShowEditPanel(false); -// }; - -// const handleToggle = (id) => { -// const updated=brokers.map(b => -// b.id === id ? { ...b, onOff: !b.onOff } : b -// ) -// setBrokers(updated); -// }; - -// const filteredBrokers = brokers.filter(broker => { -// const matchesSearch = broker.name.toLowerCase().includes(searchTerm.toLowerCase()) || -// broker.broker.toLowerCase().includes(searchTerm.toLowerCase()) || -// broker.apiId.includes(searchTerm); - -// const matchesStatus = filterStatus === 'All' || broker.status.toLowerCase() === filterStatus.toLowerCase(); - -// return matchesSearch && matchesStatus; -// }); - -// const groupedBrokers = filteredBrokers.reduce((acc, broker) => { -// const key = `${broker.status}-${broker.onOff ? 'on' : 'off'}`; -// if (!acc[key]) acc[key] = []; -// acc[key].push(broker); -// return acc; -// }, {}); - -// const mainTabs = ['Dashboard', 'Brokers', 'Scan & Trade', 'Positions', 'AI Strategy Builder']; -// const subTabs = ['API Management', 'Risk Management', 'Hook Hub']; -// const statusFilters = ['All', 'Active', 'Inactive', 'Expired']; - -// return ( - //
- //
- //
- //
- // - //
- //
- // {mainTabs.map(tab => ( - // - // ))} - //
- //
- //
- // - // - //
- // NSE - // - //
- // - //
- //
- -//
-//

Brokers / API Management

-//
-// {subTabs.map(tab => ( -// -// ))} -//
-//
- -//
-//
-// setSearchTerm(e.target.value)} -// className="px-4 py-2 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -// -//
-//
-// {statusFilters.map(status => ( -// -// ))} -// -// -//
-//
- -//
-// -// -// -// -// -// -// -// -// -// -// -// -// -// -// {Object.entries(groupedBrokers).map(([groupKey, groupBrokers]) => ( -// -// {filterStatus !== 'All' && ( -// -// -// -// )} -// {groupBrokers -// .sort((a,b)=> a.id - b.id ) -// .map(broker => ( -// -// -// -// -// -// -// -// -// -// -// ))} -// -// ))} -// -//
NameAPI IDBrokerDate AddedStatusBalanceActionOn/Off
-// {groupKey.split('-')[0].charAt(0).toUpperCase() + groupKey.split('-')[0].slice(1)} - {groupKey.split('-')[1].toUpperCase()} -//
{broker.name}{broker.apiId}{broker.broker}{broker.dateAdded}{getStatusIcon(broker.status)}{broker.balance} -//
-// -// -// -//
-//
-// handleToggle(broker.id)} -// /> -//
-//
- -//
-//
Last Synced: May 26, 2025 12:30
-//
-// -// -// -//
-//
- -// { -// setIsPanelOpen(false); -// setShowAddPanel(false); -// }} -// title="Add Broker" -// width="w-96" -// > -//
-//
-// -// setFormData({ ...formData, name: e.target.value })} -// placeholder="Enter a Name" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// -//
- -//
-//
-//

API Details

-// -//
- -//
-//
-// -// setFormData({ ...formData, apiId: e.target.value })} -// placeholder="api_key_1234567890abcdefABCDE" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//

Date Created: {formData.dateAdded}

-//
- -//
-// -// setFormData({ ...formData, secretKey: e.target.value })} -// placeholder="sk-41ZBkLjY..." -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// setFormData({ ...formData, balance: e.target.value })} -// placeholder="$0.00" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// -//
-//
-//
- -//
-// -// -//
-//
-//
- -// { -// setIsPanelOpen(false); -// setShowEditPanel(false); -// }} -// title="Edit Broker" -// width="w-96" -// > -//
-//
-// -// setFormData({ ...formData, name: e.target.value })} -// placeholder="Enter a Name" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// -//
- -//
-//
-//

API Details

-// -//
- -//
-//
-// -// setFormData({ ...formData, apiId: e.target.value })} -// placeholder="api_key_1234567890abcdefABCDE" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//

Date Modified: {formData.dateAdded}

-//
- -//
-// -// setFormData({ ...formData, secretKey: e.target.value })} -// placeholder="sk-41ZBkLjY..." -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// setFormData({ ...formData, balance: e.target.value })} -// placeholder="$0.00" -// className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" -// /> -//
- -//
-// -// -//
-//
-//
- -//
-// -// -//
-//
-//
-//
-// ); -// }; - -// export default BrokerManagement; - - - "use client"; import Image from 'next/image'; import logo from "../assets/images.png" - import React, { useState, useEffect } from 'react'; - const getStatusIcon = (status) => { switch (status) { case 'active': @@ -621,7 +14,6 @@ const getStatusIcon = (status) => { return ; } }; - const ToggleSwitch = ({ checked, onChange }) => (
{children}
@@ -676,7 +66,6 @@ const SlidePanel = ({ isOpen, onClose, title, children, width = "w-96" }) => ( ); - const BrokerManagement = () => { const [activeMainTab, setActiveMainTab] = useState('Brokers'); const [activeSubTab, setActiveSubTab] = useState('API Management'); @@ -696,7 +85,6 @@ const BrokerManagement = () => { onOff: true, secretKey: '' }); - const [brokers, setBrokers] = useState([ { id: 1, name: 'MarketAxess', apiId: '88234', broker: 'Meta5', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: true, secretKey: 'sk-41ZBkLjY...' }, { id: 2, name: 'Tradeweb Markets', apiId: '89245', broker: 'Angel One', dateAdded: 'Mar 01, 2025', status: 'inactive', balance: '$175.50', onOff: true, secretKey: 'sk-98AbcDeF...' }, @@ -709,7 +97,6 @@ const BrokerManagement = () => { { id: 9, name: 'MarketAxess', apiId: '88234', broker: 'Meta5', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$150.25', onOff: true, secretKey: 'sk-78PqrStu...' }, { id: 10, name: 'Tradeweb Markets', apiId: '89245', broker: 'Dhan', dateAdded: 'Mar 01, 2025', status: 'inactive', balance: '$175.50', onOff: true, secretKey: 'sk-98VwxYza...' }, ]); - const handleAddBroker = () => { setEditingBroker(null); setFormData({ @@ -726,7 +113,6 @@ const BrokerManagement = () => { setShowAddPanel(true); setShowEditPanel(false); }; - const handleEditBroker = (broker) => { setEditingBroker(broker); setFormData({ ...broker }); @@ -734,19 +120,16 @@ const BrokerManagement = () => { setShowAddPanel(false); setShowEditPanel(true); }; - const handleDeleteBroker = (id) => { if (window.confirm('Are you sure you want to delete this broker?')) { setBrokers(brokers.filter(b => b.id !== id)); } }; - const handleSaveBroker = () => { if (!formData.name || !formData.apiId || !formData.broker) { alert('Please fill in all required fields'); return; } - if (editingBroker) { setBrokers(brokers.map(b => b.id === editingBroker.id ? { ...formData, id: editingBroker.id } : b)); } else { @@ -760,35 +143,28 @@ const BrokerManagement = () => { setShowAddPanel(false); setShowEditPanel(false); }; - const handleToggle = (id) => { const updated = brokers.map(b => b.id === id ? { ...b, onOff: !b.onOff } : b ); setBrokers(updated); }; - const filteredBrokers = brokers.filter(broker => { const matchesSearch = broker.name.toLowerCase().includes(searchTerm.toLowerCase()) || broker.broker.toLowerCase().includes(searchTerm.toLowerCase()) || - broker.apiId.includes(searchTerm); - - const matchesStatus = filterStatus === 'All' || broker.status.toLowerCase() === filterStatus.toLowerCase(); - + broker.apiId.includes(searchTerm); + const matchesStatus = filterStatus === 'All' || broker.status.toLowerCase() === filterStatus.toLowerCase(); return matchesSearch && matchesStatus; }); - const groupedBrokers = filteredBrokers.reduce((acc, broker) => { const key = `${broker.status}-${broker.onOff ? 'on' : 'off'}`; if (!acc[key]) acc[key] = []; acc[key].push(broker); return acc; }, {}); - const mainTabs = ['Dashboard', 'Brokers', 'Scan & Trade', 'Positions', 'AI Strategy Builder']; const subTabs = ['API Management', 'Risk Management', 'Hook Hub']; const statusFilters = ['All', 'Active', 'Inactive', 'Expired']; - return ( <> - + `}
@@ -833,7 +208,6 @@ const BrokerManagement = () => {
-

Brokers / API Management

@@ -852,7 +226,6 @@ const BrokerManagement = () => { ))}
-
{
-
@@ -956,7 +328,6 @@ const BrokerManagement = () => {
-
Last Synced: May 26, 2025 12:30
@@ -965,7 +336,6 @@ const BrokerManagement = () => {
- { @@ -988,7 +358,6 @@ const BrokerManagement = () => { className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" />
-
-

API Details

@@ -1028,7 +396,6 @@ const BrokerManagement = () => { />

Date Created: {formData.dateAdded}

-
-
-
- { @@ -1114,7 +478,6 @@ const BrokerManagement = () => { className="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500" /> -
-

API Details

@@ -1139,7 +501,6 @@ const BrokerManagement = () => { Help me connect to the API
-
-
-
-
-