05/07 Phase 3: fixed tenant's appoinment page error

This commit is contained in:
2026-05-07 15:48:24 -04:00
parent ce462c57b2
commit bac9f7ee2c
2 changed files with 28 additions and 17 deletions
+21 -14
View File
@@ -4,12 +4,11 @@
<div class="d-flex justify-content-between align-items-center mb-3"> <div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="fw-bold mb-0"><i class="bi bi-calendar3 me-2"></i>Appointments</h4> <h4 class="fw-bold mb-0"><i class="bi bi-calendar3 me-2"></i>Appointments</h4>
<div class="d-flex align-items-center gap-2"> <div class="d-flex align-items-center gap-2">
<a href="{{ url_for('appointments.index', date=(view_date - timedelta(days=1)).isoformat()) }}" <a href="{{ url_for('appointments.index', date=prev_date.isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></a> class="btn btn-outline-secondary btn-sm"></a>
<input type="date" class="form-control form-control-sm" value="{{ view_date.isoformat() }}" <input type="date" class="form-control form-control-sm" value="{{ view_date.isoformat() }}"
onchange="window.location='{{ url_for('appointments.index') }}?date='+this.value" onchange="window.location='{{ url_for('appointments.index') }}?date='+this.value" style="width:150px;">
style="width:150px;"> <a href="{{ url_for('appointments.index', date=next_date.isoformat()) }}"
<a href="{{ url_for('appointments.index', date=(view_date + timedelta(days=1)).isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></a> class="btn btn-outline-secondary btn-sm"></a>
<a href="{{ url_for('appointments.create') }}" class="btn btn-primary btn-sm ms-2">+ New</a> <a href="{{ url_for('appointments.create') }}" class="btn btn-primary btn-sm ms-2">+ New</a>
</div> </div>
@@ -19,7 +18,15 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover mb-0"> <table class="table table-hover mb-0">
<thead class="table-light"> <thead class="table-light">
<tr><th>Time</th><th>Customer</th><th>Service</th><th>Staff</th><th>Status</th><th>Type</th><th></th></tr> <tr>
<th>Time</th>
<th>Customer</th>
<th>Service</th>
<th>Staff</th>
<th>Status</th>
<th>Type</th>
<th></th>
</tr>
</thead> </thead>
<tbody> <tbody>
{% for appt in appointments %} {% for appt in appointments %}
@@ -29,28 +36,28 @@
<td class="small">{{ appt.service.name if appt.service else '—' }}</td> <td class="small">{{ appt.service.name if appt.service else '—' }}</td>
<td class="small">{{ appt.staff.name if appt.staff else '—' }}</td> <td class="small">{{ appt.staff.name if appt.staff else '—' }}</td>
<td> <td>
<span class="badge bg-{{ {'pending':'warning','confirmed':'primary','in_progress':'info','completed':'success','cancelled':'danger','no_show':'dark'}.get(appt.status,'secondary') }}"> <span
class="badge bg-{{ {'pending':'warning','confirmed':'primary','in_progress':'info','completed':'success','cancelled':'danger','no_show':'dark'}.get(appt.status,'secondary') }}">
{{ appt.status }} {{ appt.status }}
</span> </span>
</td> </td>
<td class="small">{{ 'Walk-in' if appt.is_walk_in else 'Booked' }}</td> <td class="small">{{ 'Walk-in' if appt.is_walk_in else 'Booked' }}</td>
<td> <td>
<a href="{{ url_for('appointments.view', appt_id=appt.id) }}" class="btn btn-outline-secondary btn-sm">View</a> <a href="{{ url_for('appointments.view', appt_id=appt.id) }}"
class="btn btn-outline-secondary btn-sm">View</a>
{% if appt.status in ['pending','confirmed','in_progress'] %} {% if appt.status in ['pending','confirmed','in_progress'] %}
<a href="{{ url_for('pos.checkout') }}?appointment_id={{ appt.id }}" class="btn btn-success btn-sm">Checkout</a> <a href="{{ url_for('pos.checkout') }}?appointment_id={{ appt.id }}"
class="btn btn-success btn-sm">Checkout</a>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
{% else %} {% else %}
<tr><td colspan="7" class="text-center text-muted py-4">No appointments for this day.</td></tr> <tr>
<td colspan="7" class="text-center text-muted py-4">No appointments for this day.</td>
</tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block scripts %}
<script>
// Import timedelta not available in Jinja — use JS for date nav
</script>
{% endblock %}
+4
View File
@@ -46,8 +46,12 @@ def index():
tenant_id=g.tenant.id, is_active=True).filter( tenant_id=g.tenant.id, is_active=True).filter(
Service.deleted_at.is_(None)).order_by(Service.name).all() Service.deleted_at.is_(None)).order_by(Service.name).all()
prev_date = view_date - timedelta(days=1)
next_date = view_date + timedelta(days=1)
return render_template("tenant/appointments/index.html", return render_template("tenant/appointments/index.html",
appointments=appts, view_date=view_date, appointments=appts, view_date=view_date,
prev_date=prev_date, next_date=next_date,
staff_list=staff_list, services=services) staff_list=staff_list, services=services)