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
+23 -16
View File
@@ -4,13 +4,12 @@
<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>
<div class="d-flex align-items-center gap-2">
<a href="{{ url_for('appointments.index', date=(view_date - timedelta(days=1)).isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></a>
<a href="{{ url_for('appointments.index', date=prev_date.isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></a>
<input type="date" class="form-control form-control-sm" value="{{ view_date.isoformat() }}"
onchange="window.location='{{ url_for('appointments.index') }}?date='+this.value"
style="width:150px;">
<a href="{{ url_for('appointments.index', date=(view_date + timedelta(days=1)).isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></a>
onchange="window.location='{{ url_for('appointments.index') }}?date='+this.value" style="width:150px;">
<a href="{{ url_for('appointments.index', date=next_date.isoformat()) }}"
class="btn btn-outline-secondary btn-sm"></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">
<table class="table table-hover mb-0">
<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>
<tbody>
{% for appt in appointments %}
@@ -29,28 +36,28 @@
<td class="small">{{ appt.service.name if appt.service else '—' }}</td>
<td class="small">{{ appt.staff.name if appt.staff else '—' }}</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 }}
</span>
</td>
<td class="small">{{ 'Walk-in' if appt.is_walk_in else 'Booked' }}</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'] %}
<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 %}
</td>
</tr>
{% 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 %}
</tbody>
</table>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
// Import timedelta not available in Jinja — use JS for date nav
</script>
{% endblock %}
+5 -1
View File
@@ -46,8 +46,12 @@ def index():
tenant_id=g.tenant.id, is_active=True).filter(
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",
appointments=appts, view_date=view_date,
prev_date=prev_date, next_date=next_date,
staff_list=staff_list, services=services)
@@ -224,4 +228,4 @@ def _user_db_id():
uid_str = current_user.get_id()
return int(uid_str.split(":")[1]) if uid_str and ":" in uid_str else None
except Exception:
return None
return None