114 lines
3.4 KiB
Plaintext
114 lines
3.4 KiB
Plaintext
<html>
|
|
<head>
|
|
<title>Product Catalog</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
margin: 0;
|
|
padding: 20px;
|
|
}
|
|
.product {
|
|
border: 1px solid #ddd;
|
|
padding: 10px;
|
|
margin-bottom: 10px;
|
|
border-radius: 5px;
|
|
}
|
|
.product-available {
|
|
background-color: #f0fff0;
|
|
}
|
|
.product-unavailable {
|
|
background-color: #fff0f0;
|
|
}
|
|
.features {
|
|
margin-top: 5px;
|
|
}
|
|
.price {
|
|
font-weight: bold;
|
|
color: #2a5885;
|
|
}
|
|
.total {
|
|
margin-top: 20px;
|
|
text-align: right;
|
|
font-size: 1.2em;
|
|
}
|
|
.user-info {
|
|
background-color: #f5f5f5;
|
|
padding: 10px;
|
|
margin-top: 20px;
|
|
border-radius: 5px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>Product Catalog</h1>
|
|
|
|
<!-- Call Rhai function to get products and iterate over them -->
|
|
{% let products = data_objects:get_products() %}
|
|
<h2>All Products</h2>
|
|
{% for product in products %}
|
|
<div class="product {% if product.available %}product-available{% else %}product-unavailable{% endif %}">
|
|
<h3>{{ product.name }}</h3>
|
|
<div class="price">{{ data_objects:format_price(product.price) }}</div>
|
|
<div class="features">
|
|
<strong>Features:</strong>
|
|
<ul>
|
|
{% for feature in product.features %}
|
|
<li>{{ feature }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
<div>
|
|
{% if product.available %}
|
|
<span class="available">In Stock</span>
|
|
{% else %}
|
|
<span class="unavailable">Out of Stock</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<!-- Call Rhai function to get only available products -->
|
|
{% let available_products = data_objects:get_available_products() %}
|
|
<h2>Available Products ({{ available_products.len() }})</h2>
|
|
{% for product in available_products %}
|
|
<div class="product product-available">
|
|
<h3>{{ product.name }}</h3>
|
|
<div class="price">{{ data_objects:format_price(product.price) }}</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
<!-- Display total price using Rhai function -->
|
|
<div class="total">
|
|
Total Catalog Value: {{ data_objects:format_price(data_objects:calculate_total_price()) }}
|
|
</div>
|
|
|
|
<!-- Display user information from Rhai function -->
|
|
{% let user = data_objects:get_user() %}
|
|
<div class="user-info">
|
|
<h2>User Information</h2>
|
|
<p><strong>Name:</strong> {{ user.name }}</p>
|
|
<p><strong>Email:</strong> {{ user.email }}</p>
|
|
<p><strong>Role:</strong> {{ user.role }}</p>
|
|
<p><strong>Theme:</strong> {{ user.settings.theme }}</p>
|
|
|
|
<h3>Order History</h3>
|
|
<ul>
|
|
{% for order in user.orders %}
|
|
<li>
|
|
<strong>{{ order.id }}</strong> ({{ order.date }}) -
|
|
{{ data_objects:format_price(order.total) }}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- List all unique features -->
|
|
<h2>All Features</h2>
|
|
<ul>
|
|
{% let features = data_objects:get_all_features() %}
|
|
{% for feature in features %}
|
|
<li>{{ feature }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</body>
|
|
</html> |