V-FOR-VEND3TTA / return-and-exchange-system

A return and exchange system to streamline the return and exchange process for ecommerce businesses, providing a seamless experience for customers and reducing operational headaches for the business using Django, Bootstrap
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Conditional Statement for Dashboard #13

Open V-FOR-VEND3TTA opened 4 months ago

V-FOR-VEND3TTA commented 4 months ago

Right now it just displays the dashboard header and your orders and nothing else. We have to make it so that it shows that you currently have no orders to return or exchanges. The options to:

V-FOR-VEND3TTA commented 4 months ago

Our modified dashboard.html:

{% extends "returns_exchanges/base.html" %}
{% block title %}Returns and Exchanges | Dashboard{% endblock %}

{% block content %}
<div class="container">
    <h1>Dashboard</h1>
    <h2>Your Orders</h2>

    {% if orders %}
        <ul>
            {% for order in orders %}
                <li>
                    <strong>Order Number:</strong> {{ order.order_number }} <br>
                    <strong>Order Date:</strong> {{ order.order_date }} <br>
                    <strong>Total Amount:</strong> ${{ order.total_amount }} <br>
                    <strong>Items:</strong>
                    <ul>
                        {% for item in order.items.all %}
                            <li>{{ item.product_name }} - ${{ item.price }} x {{ item.quantity }} 
                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#requestModal-{{ item.id }}">
                                    Request Return/Exchange
                                </button>

                                <!-- Modal -->
                                <div class="modal fade" id="requestModal-{{ item.id }}" tabindex="-1" role="dialog" aria-labelledby="requestModalLabel-{{ item.id }}" aria-hidden="true">
                                    <div class="modal-dialog" role="document">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h5 class="modal-title" id="requestModalLabel-{{ item.id }}">Request Return/Exchange for {{ item.product_name }}</h5>
                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                            <div class="modal-body">
                                                <form method="post" action="{% url 'return_exchange_request' %}">
                                                    {% csrf_token %}
                                                    {{ return_exchange_form.as_p }}
                                                    <button type="submit" class="btn btn-primary">Submit Request</button>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        {% endfor %}
                    </ul>
                </li>
            {% endfor %}
        </ul>
    {% else %}
        <p>You currently have no orders.</p>
    {% endif %}

    <h2>Return/Exchange Requests</h2>

    {% if return_requests %}
        <ul>
            {% for request in return_requests %}
                <li>
                    <strong>Order Item:</strong> {{ request.order_item.product_name }} <br>
                    <strong>Request Type:</strong> {{ request.get_request_type_display }} <br>
                    <strong>Status:</strong> {{ request.get_status_display }} <br>
                    <strong>Reason:</strong> {{ request.reason }} <br>
                    <strong>Date:</strong> {{ request.created_at }} <br>
                    <strong>Response:</strong> {{ request.response }} <br>
                </li>
            {% endfor %}
        </ul>
    {% else %}
        <p>You currently have no return or exchange requests.</p>
    {% endif %}
</div>
{% endblock %}

NB: For {% url 'return_exchange_request' %} we remove the item.id because it has no use at this point.