{% extends 'base.html' %} {% from '_macros.html' import empty_state %} {% block title %}My orders · TradeHub{% endblock %} {% block content %}
Buying Selling
{% if orders %}
{% for order in orders %} {% set product = order.product %} {% set is_seller = (tab == 'selling') %}
{{ product.title }}
{{ product.title }}
${{ '%.2f' % product.price }}
{{ order.status_label }} {% if is_seller %}Buyer: {{ order.buyer.username }} {% else %}Seller: {{ product.seller.username }}{% endif %} {{ order.created_at.strftime('%b %d, %Y') }}
{% if order.note %}

Note: {{ order.note }}

{% endif %}
{# Chat button (both roles) — other user is the opposite of current role #} {% set other_id = order.buyer_id if is_seller else product.seller_id %} Chat {# Seller actions #} {% if is_seller %} {% if order.status == 'pending' %}
{% endif %} {% endif %} {# Complete (both parties can do it) #} {% if order.status == 'confirmed' %}
{% endif %} {# Cancel (buyer) #} {% if not is_seller and order.status in ('pending', 'confirmed') %}
{% endif %} {# Leave review (buyer, completed, no review yet) #} {% if not is_seller and order.status == 'completed' and not order.review %} Review {% endif %} {# Already reviewed #} {% if not is_seller and order.review %} Edit review {% endif %}
{% endfor %}
{% else %} {{ empty_state( icon='shopping-bag', title='No orders yet', message='Browse the marketplace to find something you like.' if tab == 'buying' else 'No incoming orders — list something to start selling.', cta_url=url_for('main.index') if tab == 'buying' else url_for('products.publish'), cta_text='Browse items' if tab == 'buying' else 'List an item' ) }} {% endif %}
{% endblock %}