From 278e3fc18c0796253a152ab190d0629b5517eed4 Mon Sep 17 00:00:00 2001 From: sazzadulalambd Date: Tue, 5 May 2026 21:54:46 +0600 Subject: [PATCH] feat: add swap station management module and settings configuration to admin dashboard --- src/app/admin/settings/page.tsx | 234 +++++++++++++++++++++++++++++++- 1 file changed, 232 insertions(+), 2 deletions(-) diff --git a/src/app/admin/settings/page.tsx b/src/app/admin/settings/page.tsx index 25ac10b..694f853 100644 --- a/src/app/admin/settings/page.tsx +++ b/src/app/admin/settings/page.tsx @@ -1,7 +1,7 @@ 'use client'; import { useState } from 'react'; -import { Settings, Upload, Image, Globe, Mail, MessageSquare, Phone, MapPin, Link2, Clock, Save, FileText, Camera, Palette, Ruler, Sun, Moon, Monitor, Smartphone, Tablet, Package, Wrench, FileCheck, BadgeDollarSign, CreditCard, Plus, X, DollarSign } from 'lucide-react'; +import { Settings, Upload, Image, Globe, Mail, MessageSquare, Phone, MapPin, Link2, Clock, Save, FileText, Camera, Palette, Ruler, Sun, Moon, Monitor, Smartphone, Tablet, Package, Wrench, FileCheck, BadgeDollarSign, CreditCard, Plus, X, DollarSign, Zap } from 'lucide-react'; interface CompanySettings { name: string; @@ -138,6 +138,19 @@ interface CompanySettings { status: string; description: string; }[]; + swapStation: { + id: string; + name: string; + batteryCount: number; + swapPrice: number; + monthlySubscription: number; + dailySubscription: number; + minBatteries: number; + maxBatteries: number; + profitSharePercent: number; + status: string; + description: string; + }[]; }; } @@ -495,12 +508,40 @@ const initialSettings: CompanySettings = { description: 'Investment plan for 5 bikes - medium scale investment', } ], + swapStation: [ + { + id: 'ss_1', + name: 'Basic Swap Station', + batteryCount: 10, + swapPrice: 50, + monthlySubscription: 500, + dailySubscription: 20, + minBatteries: 1, + maxBatteries: 5, + profitSharePercent: 50, + status: 'active', + description: 'Basic swap station for small operators', + }, + { + id: 'ss_2', + name: 'Premium Swap Station', + batteryCount: 50, + swapPrice: 45, + monthlySubscription: 2000, + dailySubscription: 80, + minBatteries: 10, + maxBatteries: 30, + profitSharePercent: 55, + status: 'active', + description: 'Premium swap station for large operators', + } + ], }, }; export default function CompanySettingsPage() { const [settings, setSettings] = useState(initialSettings); - const [activeTab, setActiveTab] = useState<'general' | 'branding' | 'social' | 'integration' | 'landing' | 'kyc' | 'parts' | 'rental' | 'plans' | 'investment'>('general'); + const [activeTab, setActiveTab] = useState<'general' | 'branding' | 'social' | 'integration' | 'landing' | 'kyc' | 'parts' | 'rental' | 'plans' | 'investment' | 'swapstation'>('general'); const [activeMasterTab, setActiveMasterTab] = useState<'investor' | 'merchant' | 'swapstation' | 'rental'>('investor'); const [saved, setSaved] = useState(false); const [activePlanTab, setActivePlanTab] = useState<'singleRent' | 'rentToOwn' | 'shareEv'>('singleRent'); @@ -553,6 +594,42 @@ export default function CompanySettingsPage() { } }; + const [activeSwapTab, setActiveSwapTab] = useState(0); + const [addSwapStationPlan, setAddSwapStationPlan] = useState(false); + const [newSwapName, setNewSwapName] = useState(''); + const [newSwapStatus, setNewSwapStatus] = useState('active'); + const [newSwapBatteryCount, setNewSwapBatteryCount] = useState(10); + const [newSwapPrice, setNewSwapPrice] = useState(50); + const [newSwapMonthly, setNewSwapMonthly] = useState(500); + const [newSwapDaily, setNewSwapDaily] = useState(20); + const [newSwapMin, setNewSwapMin] = useState(1); + const [newSwapMax, setNewSwapMax] = useState(5); + const [newSwapProfit, setNewSwapProfit] = useState(50); + const [newSwapDesc, setNewSwapDesc] = useState(''); + + const createSwapStationPlan = () => { + if (newSwapName.trim() && typeof window !== 'undefined') { + const newPlan = { + id: 'ss_' + Date.now(), + name: newSwapName, + batteryCount: newSwapBatteryCount, + swapPrice: newSwapPrice, + monthlySubscription: newSwapMonthly, + dailySubscription: newSwapDaily, + minBatteries: newSwapMin, + maxBatteries: newSwapMax, + profitSharePercent: newSwapProfit, + status: newSwapStatus, + description: newSwapDesc + }; + const updatedPlans = [...settings.plans.swapStation, newPlan]; + setSettings({ ...settings, plans: { ...settings.plans, swapStation: updatedPlans } }); + setActiveSwapTab(updatedPlans.length - 1); + setAddSwapStationPlan(false); + setNewSwapName(''); + } + }; + const handleSave = () => { setSaved(true); setTimeout(() => setSaved(false), 2000); @@ -569,6 +646,7 @@ export default function CompanySettingsPage() { { id: 'rental', label: 'Rental Policy', icon: FileCheck }, { id: 'plans', label: 'Plan Selection', icon: Package }, { id: 'investment', label: 'Investment Plan', icon: DollarSign }, + { id: 'swapstation', label: 'Swap Station Plan', icon: Zap }, ]; return ( @@ -2062,6 +2140,158 @@ export default function CompanySettingsPage() { ))} )} + + {(activeTab as string) === 'swapstation' && ( +
+
+

Swap Station Plans

+
+ +
+
+

Swap Station Plans ({settings.plans.swapStation.length})

+

Manage swap station plans for operators

+
+ +
+ + {addSwapStationPlan && ( +
+
+
+

New Swap Station Plan

+

Fill in the details below

+
+ +
+
+
+
+ + setNewSwapName(e.target.value)} placeholder="e.g., Standard Station" className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + +
+
+ + setNewSwapBatteryCount(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapPrice(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapMonthly(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapDaily(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapMin(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapMax(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+ + setNewSwapProfit(parseInt(e.target.value))} className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm mt-1" /> +
+
+
+ +