from fastapi import APIRouter, Depends, HTTPException from core.database import fake_users_db import uuid router = APIRouter() @router.post("/sellfabric") async def sellfabric_handler( fabric_name: str, quantity: int, price: float, seller_id: str = None ): """Handle fabric selling transaction""" if not seller_id: raise HTTPException(status_code=400, detail="Seller ID is required") if seller_id not in fake_users_db: raise HTTPException(status_code=404, detail="Seller not found") transaction_id = str(uuid.uuid4()) # Simulate storing fabric transaction fake_users_db[seller_id]["transactions"] = fake_users_db[seller_id].get("transactions", []) fake_users_db[seller_id]["transactions"].append({ "transaction_id": transaction_id, "fabric_name": fabric_name, "quantity": quantity, "price": price, "status": "pending" }) return { "message": "Fabric listing created successfully", "transaction_id": transaction_id, "data": { "fabric_name": fabric_name, "quantity": quantity, "price": price, "seller_id": seller_id }, "metadata": { "timestamp": "2024-01-01T00:00:00Z", "status": "pending" }, "next_steps": [ "Await buyer confirmation", "Prepare fabric for shipping" ] }