# app/routes/frontend.py """ Frontend HTML route handlers. Serves static HTML files for admin, vendor, and customer interfaces. Supports both path-based (/vendor/{vendor_code}/) and query-based access. """ from fastapi import APIRouter, Path from fastapi.responses import FileResponse router = APIRouter(include_in_schema=False) # ============================================================================ # ADMIN ROUTES # ============================================================================ @router.get("/admin/") @router.get("/admin/login") async def admin_login(): """Serve admin login page""" return FileResponse("static/admin/login.html") @router.get("/admin/dashboard") async def admin_dashboard(): """Serve admin dashboard page""" return FileResponse("static/admin/dashboard.html") @router.get("/admin/vendors") async def admin_vendors(): """Serve admin vendors management page""" return FileResponse("static/admin/vendors.html") @router.get("/admin/vendor-edit") async def admin_vendor_edit(): """Serve admin vendor edit page""" return FileResponse("static/admin/vendor-edit.html") # ============================================================================ # VENDOR ROUTES (with vendor code in path) # ============================================================================ @router.get("/vendor/{vendor_code}/") @router.get("/vendor/{vendor_code}/login") async def vendor_login_with_code(vendor_code: str = Path(...)): """Serve vendor login page with vendor code in path""" return FileResponse("static/vendor/login.html") @router.get("/vendor/{vendor_code}/dashboard") async def vendor_dashboard_with_code(vendor_code: str = Path(...)): """Serve vendor dashboard page with vendor code in path""" return FileResponse("static/vendor/dashboard.html") @router.get("/vendor/{vendor_code}/products") @router.get("/vendor/{vendor_code}/admin/products") async def vendor_products_with_code(vendor_code: str = Path(...)): """Serve vendor products management page""" return FileResponse("static/vendor/admin/products.html") @router.get("/vendor/{vendor_code}/orders") @router.get("/vendor/{vendor_code}/admin/orders") async def vendor_orders_with_code(vendor_code: str = Path(...)): """Serve vendor orders management page""" return FileResponse("static/vendor/admin/orders.html") @router.get("/vendor/{vendor_code}/marketplace") @router.get("/vendor/{vendor_code}/admin/marketplace") async def vendor_marketplace_with_code(vendor_code: str = Path(...)): """Serve vendor marketplace import page""" return FileResponse("static/vendor/admin/marketplace.html") @router.get("/vendor/{vendor_code}/customers") @router.get("/vendor/{vendor_code}/admin/customers") async def vendor_customers_with_code(vendor_code: str = Path(...)): """Serve vendor customers management page""" return FileResponse("static/vendor/admin/customers.html") @router.get("/vendor/{vendor_code}/inventory") @router.get("/vendor/{vendor_code}/admin/inventory") async def vendor_inventory_with_code(vendor_code: str = Path(...)): """Serve vendor inventory management page""" return FileResponse("static/vendor/admin/inventory.html") @router.get("/vendor/{vendor_code}/team") @router.get("/vendor/{vendor_code}/admin/team") async def vendor_team_with_code(vendor_code: str = Path(...)): """Serve vendor team management page""" return FileResponse("static/vendor/admin/team.html") # Fallback vendor routes (without vendor code - for query parameter access) @router.get("/vendor/") @router.get("/vendor/login") async def vendor_login(): """Serve vendor login page (query parameter based)""" return FileResponse("static/vendor/login.html") @router.get("/vendor/dashboard") async def vendor_dashboard(): """Serve vendor dashboard page (query parameter based)""" return FileResponse("static/vendor/dashboard.html") # ============================================================================ # CUSTOMER/SHOP ROUTES # ============================================================================ @router.get("/shop/") @router.get("/shop/products") async def shop_products(): """Serve shop products catalog page""" return FileResponse("static/shop/products.html") @router.get("/shop/products/{product_id}") async def shop_product_detail(product_id: int): """Serve product detail page""" return FileResponse("static/shop/product.html") @router.get("/shop/cart") async def shop_cart(): """Serve shopping cart page""" return FileResponse("static/shop/cart.html") @router.get("/shop/checkout") async def shop_checkout(): """Serve checkout page""" return FileResponse("static/shop/checkout.html") @router.get("/shop/account/register") async def shop_register(): """Serve customer registration page""" return FileResponse("static/shop/account/register.html") @router.get("/shop/account/login") async def shop_login(): """Serve customer login page""" return FileResponse("static/shop/account/login.html") @router.get("/shop/account/dashboard") async def shop_account_dashboard(): """Serve customer account dashboard""" return FileResponse("static/shop/account/dashboard.html") @router.get("/shop/account/orders") async def shop_orders(): """Serve customer orders history page""" return FileResponse("static/shop/account/orders.html") @router.get("/shop/account/orders/{order_id}") async def shop_order_detail(order_id: int): """Serve customer order detail page""" return FileResponse("static/shop/account/order-detail.html") @router.get("/shop/account/profile") async def shop_profile(): """Serve customer profile page""" return FileResponse("static/shop/account/profile.html") @router.get("/shop/account/addresses") async def shop_addresses(): """Serve customer addresses management page""" return FileResponse("static/shop/account/addresses.html")