refer README.md, Commit-5

This commit is contained in:
23CABSHIYAMR 2025-10-06 22:54:41 +05:30
parent 06f87e0ead
commit d2f01c80f5
30 changed files with 829 additions and 659 deletions

View File

@ -25,11 +25,9 @@ export const metadata = {
export default function RootLayout({ children }) {
return (
<html lang="en" className={beVietnamPro.variable}>
<body>
<div className="p-5">
<body className="p-4">
<Header/>
</div>
<main className="p-6">{children}</main>
<main >{children}</main>
</body>
</html>

View File

@ -1,86 +0,0 @@
'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,77 @@
"use client";
import FormInput from "@/components/ui/FormInput";
import FormSelect from "@/components/ui/FormSelect";
import { BROKER_OPTIONS } from "@/constants/brokers";
export default function BrokerForm({
formData,
onChange,
mode,
selectedBroker,
}) {
return (
<div className="w-full space-y-6">
<div className=" w-full h-full space-y-4 border-1 border-gray-200 p-4 rounded-md">
<h3 className="text-base font-semibold text-gray-900">
Broker Details
</h3>
<FormInput
label="Name"
value={formData.name}
onChange={(val) => onChange({ ...formData, name: val })}
placeholder="Enter a Name"
className="outline-gray-200"
required
/>
<FormSelect
label="Select Broker"
value={formData.broker}
onChange={(val) => onChange({ ...formData, broker: val })}
options={BROKER_OPTIONS}
placeholder="Select Broker"
className="outline-gray-200"
/>
</div>
<div className="space-y-4 border-1 border-gray-200 p-4 rounded-md">
<div className="flex items-center justify-between">
<h3 className="text-base font-semibold text-gray-900">API Details</h3>
{mode === "edit" ? (
<button className="text-sm text-teal-500 hover:text-teal-600 flex items-center gap-1">
Update Key 🔄
</button>
) : (
<button className="text-sm text-teal-500 hover:text-teal-600 ">
Help me connect to the 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}`
: ""
}
styleEl="bg-gray-50"
/>
<FormInput
label="Secret API Key"
value={formData.secretKey}
onChange={(val) => onChange({ ...formData, secretKey: val })}
placeholder="sk_412345LH..."
type="password"
styleEl="bg-gray-50"
/>
</div>
</div>
);
}

View File

@ -1,224 +0,0 @@
"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,249 @@
"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, FilePlus2, Filter, User } from "lucide-react";
import { filterBrokers, createNewBroker } from "@/utils/brokerHelpers";
import { INITIAL_BROKERS, subPages } from "@/constants/brokers";
import { li } from "framer-motion/client";
export default function BrokerManagement() {
// Broker state
const [brokers, setBrokers] = useState(INITIAL_BROKERS);
const [activeSubPage, setSubPage] = useState(subPages[0].name);
// 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">
<div className="mb-1">
<div className="w-full flex justify-between items-center px-2">
<div className="flex gap-2 items-center">
<User
size={32}
className="text-gray-600 bg-gray-100 p-1 rounded-2xl"
/>
<h1 className="text-lg font-bold text-gray-900 mb-1">
Brokers / API Management
</h1>
</div>
<ul className="relative flex gap-8">
{subPages.map((item) => (
<li
key={item.id}
onClick={() => setSubPage(item.name)}
className={`cursor-pointer pb-4 transition-all duration-300 ${
activeSubPage === item.name
? "text-transparent bg-gradient-to-b from-[#00BFA6] to-[#144861] bg-clip-text font-semibold border-b-2 border-[#00BFA6]"
: "text-gray-600"
}`}
>
{item.name}
</li>
))}
</ul>
</div>
{/* main section */}
<div className="bg-gray-50 p-3 rounded-2xl">
{/* search row container */}
<div className="p-2 mb-2 ">
<div className="flex gap-2 justify-between">
{/* search bar and filter icon */}
<div className="w-[25%] flex gap-2">
<SearchBar
searchTerm={searchTerm}
onSearchChange={setSearchTerm}
/>
<button className="w-fit flex items-center gap-2 px-4 py-2 border border-gray-300 text-gray-700 rounded-3xl hover:bg-gray-50 transition-colors text-sm font-medium">
Filters
<Filter size={18} />
</button>
</div>
{/* active, incative and expired */}
<StatusFilter
activeFilter={filterStatus}
onFilterChange={setFilterStatus}
/>
{/* export and add button */}
<div className="flex w-[20%] items-center gap-3">
<button
onClick={handleExportCSV}
className=" w-full p-[2px] rounded-full bg-gradient-to-b from-[#00BFA6] to-[#144861] hover:from-[#144861] hover:to-[#00BFA6] transition"
>
<div className=" flex items-center justify-center gap-2 bg-white text-gray-700 px-1 py-2.5 rounded-full text-sm font-medium">
Export CSV
<FilePlus2 size={20} />
</div>
</button>
<button
onClick={handleAdd}
className=" w-full flex justify-around items-center gap-2 bg-gradient-to-b from-[#00BFA6] to-[#144861] hover:from-[#144861] hover:to-[#00BFA6] hover:bg-teal-600 text-white p-2 rounded-full transition-colors text-sm shadow-sm"
>
Add Broker
<Plus size={30} className="p-1 bg-white rounded-full text-gray-700 "/>
</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>
</div>
);
}

View File

@ -1,54 +0,0 @@
'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,184 @@
// 'use client';
// import { useState } from 'react';
// import TableRow from './TableRow';
// import {EyeOff,Eye} from 'lucide-react';
// export default function BrokerTable({ brokers, onEdit, onDelete, onToggleStatus, onToggleVisibility, hiddenRows }) {
// const [isHidden,setHidden]=useState(false);
// return (
// <div className="bg-white overflow-hidden border-1 border-gray-300 rounded-lg">
// <table className="w-full pt-5 ">
// <thead className="bg-gray-100 border-b border-gray-200">
// <tr >
// <th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
// Name
// </th>
// <th className="px-6 py-4 text-left text-xs font-bold text-gray-800 uppercase tracking-wider">
// API ID
// </th>
// <th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
// Broker
// </th>
// <th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
// Date Added
// </th>
// <th className="px-6 py-4 text-center text-xs font-bold text-gray-800 tracking-wider ">
// Status
// </th>
// <th className="flex items-center px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
// Balance
// <button
// onClick={()=>setHidden(!isHidden)}
// className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
// title={isHidden ? "Show" : "Hide"}
// >
// {isHidden ? <EyeOff size={18} /> : <Eye size={18} />}
// </button>
// </th>
// <th className="px-6 py-4 text-center text-xs font-bold text-gray-800 tracking-wider">
// Actions
// </th>
// <th className="px-6 py-4 text-center text-xs font-bold text-gray-800 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={isHidden}
// />
// ))}
// </tbody>
// </table>
// </div>
// );
// }
'use client';
import { useState } from 'react';
import TableRow from './TableRow';
import { EyeOff, Eye } from 'lucide-react';
export default function BrokerTable({
brokers,
onEdit,
onDelete,
onToggleStatus,
lastSynced = "May 26, 2025 12:30",
currentPage = 1,
totalPages = 2,
onPageChange
}) {
const [isHidden, setHidden] = useState(false);
return (
<div className="bg-white overflow-hidden border border-gray-300 rounded-lg">
<table className="w-full">
<thead className="bg-gray-100 border-b border-gray-200">
<tr>
<th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
Name
</th>
<th className="px-6 py-4 text-left text-xs font-bold text-gray-800 uppercase tracking-wider">
API ID
</th>
<th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
Broker
</th>
<th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
Date Added
</th>
<th className="px-6 py-4 text-center text-xs font-bold text-gray-800 tracking-wider">
Status
</th>
<th className="px-6 py-4 text-left text-xs font-bold text-gray-800 tracking-wider">
<div className="flex items-center gap-2">
Balance
<button
onClick={() => setHidden(!isHidden)}
className="p-1 hover:bg-gray-200 rounded text-gray-600 transition-colors"
title={isHidden ? "Show" : "Hide"}
>
{isHidden ? <EyeOff size={16} /> : <Eye size={16} />}
</button>
</div>
</th>
<th className="px-6 py-4 text-center text-xs font-bold text-gray-800 tracking-wider">
Actions
</th>
<th className="px-6 py-4 text-center text-xs font-bold text-gray-800 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}
isHidden={isHidden}
/>
))}
</tbody>
</table>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between bg-white">
<div className="text-sm text-gray-500">
Last Synced: {lastSynced}
</div>
<div className="flex items-center gap-2">
<button
onClick={() => onPageChange?.(currentPage - 1)}
disabled={currentPage === 1}
className={`px-3 py-1.5 rounded text-sm font-medium transition-colors ${
currentPage === 1
? 'bg-gray-100 text-gray-400 cursor-not-allowed opacity-0'
: 'bg-gray-200 text-gray-700 hover:bg-gray-300'
}`}
>
&lt;
</button>
{[...Array(totalPages)].map((_, i) => (
<button
key={i + 1}
onClick={() => onPageChange?.(i + 1)}
className={`w-9 h-9 rounded text-sm font-medium transition-colors ${
currentPage === i + 1
? 'bg-gradient-to-b from-[#00BFA6] to-[#144816] text-white'
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
}`}
>
{i + 1}
</button>
))}
<button
onClick={() => onPageChange?.(currentPage + 1)}
disabled={currentPage === totalPages}
className={`px-3 py-1.5 rounded text-sm font-bold transition-colors outline-0 ${
currentPage === totalPages
? ' text-gray-400 cursor-not-allowed'
: ' text-gray-700 hover:bg-gray-300'
}`}
>
&gt;
</button>
</div>
</div>
</div>
);
}

View File

@ -6,15 +6,15 @@ 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}
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400"
size={18}
/>
<input
type="text"
placeholder="Search..."
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"
className="w-full bg-white p-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-1 focus:ring-[#00BFA6]"
/>
</div>
);

View File

@ -1,36 +0,0 @@
'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,32 @@
"use client";
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 (
<>
<div className="flex gap-1">
{filters.map((filter) => (
<button
key={filter.value}
onClick={() => onFilterChange(filter.value)}
className={`p-0.5 rounded-xl text-gray-500 ${
activeFilter !== filter.value
? "bg-gray-200 "
: "text-gray-800 bg-gradient-to-b from-[#00BFA6] to-[#144861]"
}`}
>
<div className="p-1 h-full w-full flex justify-center items-center bg-white rounded-lg">
{filter.label}
</div>
</button>
))}
</div>
</>
);
}

View File

@ -1,11 +0,0 @@
'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,29 @@
'use client'
import { Check, X, AlertTriangle } from "lucide-react";
export default function StatusIndicator({ status }) {
const baseClasses = "w-4 h-4 p-[2px] rounded-full"; // circle look
switch (status) {
case "active":
return (
<div className={`${baseClasses} bg-[#00BFA6] text-white`}>
<Check className="w-full h-full" strokeWidth={4} />
</div>
);
case "inactive":
return (
<div className={`${baseClasses} bg-yellow-500 text-white`}>
<AlertTriangle className="w-full h-full" strokeWidth={4} />
</div>
);
case "expired":
return (
<div className={`${baseClasses} bg-red-500 text-white`}>
<X className="w-full h-full" strokeWidth={4} />
</div>
);
default:
return null;
}
}

View File

@ -1,134 +0,0 @@
// '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 }) {
// const BrokerData=isHidden?{name:"---",id:'---',dateAdded:'---',balance:"---",}:broker;
// // if (isHidden) broker={name:"---",id:'---',dateAdded:'---'};
// 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">
// {BrokerData.name}
// </td>
// <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
// {BrokerData.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">
// {BrokerData.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">
// {BrokerData.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>
// );
// }
'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 }) {
const BrokerData = isHidden
? { name: "---", id: '---', dateAdded: '---', balance: "---" }
: broker;
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">
{BrokerData.name}
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{BrokerData.id}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<BrokerAvatar brokerName={isHidden ? "---" : broker.broker} />
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{BrokerData.dateAdded}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<StatusIndicator status={isHidden ? "---" : broker.status} />
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-green-500">
{BrokerData.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"
disabled={isHidden}
>
<Edit2 size={18} />
</button>
<button
onClick={() => onDelete(broker.id)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Delete"
disabled={isHidden}
>
<Trash2 size={18} />
</button>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-center">
<ToggleSwitch
isActive={!isHidden && broker.status === 'active'}
onToggle={() => onToggleStatus(broker.id)}
disabled={isHidden}
/>
</td>
</tr>
);
}

View File

@ -0,0 +1,65 @@
'use client';
import { Edit2, Trash2, LogOut } 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 }) {
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 flex justify-center">
<StatusIndicator status={broker.status} />
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-[#00BFA6]">
{isHidden?"$-----":broker.balance}
</td>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center justify-center gap-2">
<button
//add a click event
//onClick={() => onEdit(broker)}
className="p-1.5 hover:bg-gray-100 rounded text-gray-600"
title="Exit"
>
<LogOut 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

@ -7,11 +7,12 @@ export default function FormInput({
placeholder,
type = "text",
required = false,
helperText
helperText ,
styleEl=''
}) {
return (
<div>
<label className="block text-sm font-medium text-gray-700 mb-1">
<label className="block text-sm font-medium text-gray-700 mb-1">
{label}{required && '*'}
</label>
<input
@ -19,7 +20,7 @@ export default function FormInput({
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"
className={`${styleEl} 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>

View File

@ -1,57 +0,0 @@
'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-gray-400 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,121 @@
// '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-gray-400 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>
// </>
// );
// }
"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-gray-300 opacity-50 z-40"
onClick={onClose}
/>
<div className="fixed right-0 top-0 h-full w-full max-w-md bg-white shadow-2xl z-50 transform transition-transform duration-300 ease-in-out flex flex-col p-4">
<div className="flex items-center justify-between py-4 ">
<h2 className="text-xl font-semibold text-gray-900">{title}</h2>
<button
onClick={onClose}
className="p-1 hover:bg-gray-100 rounded-full transition-colors"
>
<X size={24} className="text-gray-600" />
</button>
</div>
<p className="text-sm text-gray-600 pb-3 border-b border-gray-200">
Choose your preferred exchange to add a broker.
</p>
<div className="flex-1 overflow-y-auto py-6">{children}</div>
<div className="px-6 py-4 border-t border-gray-200 flex gap-3">
{/* <button
onClick={onCancel}
className="flex-1 px-6 py-2.5 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors text-gray-700 font-medium"
>
Cancel
</button> */}
<button
onClick={onCancel}
className="flex-1 p-0.5 rounded-full bg-gradient-to-b from-[#00BFA6] to-[#144861] hover:from-[#144861] hover:to-[#00BFA6] transition"
>
<div className=" flex items-center justify-center gap-2 bg-white text-gray-700 px-1 py-2.5 rounded-full text-sm font-medium">
Cancel
</div>
</button>
<button
onClick={onSubmit}
className="flex-1 p-0.5 bg-gradient-to-b from-[#00BFA6] to-[#144861] rounded-full hover:bg-teal-600 text-white transition-colors font-medium"
>
{submitLabel}
</button>
</div>
</div>
</>
);
}

View File

@ -6,7 +6,7 @@ export default function ToggleSwitch({ isActive, onToggle, disabled = false }) {
onClick={onToggle}
disabled={disabled}
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${
isActive ? 'bg-teal-500' : 'bg-gray-300'
isActive ? 'bg-gradient-to-b from-[#00BFA6] to-[#226685]' : 'bg-gray-300'
} ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
>
<span

View File

@ -8,11 +8,6 @@ export const STATUS_TYPES = {
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 = [
{
@ -82,3 +77,9 @@ export const INITIAL_BROKERS = [
dateCreated: '03/02/2025',
},
];
export const subPages=[
{id:1,name:"API Management"},
{id:2,name:"Risk Management"},
{id:3,name:"Hook Hub"}
]

View File

@ -1,38 +0,0 @@
'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>
);
}

53
src/layouts/Header.jsx Normal file
View File

@ -0,0 +1,53 @@
"use client";
import NavList from "./NavList";
import { Bell, User, Moon, CircleQuestionMark, Sun } 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 & Trade", 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] mb-5">
<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">
<Moon size={20} className="text-gray-600" />
</button>
<button className="p-2 hover:bg-gray-200 rounded-lg transition-colors">
<CircleQuestionMark size={20} className="text-gray-600" />
</button>
<button className="p-2 hover:bg-gray-200 rounded-lg transition-colors">
<Bell size={20} className="text-gray-600" />
</button>
<button className="flex p-0.5 rounded-full bg-gradient-to-b from-[#00BFA6] to-[#144861] hover:from-[#144861] hover:to-[#00BFA6] transition">
<div className=" flex items-center justify-center gap-2 bg-white text-gray-700 p-1.5 rounded-full text-sm font-medium">
<span className="font-bold">NSE</span>
<Sun size={20} className="text-gray-600" />
<span className="rotate-90 text-xl text-[#00BFA6]">&gt;</span>
</div>
</button>
<button className="flex p-0.5 rounded-full bg-gradient-to-b from-[#00BFA6] to-[#144861] hover:from-[#144861] hover:to-[#00BFA6] transition">
<div className=" flex items-center justify-center gap-2 bg-white text-gray-700 p-1.5 rounded-full text-sm font-medium">
<User size={20} className="text-black" />
</div>
</button>
</div>
</div>
</div>
);
}

View File

@ -18,7 +18,7 @@ export default function NavList({ list_items }) {
href={item.routeLink}
className={`text-sm font-medium transition-colors ${
isActive
? "text-teal-500"
? "text-transparent bg-gradient-to-b from-[#00BFA6] to-[#226685] bg-clip-text font-semibold"
: "text-gray-600 hover:text-gray-900"
}`}
>
@ -28,7 +28,7 @@ export default function NavList({ list_items }) {
{isActive && (
<motion.div
layoutId="header-underline"
className="absolute -bottom-[17px] left-0 right-0 h-[3px] bg-teal-500 rounded"
className="absolute -bottom-[18px] left-0 right-0 h-[3px] bg-gradient-to-b from-[#00BFA6] to-[#226685] rounded"
/>
)}
</li>