diff --git a/src/app/admin/settings/page.tsx b/src/app/admin/settings/page.tsx index ec2b9fa..efd9462 100644 --- a/src/app/admin/settings/page.tsx +++ b/src/app/admin/settings/page.tsx @@ -70,7 +70,7 @@ interface CompanySettings { documents: { id: string; name: string; required: boolean; description: string }[]; }[]; }; - parts: { id: string; name: string; price?: number; minPrice?: number; maxPrice?: number; inStock: number }[]; + parts: { id: string; name: string; buyingPrice: number; sellingPrice: number }[]; serviceCenters: { id: string; name: string; address: string; phone: string; rating: number }[]; companyPolicy: { investor: { title: string; description: string }[]; @@ -333,21 +333,21 @@ const initialSettings: CompanySettings = { ] }, parts: [ - { id: 'PRT-001', name: 'Battery 60V', price: 15000, inStock: 25 }, - { id: 'PRT-002', name: 'Battery 48V', price: 12000, inStock: 30 }, - { id: 'PRT-003', name: 'Front Tire', price: 2500, inStock: 50 }, - { id: 'PRT-004', name: 'Rear Tire', price: 2500, inStock: 50 }, - { id: 'PRT-005', name: 'Brake Pad', price: 800, inStock: 100 }, - { id: 'PRT-006', name: 'Mirror', price: 350, inStock: 80 }, - { id: 'PRT-007', name: 'Controller', minPrice: 3500, maxPrice: 5000, inStock: 15 }, - { id: 'PRT-008', name: 'Motor', minPrice: 8000, maxPrice: 12000, inStock: 10 }, - { id: 'PRT-009', name: 'Charger', minPrice: 1500, maxPrice: 2500, inStock: 20 }, - { id: 'PRT-010', name: 'Display Meter', price: 1200, inStock: 25 }, - { id: 'PRT-011', name: 'Throttle', price: 800, inStock: 40 }, - { id: 'PRT-012', name: 'Brake Cable', price: 250, inStock: 60 }, - { id: 'PRT-013', name: 'Chain', price: 600, inStock: 35 }, - { id: 'PRT-014', name: 'Sprocket', price: 450, inStock: 45 }, - { id: 'PRT-015', name: 'Foot Peg', price: 300, inStock: 50 }, + { id: 'PRT-001', name: 'Battery 60V', buyingPrice: 12000, sellingPrice: 15000 }, + { id: 'PRT-002', name: 'Battery 48V', buyingPrice: 9000, sellingPrice: 12000 }, + { id: 'PRT-003', name: 'Front Tire', buyingPrice: 1800, sellingPrice: 2500 }, + { id: 'PRT-004', name: 'Rear Tire', buyingPrice: 1800, sellingPrice: 2500 }, + { id: 'PRT-005', name: 'Brake Pad', buyingPrice: 500, sellingPrice: 800 }, + { id: 'PRT-006', name: 'Mirror', buyingPrice: 200, sellingPrice: 350 }, + { id: 'PRT-007', name: 'Controller', buyingPrice: 3000, sellingPrice: 4500 }, + { id: 'PRT-008', name: 'Motor', buyingPrice: 7000, sellingPrice: 10000 }, + { id: 'PRT-009', name: 'Charger', buyingPrice: 1200, sellingPrice: 2000 }, + { id: 'PRT-010', name: 'Display Meter', buyingPrice: 800, sellingPrice: 1200 }, + { id: 'PRT-011', name: 'Throttle', buyingPrice: 500, sellingPrice: 800 }, + { id: 'PRT-012', name: 'Brake Cable', buyingPrice: 150, sellingPrice: 250 }, + { id: 'PRT-013', name: 'Chain', buyingPrice: 400, sellingPrice: 600 }, + { id: 'PRT-014', name: 'Sprocket', buyingPrice: 300, sellingPrice: 450 }, + { id: 'PRT-015', name: 'Foot Peg', buyingPrice: 180, sellingPrice: 300 }, ], serviceCenters: [ { id: 'SC-001', name: 'JAIBEN Service Center - Gulshan', address: 'House 45, Road 13, Gulshan 1, Dhaka', phone: '+8801712345670', rating: 4.8 }, @@ -1802,47 +1802,86 @@ export default function CompanySettingsPage() { {activeTab === 'parts' && (
-

EV Parts

- -
- - - - - - - - - - - - {settings.parts.map(part => ( - - - - - - - - ))} - -
Part IDNamePrice RangeIn StockType
{part.id}{part.name} - {part.minPrice && part.maxPrice ? ( - ৳{part.minPrice} - ৳{part.maxPrice} - ) : part.price ? ( - ৳{part.price} - ) : ( - - - )} - {part.inStock} - {part.minPrice ? ( - Range - ) : ( - Fixed - )} -
+
+

EV Parts

+ +
+ + {showAddPolicy && activeTab === 'parts' && ( +
+ setNewPolicyName(e.target.value)} className="w-full px-2 py-1.5 border border-slate-200 rounded text-sm mb-2" placeholder="Part Name" /> +
+ setNewPolicyDesc(e.target.value)} className="px-2 py-1.5 border border-slate-200 rounded text-sm" placeholder="Buying Price" /> + setEditPolicyDescHtml(e.target.value)} className="px-2 py-1.5 border border-slate-200 rounded text-sm" placeholder="Selling Price" /> +
+
+ + +
+
+ )} + +
+ {settings.parts.map((part, i) => ( +
+ {editingPolicy?.tab === 'parts' && editingPolicy?.index === i ? ( +
+ setEditPolicyName(e.target.value)} className="w-full px-2 py-1.5 border border-slate-200 rounded text-sm" placeholder="Part Name" /> +
+ setEditPolicyDesc(e.target.value)} className="px-2 py-1.5 border border-slate-200 rounded text-sm" placeholder="Buying Price" /> + setNewPolicyName(e.target.value)} className="px-2 py-1.5 border border-slate-200 rounded text-sm" placeholder="Selling Price" /> +
+
+ + +
+
+ ) : ( +
+
+
+ {part.name} + ({part.id}) +
+
+ Buying: ৳{part.buyingPrice} + Selling: ৳{part.sellingPrice} +
+
+
+ + +
+
+ )} +
+ ))}
-
)}