diff --git a/actix_mvc_app/src/controllers/marketplace.rs b/actix_mvc_app/src/controllers/marketplace.rs index ebe48d5..9ba00ce 100644 --- a/actix_mvc_app/src/controllers/marketplace.rs +++ b/actix_mvc_app/src/controllers/marketplace.rs @@ -103,7 +103,10 @@ impl MarketplaceController { AssetType::NFT.as_str(), AssetType::RealEstate.as_str(), AssetType::IntellectualProperty.as_str(), - AssetType::PhysicalAsset.as_str(), + AssetType::Commodity.as_str(), + AssetType::Share.as_str(), + AssetType::Bond.as_str(), + AssetType::Other.as_str(), ]); render_template(&tmpl, "marketplace/listings.html", &context) @@ -140,15 +143,28 @@ impl MarketplaceController { if let Some(listing) = listing { // Get similar listings (same asset type, active) let similar_listings: Vec<&Listing> = listings.iter() - .filter(|l| l.asset_type == listing.asset_type && - l.status == ListingStatus::Active && + .filter(|l| l.asset_type == listing.asset_type && + l.status == ListingStatus::Active && l.id != listing.id) .take(4) .collect(); + // Get highest bid amount and minimum bid for auction listings + let (highest_bid_amount, minimum_bid) = if listing.listing_type == ListingType::Auction { + if let Some(bid) = listing.highest_bid() { + (Some(bid.amount), bid.amount + 1.0) + } else { + (None, listing.price + 1.0) + } + } else { + (None, 0.0) + }; + context.insert("active_page", &"marketplace"); context.insert("listing", listing); context.insert("similar_listings", &similar_listings); + context.insert("highest_bid_amount", &highest_bid_amount); + context.insert("minimum_bid", &minimum_bid); // Add current user info for bid/purchase forms let user_id = "user-123"; @@ -311,7 +327,7 @@ impl MarketplaceController { tmpl: web::Data, path: web::Path, ) -> Result { - let listing_id = path.into_inner(); + let _listing_id = path.into_inner(); // In a real application, we would: // 1. Find the listing in the database @@ -344,7 +360,10 @@ impl MarketplaceController { AssetType::NFT => 500.0 + (i as f64 * 100.0), AssetType::RealEstate => 50000.0 + (i as f64 * 10000.0), AssetType::IntellectualProperty => 2000.0 + (i as f64 * 500.0), - AssetType::PhysicalAsset => 1000.0 + (i as f64 * 200.0), + AssetType::Commodity => 1000.0 + (i as f64 * 200.0), + AssetType::Share => 300.0 + (i as f64 * 50.0), + AssetType::Bond => 1500.0 + (i as f64 * 300.0), + AssetType::Other => 800.0 + (i as f64 * 150.0), }; let mut listing = Listing::new( @@ -382,7 +401,10 @@ impl MarketplaceController { AssetType::NFT => 400.0 + (i as f64 * 50.0), AssetType::RealEstate => 40000.0 + (i as f64 * 5000.0), AssetType::IntellectualProperty => 1500.0 + (i as f64 * 300.0), - AssetType::PhysicalAsset => 800.0 + (i as f64 * 100.0), + AssetType::Commodity => 800.0 + (i as f64 * 100.0), + AssetType::Share => 250.0 + (i as f64 * 40.0), + AssetType::Bond => 1200.0 + (i as f64 * 250.0), + AssetType::Other => 600.0 + (i as f64 * 120.0), }; let mut listing = Listing::new( @@ -435,7 +457,10 @@ impl MarketplaceController { AssetType::NFT => 600.0 + (i as f64 * 150.0), AssetType::RealEstate => 60000.0 + (i as f64 * 15000.0), AssetType::IntellectualProperty => 2500.0 + (i as f64 * 600.0), - AssetType::PhysicalAsset => 1200.0 + (i as f64 * 300.0), + AssetType::Commodity => 1200.0 + (i as f64 * 300.0), + AssetType::Share => 350.0 + (i as f64 * 70.0), + AssetType::Bond => 1800.0 + (i as f64 * 350.0), + AssetType::Other => 1000.0 + (i as f64 * 200.0), }; let listing = Listing::new( @@ -469,7 +494,10 @@ impl MarketplaceController { AssetType::NFT => 550.0 + (i as f64 * 120.0), AssetType::RealEstate => 55000.0 + (i as f64 * 12000.0), AssetType::IntellectualProperty => 2200.0 + (i as f64 * 550.0), - AssetType::PhysicalAsset => 1100.0 + (i as f64 * 220.0), + AssetType::Commodity => 1100.0 + (i as f64 * 220.0), + AssetType::Share => 320.0 + (i as f64 * 60.0), + AssetType::Bond => 1650.0 + (i as f64 * 330.0), + AssetType::Other => 900.0 + (i as f64 * 180.0), }; let sale_price = price * 0.95; // Slight discount on sale @@ -515,7 +543,10 @@ impl MarketplaceController { AssetType::NFT => 450.0 + (i as f64 * 80.0), AssetType::RealEstate => 45000.0 + (i as f64 * 8000.0), AssetType::IntellectualProperty => 1800.0 + (i as f64 * 400.0), - AssetType::PhysicalAsset => 900.0 + (i as f64 * 180.0), + AssetType::Commodity => 900.0 + (i as f64 * 180.0), + AssetType::Share => 280.0 + (i as f64 * 45.0), + AssetType::Bond => 1350.0 + (i as f64 * 270.0), + AssetType::Other => 750.0 + (i as f64 * 150.0), }; let mut listing = Listing::new( diff --git a/actix_mvc_app/src/views/marketplace/create_listing.html b/actix_mvc_app/src/views/marketplace/create_listing.html index 1725e7b..82e44a0 100644 --- a/actix_mvc_app/src/views/marketplace/create_listing.html +++ b/actix_mvc_app/src/views/marketplace/create_listing.html @@ -35,8 +35,8 @@ diff --git a/actix_mvc_app/src/views/marketplace/index.html b/actix_mvc_app/src/views/marketplace/index.html index d83f392..1eee45b 100644 --- a/actix_mvc_app/src/views/marketplace/index.html +++ b/actix_mvc_app/src/views/marketplace/index.html @@ -116,8 +116,8 @@
{{ listing.title }}

{{ listing.description }}

- {{ listing.listing_type.as_str() }} - {{ listing.asset_type.as_str() }} + {{ listing.listing_type }} + {{ listing.asset_type }}
- {% if listing.asset_type.as_str() == "Token" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "NFT" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "RealEstate" %} + {% if listing.asset_type == "Token" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "NFT" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "RealEstate" %} Real Estate - {% elif listing.asset_type.as_str() == "IntellectualProperty" %} + {% elif listing.asset_type == "IntellectualProperty" %} IP {% else %} - {{ listing.asset_type.as_str() }} + {{ listing.asset_type }} {% endif %} ${{ listing.price }} - {{ listing.listing_type.as_str() }} + {{ listing.listing_type }} {{ listing.seller_name }} {{ listing.created_at|date }} diff --git a/actix_mvc_app/src/views/marketplace/listing_detail.html b/actix_mvc_app/src/views/marketplace/listing_detail.html index 39d1d44..9daa872 100644 --- a/actix_mvc_app/src/views/marketplace/listing_detail.html +++ b/actix_mvc_app/src/views/marketplace/listing_detail.html @@ -27,15 +27,15 @@ {% endif %}
- {% if listing.listing_type.as_str() == "Fixed Price" %} + {% if listing.listing_type == "Fixed Price" %} - {% elif listing.listing_type.as_str() == "Auction" %} + {% elif listing.listing_type == "Auction" %} - {% elif listing.listing_type.as_str() == "Exchange" %} + {% elif listing.listing_type == "Exchange" %} @@ -59,16 +59,16 @@

Asset Name: {{ listing.asset_name }}

Asset Type: - {% if listing.asset_type.as_str() == "Token" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "NFT" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "RealEstate" %} + {% if listing.asset_type == "Token" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "NFT" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "RealEstate" %} Real Estate - {% elif listing.asset_type.as_str() == "IntellectualProperty" %} + {% elif listing.asset_type == "IntellectualProperty" %} Intellectual Property {% else %} - {{ listing.asset_type.as_str() }} + {{ listing.asset_type }} {% endif %}

Asset ID: {{ listing.asset_id }}

@@ -89,8 +89,11 @@ Listing Details
- - {{ listing.status.as_str() }} + {% if listing.status == 'Active' %} + {{ listing.status }} + {% else %} + {{ listing.status }} + {% endif %}
@@ -100,7 +103,7 @@
- {{ listing.listing_type.as_str() }} + {{ listing.listing_type }} {% if listing.featured %} Featured {% endif %} @@ -143,7 +146,7 @@
- {% if listing.listing_type.as_str() == "Auction" %} + {% if listing.listing_type == "Auction" %}
@@ -168,8 +171,11 @@ ${{ bid.amount }} {{ bid.created_at|date }} - - {{ bid.status.as_str() }} + {% if bid.status == 'Active' %} + {{ bid.status }} + {% else %} + {{ bid.status }} + {% endif %} @@ -177,7 +183,7 @@
-

Current Highest Bid: ${{ listing.highest_bid().amount }}

+

Current Highest Bid: ${{ listing.highest_bid_amount }}

{% else %}

No bids yet. Be the first to bid!

Starting Price: ${{ listing.price }}

@@ -212,8 +218,8 @@
{{ similar.title }}
- {{ similar.listing_type.as_str() }} - {{ similar.asset_type.as_str() }} + {{ similar.listing_type }} + {{ similar.asset_type }}
diff --git a/actix_mvc_app/src/views/marketplace/listings.html b/actix_mvc_app/src/views/marketplace/listings.html index aa50e32..bfe9777 100644 --- a/actix_mvc_app/src/views/marketplace/listings.html +++ b/actix_mvc_app/src/views/marketplace/listings.html @@ -77,9 +77,9 @@
{% if listings|length > 0 %} {% for listing in listings %} -
{% if listing.featured %} @@ -96,17 +96,17 @@
{{ listing.title }}

{{ listing.description }}

- {{ listing.listing_type.as_str() }} - {% if listing.asset_type.as_str() == "Token" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "NFT" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "RealEstate" %} + {{ listing.listing_type }} + {% if listing.asset_type == "Token" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "NFT" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "RealEstate" %} Real Estate - {% elif listing.asset_type.as_str() == "IntellectualProperty" %} + {% elif listing.asset_type == "IntellectualProperty" %} IP {% else %} - {{ listing.asset_type.as_str() }} + {{ listing.asset_type }} {% endif %}
@@ -159,8 +159,8 @@ {% if listings|length > 0 %} {% for listing in listings %}
@@ -173,20 +173,20 @@ {{ listing.title }} - {% if listing.asset_type.as_str() == "Token" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "NFT" %} - {{ listing.asset_type.as_str() }} - {% elif listing.asset_type.as_str() == "RealEstate" %} + {% if listing.asset_type == "Token" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "NFT" %} + {{ listing.asset_type }} + {% elif listing.asset_type == "RealEstate" %} Real Estate - {% elif listing.asset_type.as_str() == "IntellectualProperty" %} + {% elif listing.asset_type == "IntellectualProperty" %} IP {% else %} - {{ listing.asset_type.as_str() }} + {{ listing.asset_type }} {% endif %} ${{ listing.price }} - {{ listing.listing_type.as_str() }} + {{ listing.listing_type }} {{ listing.seller_name }} {{ listing.created_at|date }} diff --git a/actix_mvc_app/src/views/marketplace/my_listings.html b/actix_mvc_app/src/views/marketplace/my_listings.html index 6ff99bd..ecac37a 100644 --- a/actix_mvc_app/src/views/marketplace/my_listings.html +++ b/actix_mvc_app/src/views/marketplace/my_listings.html @@ -58,17 +58,17 @@ {{ listing.title }} ${{ listing.price }} - {{ listing.listing_type.as_str() }} + {{ listing.listing_type }} - {% if listing.status.as_str() == "Active" %} - {{ listing.status.as_str() }} - {% elif listing.status.as_str() == "Sold" %} - {{ listing.status.as_str() }} - {% elif listing.status.as_str() == "Cancelled" %} - {{ listing.status.as_str() }} - {% elif listing.status.as_str() == "Expired" %} - {{ listing.status.as_str() }} + {% if listing.status == "Active" %} + {{ listing.status }} + {% elif listing.status == "Sold" %} + {{ listing.status }} + {% elif listing.status == "Cancelled" %} + {{ listing.status }} + {% elif listing.status == "Expired" %} + {{ listing.status }} {% endif %} {{ listing.created_at|date }} @@ -85,7 +85,7 @@ - {% if listing.status.as_str() == "Active" %} + {% if listing.status == "Active" %}