feat: add hub selection to battery form and update data schema
This commit is contained in:
@@ -58,6 +58,8 @@ interface Battery {
|
|||||||
assignedBikerName?: string;
|
assignedBikerName?: string;
|
||||||
currentStationId?: string;
|
currentStationId?: string;
|
||||||
currentStationName?: string;
|
currentStationName?: string;
|
||||||
|
hubId?: string;
|
||||||
|
hubName?: string;
|
||||||
lastMaintenance?: string;
|
lastMaintenance?: string;
|
||||||
nextMaintenance?: string;
|
nextMaintenance?: string;
|
||||||
bmsData?: BMSData;
|
bmsData?: BMSData;
|
||||||
@@ -254,6 +256,13 @@ const mockStations: SwapStation[] = [
|
|||||||
{ id: 'SS-005', name: 'Mirpur Swap Station', location: 'Mirpur 1, Section 2' },
|
{ id: 'SS-005', name: 'Mirpur Swap Station', location: 'Mirpur 1, Section 2' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const hubs = [
|
||||||
|
{ id: 'HUB-001', name: 'JAIBEN Head Office' },
|
||||||
|
{ id: 'HUB-002', name: 'Banani Hub' },
|
||||||
|
{ id: 'HUB-003', name: 'Uttara Hub' },
|
||||||
|
{ id: 'HUB-004', name: 'Mirpur Hub' },
|
||||||
|
];
|
||||||
|
|
||||||
const statusColors: Record<string, string> = {
|
const statusColors: Record<string, string> = {
|
||||||
available: 'bg-green-100 text-green-700',
|
available: 'bg-green-100 text-green-700',
|
||||||
'in-use': 'bg-blue-100 text-blue-700',
|
'in-use': 'bg-blue-100 text-blue-700',
|
||||||
@@ -789,12 +798,17 @@ function BatteryForm({ battery, onSave, onCancel }: { battery: Battery | null; o
|
|||||||
voltage: 60,
|
voltage: 60,
|
||||||
purchaseDate: new Date().toISOString().split('T')[0],
|
purchaseDate: new Date().toISOString().split('T')[0],
|
||||||
purchasePrice: 0,
|
purchasePrice: 0,
|
||||||
|
transactionMethod: 'cash',
|
||||||
|
autoJournal: true,
|
||||||
|
autoJournalSource: 'supplier',
|
||||||
warrantyExpiry: '',
|
warrantyExpiry: '',
|
||||||
status: 'available',
|
status: 'available',
|
||||||
currentSoc: 100,
|
currentSoc: 100,
|
||||||
health: 100,
|
health: 100,
|
||||||
cycleCount: 0,
|
cycleCount: 0,
|
||||||
history: [],
|
history: [],
|
||||||
|
hubId: '',
|
||||||
|
hubName: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleChange = (field: keyof Battery, value: any) => {
|
const handleChange = (field: keyof Battery, value: any) => {
|
||||||
@@ -897,33 +911,23 @@ function BatteryForm({ battery, onSave, onCancel }: { battery: Battery | null; o
|
|||||||
<option value="other">Other</option>
|
<option value="other">Other</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-3">
|
<div>
|
||||||
<label className="flex items-center gap-2 cursor-pointer">
|
<label className="block text-sm font-medium text-slate-700 mb-1">Hub</label>
|
||||||
<input
|
<select
|
||||||
type="checkbox"
|
value={formData.hubId || ''}
|
||||||
checked={formData.autoJournal || false}
|
onChange={(e) => {
|
||||||
onChange={(e) => handleChange('autoJournal', e.target.checked)}
|
const hub = hubs.find(h => h.id === e.target.value);
|
||||||
className="w-4 h-4 text-accent rounded border-slate-300 focus:ring-accent"
|
handleChange('hubId', e.target.value);
|
||||||
/>
|
handleChange('hubName', hub?.name || '');
|
||||||
<span className="text-sm text-slate-700">Auto-Journal Entry</span>
|
}}
|
||||||
</label>
|
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent"
|
||||||
|
>
|
||||||
|
<option value="">Select Hub...</option>
|
||||||
|
{hubs.map(hub => (
|
||||||
|
<option key={hub.id} value={hub.id}>{hub.name}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{formData.autoJournal && (
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-slate-700 mb-1">Auto-Journal Source</label>
|
|
||||||
<select
|
|
||||||
value={formData.autoJournalSource || 'supplier'}
|
|
||||||
onChange={(e) => handleChange('autoJournalSource', e.target.value as any)}
|
|
||||||
className="w-full px-3 py-2 border border-slate-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-accent"
|
|
||||||
>
|
|
||||||
<option value="supplier">Supplier Purchase</option>
|
|
||||||
<option value="import">Import</option>
|
|
||||||
<option value="internal">Internal Transfer</option>
|
|
||||||
<option value="transfer">Transfer</option>
|
|
||||||
<option value="other">Other</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-slate-700 mb-1">Warranty Expiry</label>
|
<label className="block text-sm font-medium text-slate-700 mb-1">Warranty Expiry</label>
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user