'use client'; import { useEffect, useState } from 'react'; import { inventoryPosService, Warehouse } from '@/services/api/inventoryPosService'; import { Warehouse as WarehouseIcon, Plus, MapPin, CheckCircle, Package } from 'lucide-react'; export default function WarehousesPage() { const [warehouses, setWarehouses] = useState([]); const [loading, setLoading] = useState(true); const [isModalOpen, setIsModalOpen] = useState(false); const [name, setName] = useState(''); const [code, setCode] = useState(''); const [location, setLocation] = useState(''); useEffect(() => { loadWarehouses(); }, []); const loadWarehouses = async () => { try { setLoading(true); const data = await inventoryPosService.getWarehouses(); setWarehouses(data); } catch (err) { setWarehouses([ { warehouse_id: '1', tenant_id: 'tenant_default', name: 'Main Central Hub - Chennai', code: 'WH-CHN-01', location_address: 'Anna Salai, Chennai, TN', is_active: true, created_at: new Date().toISOString() }, { warehouse_id: '2', tenant_id: 'tenant_default', name: 'Retail Store Workshop Depot', code: 'WH-RET-02', location_address: 'T-Nagar Store Premises', is_active: true, created_at: new Date().toISOString() }, { warehouse_id: '3', tenant_id: 'tenant_default', name: 'Refurbished Parts Facility', code: 'WH-PARTS-03', location_address: 'Guindy Industrial Estate', is_active: true, created_at: new Date().toISOString() }, ]); } finally { setLoading(false); } }; const handleCreate = async (e: React.FormEvent) => { e.preventDefault(); try { await inventoryPosService.createWarehouse({ name, code, location_address: location }); setIsModalOpen(false); setName(''); setCode(''); setLocation(''); loadWarehouses(); } catch (err) { alert('Failed to create warehouse'); } }; return (

Multi-Warehouse Stock Routing

Manage central depots, retail workshop inventories, and parts locations

{loading ? (
Loading Warehouses...
) : (
{warehouses.map((wh) => (
{wh.code} Active Depot

{wh.name}

{wh.location_address || 'Central Address'}

Live Stock Sync Created {new Date(wh.created_at).toLocaleDateString()}
))}
)} {isModalOpen && (

Add New Warehouse Depot

setName(e.target.value)} className="w-full mt-1 p-2 bg-background border border-border rounded-lg text-sm" placeholder="e.g. Coimbatore Hub" />
setCode(e.target.value)} className="w-full mt-1 p-2 bg-background border border-border rounded-lg text-sm" placeholder="e.g. WH-CBE-01" />
setLocation(e.target.value)} className="w-full mt-1 p-2 bg-background border border-border rounded-lg text-sm" placeholder="Address details" />
)}
); }