Improved modurality:refer README.md for details

This commit is contained in:
23CABSHIYAMR 2025-10-04 15:42:58 +05:30
parent b4545632fc
commit f5aeaa54d1
32 changed files with 891 additions and 535 deletions

0
broker.js Normal file
View File

View File

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@ -1 +0,0 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

Before

Width:  |  Height:  |  Size: 391 B

View File

@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 128 B

View File

@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

Before

Width:  |  Height:  |  Size: 385 B

View File

@ -1,364 +1,7 @@
'use client';
import React, { useState } from 'react';
import { X, Plus, Edit2, Copy, Trash2, MoreVertical, Search, Filter } from 'lucide-react';
import BrokerManagement from '@/components/brokers/BrokerManagement';
export default function BrokerManagement() {
const [brokers, setBrokers] = useState([
{ id: 'BR301', name: 'Techbonds Markets', broker: 'Masak', dateAdded: 'Feb 16, 2025', status: 'active', balance: '$978.50', apiKey: 'api_key_123456789abcdef', secretKey: 'sk_412345LH...', dateCreated: '04/12/2025' },
{ id: 'BR295', name: 'Techbonds Markets', broker: 'AngelOne', dateAdded: 'Mar 02, 2025', status: 'expired', balance: '$978.50', apiKey: 'api_key_987654321fedcba', secretKey: 'sk_987654LH...', dateCreated: '03/02/2025' },
{ id: 'BR298', name: 'MarketEases', broker: 'Masak', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$102.25', apiKey: 'api_key_111222333444555', secretKey: 'sk_111222LH...', dateCreated: '02/14/2025' },
{ id: 'BR293', name: 'Techbonds Markets', broker: 'Zerodha', dateAdded: 'Mar 03, 2025', status: 'inactive', balance: '$978.50', apiKey: 'api_key_555444333222111', secretKey: 'sk_555444LH...', dateCreated: '03/03/2025' },
{ id: 'BR297', name: 'Techbonds Markets', broker: 'Dhan', dateAdded: 'Feb 14, 2025', status: 'active', balance: '$102.25', apiKey: 'api_key_666777888999000', secretKey: 'sk_666777LH...', dateCreated: '02/14/2025' },
{ id: 'BR292', name: 'Techbonds Markets', broker: 'AngelOne', dateAdded: 'Mar 02, 2025', status: 'inactive', balance: '$978.50', apiKey: 'api_key_000999888777666', secretKey: 'sk_000999LH...', dateCreated: '03/02/2025' },
]);
const [isSlideOpen, setIsSlideOpen] = useState(false);
const [slideMode, setSlideMode] = useState('add');
const [selectedBroker, setSelectedBroker] = useState(null);
const [searchTerm, setSearchTerm] = useState('');
const [filterStatus, setFilterStatus] = useState('all');
const [formData, setFormData] = useState({
name: '',
broker: '',
apiKey: '',
secretKey: '',
});
const handleAdd = () => {
setSlideMode('add');
setFormData({ name: '', broker: '', apiKey: '', secretKey: '' });
setIsSlideOpen(true);
};
const handleEdit = (broker) => {
setSlideMode('edit');
setSelectedBroker(broker);
setFormData({
name: broker.name,
broker: broker.broker,
apiKey: broker.apiKey,
secretKey: broker.secretKey,
});
setIsSlideOpen(true);
};
const handleSubmit = () => {
if (slideMode === 'add') {
const newBroker = {
id: `BR${Math.floor(Math.random() * 1000)}`,
name: formData.name,
broker: formData.broker,
dateAdded: new Date().toLocaleDateString('en-US', { month: 'short', day: '2-digit', year: 'numeric' }),
status: 'active',
balance: '$0.00',
apiKey: formData.apiKey,
secretKey: formData.secretKey,
dateCreated: new Date().toLocaleDateString('en-US'),
};
setBrokers([...brokers, newBroker]);
} else if (selectedBroker) {
setBrokers(brokers.map(b =>
b.id === selectedBroker.id
? { ...b, name: formData.name, broker: formData.broker, apiKey: formData.apiKey, secretKey: formData.secretKey }
: b
));
}
setIsSlideOpen(false);
};
const handleDelete = (id) => {
setBrokers(brokers.filter(b => b.id !== id));
};
const toggleStatus = (id) => {
setBrokers(brokers.map(b =>
b.id === id
? { ...b, status: b.status === 'active' ? 'inactive' : 'active' }
: b
));
};
const filteredBrokers = brokers.filter(broker => {
const matchesSearch = broker.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
broker.broker.toLowerCase().includes(searchTerm.toLowerCase());
const matchesFilter = filterStatus === 'all' || broker.status === filterStatus;
return matchesSearch && matchesFilter;
});
return (
<div className="min-h-screen bg-gray-50 p-6">
{/* Header Section */}
<div className="mb-6">
<div className="flex items-center justify-between mb-4">
<h1 className="text-2xl font-bold text-gray-900">Brokers / API Management</h1>
<button
onClick={handleAdd}
className="flex items-center gap-2 bg-teal-500 hover:bg-teal-600 text-white px-4 py-2 rounded-lg transition-colors"
>
<Plus size={20} />
Add Broker
</button>
</div>
{/* Filters and Search */}
<div className="flex items-center gap-4">
<div className="flex-1 relative">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" size={20} />
<input
type="text"
placeholder="Search..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
</div>
<button className="flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50">
<Filter size={20} />
Filters
</button>
<div className="flex gap-2">
<button
onClick={() => setFilterStatus('all')}
className={`px-4 py-2 rounded-lg ${filterStatus === 'all' ? 'bg-gray-200' : 'bg-white border border-gray-300'}`}
>
Active
</button>
<button
onClick={() => setFilterStatus('inactive')}
className={`px-4 py-2 rounded-lg ${filterStatus === 'inactive' ? 'bg-gray-200' : 'bg-white border border-gray-300'}`}
>
Inactive
</button>
<button
onClick={() => setFilterStatus('expired')}
className={`px-4 py-2 rounded-lg ${filterStatus === 'expired' ? 'bg-gray-200' : 'bg-white border border-gray-300'}`}
>
Expired
</button>
</div>
</div>
</div>
{/* Table */}
<div className="bg-white rounded-lg shadow overflow-hidden">
<table className="w-full">
<thead className="bg-gray-50 border-b border-gray-200">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">API ID</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Broker</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date Added</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Balance</th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider"></th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider"></th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider"></th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">On/Off</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{filteredBrokers.map((broker) => (
<tr key={broker.id} className="hover:bg-gray-50">
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">{broker.name}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{broker.id}</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center gap-2">
<div className="w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center text-white text-xs">
{broker.broker.charAt(0)}
</div>
<span className="text-sm text-gray-900">{broker.broker}</span>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{broker.dateAdded}</td>
<td className="px-6 py-4 whitespace-nowrap">
<span className={`inline-flex items-center w-2.5 h-2.5 rounded-full ${
broker.status === 'active' ? 'bg-green-500' :
broker.status === 'expired' ? 'bg-red-500' :
'bg-yellow-500'
}`}></span>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{broker.balance}</td>
<td className="px-4 py-4 whitespace-nowrap text-center">
<button className="p-1.5 hover:bg-gray-100 rounded text-gray-600" title="Info">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="16" x2="12" y2="12"/>
<line x1="12" y1="8" x2="12.01" y2="8"/>
</svg>
</button>
</td>
<td className="px-4 py-4 whitespace-nowrap text-center">
<button
onClick={() => handleEdit(broker)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Edit"
>
<Edit2 size={18} />
</button>
</td>
<td className="px-4 py-4 whitespace-nowrap text-center">
<button
onClick={() => handleDelete(broker.id)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Delete"
>
<Trash2 size={18} />
</button>
</td>
<td className="px-6 py-4 whitespace-nowrap text-center">
<button
onClick={() => toggleStatus(broker.id)}
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
broker.status === 'active' ? 'bg-teal-500' : 'bg-gray-300'
}`}
>
<span
className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${
broker.status === 'active' ? 'translate-x-6' : 'translate-x-1'
}`}
/>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
{/* Slide-in Panel */}
{isSlideOpen && (
<>
{/* Overlay */}
<div
className="fixed inset-0 bg-gray-300 bg-opacity-80 z-40"
onClick={() => setIsSlideOpen(false)}
></div>
{/* Slide Panel */}
<div className="fixed right-0 top-0 h-full w-96 bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out">
<div className="flex flex-col h-full">
{/* Header */}
<div className="flex items-center justify-between p-6 border-b">
<h2 className="text-xl font-semibold text-gray-900">
{slideMode === 'add' ? 'Add Broker' : 'Edit Broker'}
</h2>
<button
onClick={() => setIsSlideOpen(false)}
className="p-2 hover:bg-gray-100 rounded-lg"
>
<X size={20} />
</button>
</div>
{/* Content */}
<div className="flex-1 overflow-y-auto p-6">
<p className="text-sm text-gray-500 mb-6">
Choose your preferred exchange to add a broker.
</p>
{/* Broker Details */}
<div className="space-y-4 mb-6">
<h3 className="font-semibold text-gray-900">Broker Details</h3>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Name*
</label>
<input
type="text"
placeholder="Enter a Name"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Select Broker
</label>
<select
value={formData.broker}
onChange={(e) => setFormData({ ...formData, broker: e.target.value })}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
>
<option value="">Select Broker</option>
<option value="Masak">Masak</option>
<option value="AngelOne">AngelOne</option>
<option value="Zerodha">Zerodha</option>
<option value="Dhan">Dhan</option>
</select>
</div>
</div>
{/* API Details */}
<div className="space-y-4">
<div className="flex items-center justify-between">
<h3 className="font-semibold text-gray-900">API Details</h3>
{slideMode === 'edit' && (
<button className="text-sm text-teal-500 hover:text-teal-600">
Update Key 🔄
</button>
)}
{slideMode === 'add' && (
<button className="text-sm text-teal-500 hover:text-teal-600">
Help me connect to API
</button>
)}
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
API Key
</label>
<input
type="text"
placeholder="api_key_1234567890abcdef"
value={formData.apiKey}
onChange={(e) => setFormData({ ...formData, apiKey: e.target.value })}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
{slideMode === 'edit' && selectedBroker && (
<p className="text-xs text-gray-500 mt-1">Date Created: {selectedBroker.dateCreated}</p>
)}
</div>
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
Secret API Key
</label>
<input
type="password"
placeholder="sk_412345LH..."
value={formData.secretKey}
onChange={(e) => setFormData({ ...formData, secretKey: e.target.value })}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
</div>
</div>
</div>
{/* Footer */}
<div className="p-6 border-t flex gap-3">
<button
onClick={() => setIsSlideOpen(false)}
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors"
>
Cancel
</button>
<button
onClick={handleSubmit}
className="flex-1 px-4 py-2 bg-teal-500 hover:bg-teal-600 text-white rounded-lg transition-colors"
>
{slideMode === 'add' ? 'Add' : 'Save'}
</button>
</div>
</div>
</div>
</>
)}
</div>
);
export default function BrokersPage() {
return <BrokerManagement />;
}

View File

@ -1,32 +0,0 @@
"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { motion } from "framer-motion";
export default function NavList({ list_items }) {
const pathname = usePathname();
return (
<nav className="h-fit relative grid items-center ">
<ul className="flex space-x-6 relative">
{list_items.map((item, index) => {
const isActive = pathname === item.routeLink;
return (
<li key={index} className="relative">
<Link href={item.routeLink} className={`${isActive && "text-blue-500"}`}>
{item.name}
</Link>
{isActive && (
<motion.div
layoutId="header-underline"
className="absolute -bottom-5 left-0 right-0 h-[3px] bg-blue-500 rounded"
/>
)}
</li>
);
})}
</ul>
</nav>
);
}

View File

@ -1,27 +0,0 @@
export const BROKER_OPTIONS = ['Masak', 'AngelOne', 'Zerodha', 'Dhan'];
export const STATUS_TYPES = {
ACTIVE: 'active',
INACTIVE: 'inactive',
EXPIRED: 'expired',
};
export const STATUS_COLORS = {
[STATUS_TYPES.ACTIVE]: 'bg-green-500',
[STATUS_TYPES.EXPIRED]: 'bg-red-500',
[STATUS_TYPES.INACTIVE]: 'bg-yellow-500',
};
export const INITIAL_BROKERS = [
{
id: 'BR301',
name: 'Techbonds Markets',
broker: 'Masak',
dateAdded: 'Feb 16, 2025',
status: 'active',
balance: '$978.50',
apiKey: 'api_key_123456789abcdef',
secretKey: 'sk_412345LH...',
dateCreated: '04/12/2025',
},
];

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,87 +1,5 @@
@import "tailwindcss";
@theme {
/* Gray */
--color-gray-50: #f9fafb;
--color-gray-100: #f3f4f6;
--color-gray-200: #e5e7eb;
--color-gray-300: #d1d5db;
--color-gray-400: #9ca3af;
--color-gray-500: #6b7280;
--color-gray-600: #4b5563;
--color-gray-700: #374151;
--color-gray-800: #1f2937;
--color-gray-900: #111827;
/* Red */
--color-red-50: #fef2f2;
--color-red-100: #fee2e2;
--color-red-200: #fecaca;
--color-red-300: #fca5a5;
--color-red-400: #f87171;
--color-red-500: #ef4444;
--color-red-600: #dc2626;
--color-red-700: #b91c1c;
--color-red-800: #991b1b;
--color-red-900: #7f1d1d;
/* Green */
--color-green-50: #f0fdf4;
--color-green-100: #dcfce7;
--color-green-200: #bbf7d0;
--color-green-300: #86efac;
--color-green-400: #4ade80;
--color-green-500: #22c55e;
--color-green-600: #16a34a;
--color-green-700: #15803d;
--color-green-800: #166534;
--color-green-900: #14532d;
/* Blue */
--color-blue-50: #eff6ff;
--color-blue-100: #dbeafe;
--color-blue-200: #bfdbfe;
--color-blue-300: #93c5fd;
--color-blue-400: #60a5fa;
--color-blue-500: #3b82f6;
--color-blue-600: #2563eb;
--color-blue-700: #1d4ed8;
--color-blue-800: #1e40af;
--color-blue-900: #1e3a8a;
/* Yellow */
--color-yellow-50: #fefce8;
--color-yellow-100: #fef9c3;
--color-yellow-200: #fef08a;
--color-yellow-300: #fde047;
--color-yellow-400: #facc15;
--color-yellow-500: #eab308;
--color-yellow-600: #ca8a04;
--color-yellow-700: #a16207;
--color-yellow-800: #854d0e;
--color-yellow-900: #713f12;
/* Purple */
--color-purple-50: #faf5ff;
--color-purple-100: #f3e8ff;
--color-purple-200: #e9d5ff;
--color-purple-300: #d8b4fe;
--color-purple-400: #c084fc;
--color-purple-500: #a855f7;
--color-purple-600: #9333ea;
--color-purple-700: #7e22ce;
--color-purple-800: #6b21a8;
--color-purple-900: #581c87;
/* Orange */
--color-orange-50: #fff7ed;
--color-orange-100: #ffedd5;
--color-orange-200: #fed7aa;
--color-orange-300: #fdba74;
--color-orange-400: #fb923c;
--color-orange-500: #f97316;
--color-orange-600: #ea580c;
--color-orange-700: #c2410c;
--color-orange-800: #9a3412;
--color-orange-900: #7c2d12;
}

View File

@ -1,6 +1,6 @@
import "./globals.css";
import { Geist, Geist_Mono } from "next/font/google";
import Header from "./layouts/Header";
import Header from "../layouts/Header";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],

View File

@ -1,27 +0,0 @@
import NavList from "../components/NavList";
import Image from "next/image";
import logo from '../assets/HookNestLogo.png'
export default function Header(){
const list_items=[
{id:1,name:"Dashboard",routeLink:"/"},
{id:2,name:"Brokers",routeLink:"/Brokers"},
{id:3,name:"Scan & Tracks",routeLink:"/Scan_Tracks"},
{id:4,name:"Positions",routeLink:"/Positions"},
{id:5,name:"AI Strategy Builder",routeLink:"/AIStrategyBuilder"},
]
return (
<div className="relative flex justify-between items-center bg-gray-300 p-2 rounded-4xl">
<Image
src={logo}
alt="App Logo"
width={130}
height={100}
className="rounded-4xl"
/>
<NavList list_items={list_items}/>
<div>Icons</div>
</div>
)
}

View File

@ -0,0 +1,12 @@
'use client';
export default function BrokerAvatar({ brokerName }) {
return (
<div className="flex items-center gap-2">
<div className="w-6 h-6 bg-blue-500 rounded-full flex items-center justify-center text-white text-xs">
{brokerName.charAt(0)}
</div>
<span className="text-sm text-gray-900">{brokerName}</span>
</div>
);
}

View File

@ -0,0 +1,86 @@
'use client';
import FormInput from '@/components/ui/FormInput';
import FormSelect from '@/components/ui/FormSelect';
import { BROKER_OPTIONS, STATUS_OPTIONS } from '@/constants/brokers';
export default function BrokerForm({ formData, onChange, mode, selectedBroker }) {
return (
<>
<p className="text-sm text-gray-500 mb-6">
Choose your preferred exchange to add a broker.
</p>
<div className="space-y-4 mb-6">
<h3 className="font-semibold text-gray-900">Broker Details</h3>
<FormInput
label="Name"
value={formData.name}
onChange={(val) => onChange({ ...formData, name: val })}
placeholder="Enter a Name"
required
/>
<FormSelect
label="Select Broker"
value={formData.broker}
onChange={(val) => onChange({ ...formData, broker: val })}
options={BROKER_OPTIONS}
placeholder="Select Broker"
/>
<FormInput
label="Balance"
value={formData.balance}
onChange={(val) => onChange({ ...formData, balance: val })}
placeholder="$0.00"
type="text"
/>
<FormSelect
label="Status"
value={formData.status}
onChange={(val) => onChange({ ...formData, status: val })}
options={STATUS_OPTIONS}
placeholder="Select Status"
/>
</div>
<div className="space-y-4">
<div className="flex items-center justify-between">
<h3 className="font-semibold text-gray-900">API Details</h3>
{mode === 'edit' ? (
<button className="text-sm text-teal-500 hover:text-teal-600">
Update Key 🔄
</button>
) : (
<button className="text-sm text-teal-500 hover:text-teal-600">
Help me connect to API
</button>
)}
</div>
<FormInput
label="API Key"
value={formData.apiKey}
onChange={(val) => onChange({ ...formData, apiKey: val })}
placeholder="api_key_1234567890abcdef"
helperText={
mode === 'edit' && selectedBroker
? `Date Created: ${selectedBroker.dateCreated}`
: ''
}
/>
<FormInput
label="Secret API Key"
value={formData.secretKey}
onChange={(val) => onChange({ ...formData, secretKey: val })}
placeholder="sk_412345LH..."
type="password"
/>
</div>
</>
);
}

View File

@ -0,0 +1,224 @@
"use client";
import { useState } from "react";
import BrokerTable from "./BrokerTable";
import SearchBar from "./SearchBar";
import StatusFilter from "./StatusFilter";
import SlidePanel from "@/components/ui/SlidePanel";
import BrokerForm from "./BrokerForm";
import { Plus, Download, SlidersHorizontal } from "lucide-react";
import { filterBrokers, createNewBroker } from "@/utils/brokerHelpers";
import { INITIAL_BROKERS } from "@/constants/brokers";
export default function BrokerManagement() {
// Broker state
const [brokers, setBrokers] = useState(INITIAL_BROKERS);
// Slide panel state
const [isSlideOpen, setIsSlideOpen] = useState(false);
const [slideMode, setSlideMode] = useState("add");
const [selectedBroker, setSelectedBroker] = useState(null);
// Filter state - default to 'active'
const [searchTerm, setSearchTerm] = useState("");
const [filterStatus, setFilterStatus] = useState("active");
// Hidden rows state
const [hiddenRows, setHiddenRows] = useState([]);
// Form state
const [formData, setFormData] = useState({
name: "",
broker: "",
apiKey: "",
secretKey: "",
balance: "$0.00",
status: "active",
});
// Event handlers
const handleAdd = () => {
setSlideMode("add");
setFormData({
name: "",
broker: "",
apiKey: "",
secretKey: "",
balance: "$0.00",
status: "active",
});
setIsSlideOpen(true);
};
const handleEdit = (broker) => {
setSlideMode("edit");
setSelectedBroker(broker);
setFormData({
name: broker.name,
broker: broker.broker,
apiKey: broker.apiKey,
secretKey: broker.secretKey,
balance: broker.balance,
status: broker.status,
});
setIsSlideOpen(true);
};
const handleSubmit = () => {
if (slideMode === "add") {
const newBroker = {
...createNewBroker(formData),
balance: formData.balance,
status: formData.status,
};
setBrokers([...brokers, newBroker]);
} else if (selectedBroker) {
setBrokers(
brokers.map((b) =>
b.id === selectedBroker.id
? {
...b,
name: formData.name,
broker: formData.broker,
apiKey: formData.apiKey,
secretKey: formData.secretKey,
balance: formData.balance,
status: formData.status,
}
: b
)
);
}
setIsSlideOpen(false);
};
const handleDelete = (id) => {
setBrokers(brokers.filter((b) => b.id !== id));
setHiddenRows(hiddenRows.filter((rowId) => rowId !== id));
};
const toggleStatus = (id) => {
setBrokers(
brokers.map((b) =>
b.id === id
? { ...b, status: b.status === "active" ? "inactive" : "active" }
: b
)
);
};
const toggleVisibility = (id) => {
setHiddenRows((prev) =>
prev.includes(id) ? prev.filter((rowId) => rowId !== id) : [...prev, id]
);
};
const handleExportCSV = () => {
// CSV export logic
const headers = [
"Name",
"API ID",
"Broker",
"Date Added",
"Status",
"Balance",
];
const csvContent = [
headers.join(","),
...filteredBrokers.map((b) =>
[b.name, b.id, b.broker, b.dateAdded, b.status, b.balance].join(",")
),
].join("\n");
const blob = new Blob([csvContent], { type: "text/csv" });
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "brokers.csv";
a.click();
};
// Filter brokers
const filteredBrokers = filterBrokers(brokers, searchTerm, filterStatus);
return (
<div className="min-h-screen p-2">
{/* Header */}
<div className="mb-6">
<div className="flex items-center justify-between mb-3">
<div>
<h1 className="text-2xl font-bold text-gray-900 mb-1">
Brokers / API Management
</h1>
</div>
<div className="flex items-center gap-3"></div>
</div>
<div className="bg-gray-50 p-2">
{/* Filters */}
<div className="flex gap-2 justify-between">
<div className="flex gap-2">
<SearchBar searchTerm={searchTerm} onSearchChange={setSearchTerm} />
<button className="w-fit flex items-center gap-2 px-4 py-2 bg-white border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors text-sm font-medium">
<SlidersHorizontal size={18} />
Filters
</button>
</div>
<StatusFilter
activeFilter={filterStatus}
onFilterChange={setFilterStatus}
/>
<div className="flex items-center gap-3">
<button
onClick={handleExportCSV}
className="flex items-center gap-2 bg-white border border-gray-300 text-gray-700 px-4 py-2.5 rounded-lg hover:bg-gray-50 transition-colors text-sm font-medium"
>
<Download size={18} />
Export CSV
</button>
<button
onClick={handleAdd}
className="flex items-center gap-2 bg-teal-500 hover:bg-teal-600 text-white px-5 py-2.5 rounded-lg transition-colors text-sm font-medium shadow-sm"
>
<Plus size={18} />
Add Broker
</button>
</div>
</div>
</div>
{/* Table */}
<BrokerTable
brokers={filteredBrokers}
onEdit={handleEdit}
onDelete={handleDelete}
onToggleStatus={toggleStatus}
onToggleVisibility={toggleVisibility}
hiddenRows={hiddenRows}
/>
{/* Slide Panel */}
<SlidePanel
isOpen={isSlideOpen}
onClose={() => setIsSlideOpen(false)}
title={slideMode === "add" ? "Add Broker" : "Edit Broker"}
onSubmit={handleSubmit}
onCancel={() => setIsSlideOpen(false)}
submitLabel={slideMode === "add" ? "Add" : "Save"}
>
<BrokerForm
formData={formData}
onChange={setFormData}
mode={slideMode}
selectedBroker={selectedBroker}
/>
</SlidePanel>
</div>
</div>
);
}

View File

@ -0,0 +1,54 @@
'use client';
import TableRow from './TableRow';
export default function BrokerTable({ brokers, onEdit, onDelete, onToggleStatus, onToggleVisibility, hiddenRows }) {
return (
<div className="bg-white rounded-lg shadow overflow-hidden">
<table className="w-full pt-5">
<thead className="bg-gray-50 border-b border-gray-200">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Name
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
API ID
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Broker
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Date Added
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Balance
</th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">
Actions
</th>
<th className="px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider">
On/Off
</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{brokers.map((broker,index) => (
<TableRow
key={broker.id}
index={index}
broker={broker}
onEdit={onEdit}
onDelete={onDelete}
onToggleStatus={onToggleStatus}
onToggleVisibility={onToggleVisibility}
isHidden={hiddenRows.includes(broker.id)}
/>
))}
</tbody>
</table>
</div>
);
}

View File

@ -0,0 +1,21 @@
'use client';
import { Search } from 'lucide-react';
export default function SearchBar({ searchTerm, onSearchChange }) {
return (
<div className="flex-1 relative">
<Search
className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"
size={10}
/>
<input
type="text"
placeholder="Search..."
value={searchTerm}
onChange={(e) => onSearchChange(e.target.value)}
className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
</div>
);
}

View File

@ -0,0 +1,36 @@
'use client';
import { Filter } from 'lucide-react';
export default function StatusFilter({ activeFilter, onFilterChange }) {
const filters = [
{ value: 'all', label: 'All' },
{ value: 'active', label: 'Active' },
{ value: 'inactive', label: 'Inactive' },
{ value: 'expired', label: 'Expired' }
];
return (
<>
{/* <button className="flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50">
<Filter size={20} />
Filters
</button> */}
<div className="flex gap-2">
{filters.map((filter) => (
<button
key={filter.value}
onClick={() => onFilterChange(filter.value)}
className={`px-4 py-2 rounded-lg ${
activeFilter !== filter.value
? 'bg-gray-200'
: 'bg-white border border-blue-300'
}`}
>
{filter.label}
</button>
))}
</div>
</>
);
}

View File

@ -0,0 +1,11 @@
'use client';
import { STATUS_COLORS } from '@/constants/brokers';
export default function StatusIndicator({ status }) {
return (
<span
className={`inline-flex items-center w-2.5 h-2.5 rounded-full ${STATUS_COLORS[status]}`}
/>
);
}

View File

@ -0,0 +1,64 @@
'use client';
import { Edit2, Trash2, Eye, EyeOff } from 'lucide-react';
import BrokerAvatar from './BrokerAvatar';
import StatusIndicator from './StatusIndicator';
import ToggleSwitch from '@/components/ui/ToggleSwitch';
export default function TableRow({ index,broker, onEdit, onDelete, onToggleStatus, onToggleVisibility, isHidden }) {
if (isHidden) return null;
return (
<tr className={index%2!==0?"bg-gray-100 hover:bg-gray-50":"hover:bg-gray-50"}>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{broker.name}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{broker.id}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<BrokerAvatar brokerName={broker.broker} />
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{broker.dateAdded}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<StatusIndicator status={broker.status} />
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-green-500">
{broker.balance}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center justify-center gap-2">
<button
onClick={() => onToggleVisibility(broker.id)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title={isHidden ? "Show" : "Hide"}
>
{isHidden ? <EyeOff size={18} /> : <Eye size={18} />}
</button>
<button
onClick={() => onEdit(broker)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Edit"
>
<Edit2 size={18} />
</button>
<button
onClick={() => onDelete(broker.id)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Delete"
>
<Trash2 size={18} />
</button>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-center">
<ToggleSwitch
isActive={broker.status === 'active'}
onToggle={() => onToggleStatus(broker.id)}
/>
</td>
</tr>
);
}

View File

View File

@ -0,0 +1,29 @@
'use client';
export default function FormInput({
label,
value,
onChange,
placeholder,
type = "text",
required = false,
helperText
}) {
return (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
{label}{required && '*'}
</label>
<input
type={type}
placeholder={placeholder}
value={value}
onChange={(e) => onChange(e.target.value)}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
/>
{helperText && (
<p className="text-xs text-gray-500 mt-1">{helperText}</p>
)}
</div>
);
}

View File

@ -0,0 +1,23 @@
'use client';
export default function FormSelect({ label, value, onChange, options, placeholder }) {
return (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
{label}
</label>
<select
value={value}
onChange={(e) => onChange(e.target.value)}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-500"
>
<option value="">{placeholder}</option>
{options.map((option) => (
<option key={option} value={option}>
{option}
</option>
))}
</select>
</div>
);
}

View File

@ -0,0 +1,57 @@
'use client';
import { X } from 'lucide-react';
export default function SlidePanel({
isOpen,
onClose,
title,
children,
onSubmit,
submitLabel,
onCancel
}) {
if (!isOpen) return null;
return (
<>
<div
className="fixed inset-0 bg-black bg-opacity-50 z-40"
onClick={onClose}
/>
<div className="fixed right-0 top-0 h-full w-96 bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out">
<div className="flex flex-col h-full">
<div className="flex items-center justify-between p-6 border-b">
<h2 className="text-xl font-semibold text-gray-900">{title}</h2>
<button
onClick={onClose}
className="p-2 hover:bg-gray-100 rounded-lg"
>
<X size={20} />
</button>
</div>
<div className="flex-1 overflow-y-auto p-6">
{children}
</div>
<div className="p-6 border-t flex gap-3">
<button
onClick={onCancel}
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors"
>
Cancel
</button>
<button
onClick={onSubmit}
className="flex-1 px-4 py-2 bg-teal-500 hover:bg-teal-600 text-white rounded-lg transition-colors"
>
{submitLabel}
</button>
</div>
</div>
</div>
</>
);
}

View File

@ -0,0 +1,18 @@
'use client';
export default function ToggleSwitch({ isActive, onToggle }) {
return (
<button
onClick={onToggle}
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
isActive ? 'bg-teal-500' : 'bg-gray-300'
}`}
>
<span
className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${
isActive ? 'translate-x-6' : 'translate-x-1'
}`}
/>
</button>
);
}

84
src/constants/brokers.js Normal file
View File

@ -0,0 +1,84 @@
export const BROKER_OPTIONS = ['Masak', 'AngelOne', 'Zerodha', 'Dhan'];
export const STATUS_OPTIONS = ['active', 'inactive', 'expired'];
export const STATUS_TYPES = {
ACTIVE: 'active',
INACTIVE: 'inactive',
EXPIRED: 'expired',
};
export const STATUS_COLORS = {
[STATUS_TYPES.ACTIVE]: 'bg-green-500',
[STATUS_TYPES.EXPIRED]: 'bg-red-500',
[STATUS_TYPES.INACTIVE]: 'bg-yellow-500',
};
export const INITIAL_BROKERS = [
{
id: 'BR301',
name: 'Techbonds Markets',
broker: 'Masak',
dateAdded: 'Feb 16, 2025',
status: 'active',
balance: '$978.50',
apiKey: 'api_key_123456789abcdef',
secretKey: 'sk_412345LH...',
dateCreated: '04/12/2025',
},
{
id: 'BR295',
name: 'Techbonds Markets',
broker: 'AngelOne',
dateAdded: 'Mar 02, 2025',
status: 'expired',
balance: '$978.50',
apiKey: 'api_key_987654321fedcba',
secretKey: 'sk_987654LH...',
dateCreated: '03/02/2025',
},
{
id: 'BR298',
name: 'MarketEases',
broker: 'Masak',
dateAdded: 'Feb 14, 2025',
status: 'active',
balance: '$102.25',
apiKey: 'api_key_111222333444555',
secretKey: 'sk_111222LH...',
dateCreated: '02/14/2025',
},
{
id: 'BR293',
name: 'Techbonds Markets',
broker: 'Zerodha',
dateAdded: 'Mar 03, 2025',
status: 'inactive',
balance: '$978.50',
apiKey: 'api_key_555444333222111',
secretKey: 'sk_555444LH...',
dateCreated: '03/03/2025',
},
{
id: 'BR297',
name: 'Techbonds Markets',
broker: 'Dhan',
dateAdded: 'Feb 14, 2025',
status: 'active',
balance: '$102.25',
apiKey: 'api_key_666777888999000',
secretKey: 'sk_666777LH...',
dateCreated: '02/14/2025',
},
{
id: 'BR292',
name: 'Techbonds Markets',
broker: 'AngelOne',
dateAdded: 'Mar 02, 2025',
status: 'inactive',
balance: '$978.50',
apiKey: 'api_key_000999888777666',
secretKey: 'sk_000999LH...',
dateCreated: '03/02/2025',
},
];

41
src/hooks/useBroker.js Normal file
View File

@ -0,0 +1,41 @@
'use client';
import { useState } from 'react';
import { INITIAL_BROKERS } from '@/constants/brokers';
import {
createNewBroker,
updateBrokerData
} from '@/utils/brokerHelpers';
export function useBrokers() {
const [brokers, setBrokers] = useState(INITIAL_BROKERS);
const addBroker = (formData) => {
const newBroker = createNewBroker(formData);
setBrokers(prev => [...prev, newBroker]);
};
const updateBroker = (brokerId, formData) => {
setBrokers(prev => updateBrokerData(prev, brokerId, formData));
};
const deleteBroker = (id) => {
setBrokers(prev => prev.filter(b => b.id !== id));
};
const toggleBrokerStatus = (id) => {
setBrokers(prev => prev.map(b =>
b.id === id
? { ...b, status: b.status === 'active' ? 'inactive' : 'active' }
: b
));
};
return {
brokers,
addBroker,
updateBroker,
deleteBroker,
toggleBrokerStatus,
};
}

38
src/layouts/Header.js Normal file
View File

@ -0,0 +1,38 @@
'use client';
import NavList from "./NavList";
import { Bell, User } from 'lucide-react';
export default function Header() {
const list_items = [
{ id: 1, name: "Dashboard", routeLink: "/" },
{ id: 2, name: "Brokers", routeLink: "/Brokers" },
{ id: 3, name: "Scan & Tracks", routeLink: "/Scan_Tracks" },
{ id: 4, name: "Positions", routeLink: "/Positions" },
{ id: 5, name: "AI Strategy Builder", routeLink: "/AIStrategyBuilder" },
];
return (
<div className="bg-gray-100 rounded-[2rem] mx-2 mt-2">
<div className="flex justify-between items-center px-6 py-3">
<div className="flex items-center gap-2">
<div className="w-10 h-10 bg-gradient-to-br from-blue-500 to-teal-500 rounded-lg flex items-center justify-center">
<span className="text-white font-bold text-lg">H</span>
</div>
<span className="font-semibold text-xl text-gray-800">HookNest</span>
</div>
<NavList list_items={list_items} />
<div className="flex items-center gap-4">
<button className="p-2 hover:bg-gray-200 rounded-lg transition-colors">
<Bell size={20} className="text-gray-600" />
</button>
<button className="p-2 hover:bg-gray-200 rounded-full transition-colors">
<User size={20} className="text-gray-600" />
</button>
</div>
</div>
</div>
);
}

40
src/layouts/NavList.js Normal file
View File

@ -0,0 +1,40 @@
'use client';
import Link from "next/link";
import { usePathname } from "next/navigation";
import { motion } from "framer-motion";
export default function NavList({ list_items }) {
const pathname = usePathname();
return (
<nav className="h-fit relative grid items-center">
<ul className="flex space-x-8 relative">
{list_items.map((item) => {
const isActive = pathname === item.routeLink;
return (
<li key={item.id} className="relative">
<Link
href={item.routeLink}
className={`text-sm font-medium transition-colors ${
isActive
? "text-teal-500"
: "text-gray-600 hover:text-gray-900"
}`}
>
{item.name}
</Link>
{isActive && (
<motion.div
layoutId="header-underline"
className="absolute -bottom-[17px] left-0 right-0 h-[3px] bg-teal-500 rounded"
/>
)}
</li>
);
})}
</ul>
</nav>
);
}

View File

@ -0,0 +1,48 @@
export function filterBrokers(brokers, searchTerm, filterStatus) {
return brokers.filter(broker => {
const matchesSearch =
broker.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
broker.broker.toLowerCase().includes(searchTerm.toLowerCase());
const matchesFilter =
filterStatus === 'all' || broker.status === filterStatus;
return matchesSearch && matchesFilter;
});
}
export function generateBrokerId() {
return `BR${Math.floor(Math.random() * 1000)}`;
}
export function createNewBroker(formData) {
return {
id: generateBrokerId(),
name: formData.name,
broker: formData.broker,
dateAdded: new Date().toLocaleDateString('en-US', {
month: 'short',
day: '2-digit',
year: 'numeric'
}),
status: 'active',
balance: '$0.00',
apiKey: formData.apiKey,
secretKey: formData.secretKey,
dateCreated: new Date().toLocaleDateString('en-US'),
};
}
export function updateBrokerData(brokers, brokerId, formData) {
return brokers.map(b =>
b.id === brokerId
? {
...b,
name: formData.name,
broker: formData.broker,
apiKey: formData.apiKey,
secretKey: formData.secretKey
}
: b
);
}