diff --git a/src/allmende_payment_system/api/__init__.py b/src/allmende_payment_system/api/__init__.py index 25885f2..770c88b 100644 --- a/src/allmende_payment_system/api/__init__.py +++ b/src/allmende_payment_system/api/__init__.py @@ -9,12 +9,25 @@ templates = get_jinja_renderer() @root_router.get("/") -async def landing_page(request: Request, user: UserDep, session: SessionDep): +async def landing_page( + request: Request, user: UserDep, session: SessionDep, account_id: int | None = None +): + focused_account = None transactions = [] for account in user.accounts: + if account_id is not None and account.id != account_id: + continue + if account_id is not None and account.id == account_id: + focused_account = account transactions += account.transactions + transactions = sorted(transactions, key=lambda t: t.timestamp) return templates.TemplateResponse( "index.html.jinja", - context={"request": request, "user": user, "transactions": transactions}, + context={ + "request": request, + "user": user, + "transactions": transactions, + "focused_account": focused_account, + }, ) diff --git a/src/allmende_payment_system/templates/index.html.jinja b/src/allmende_payment_system/templates/index.html.jinja index 66627c3..4615d0a 100644 --- a/src/allmende_payment_system/templates/index.html.jinja +++ b/src/allmende_payment_system/templates/index.html.jinja @@ -8,16 +8,17 @@ {% if user.accounts|length > 0 %} {% for account in user.accounts %}
-
+
@@ -35,8 +36,8 @@
-

Letzte Buchungen

- Alle ansehen +

Letzte Buchungen{% if focused_account %} auf Konto "{{ focused_account.name }}"{% endif %}

+ {% if focused_account %}Alle Konten ansehen{% endif %}
@@ -57,7 +58,7 @@
- {{ '%+.2f' | format(transaction.total_amount | default(0)) }} € + {{ transaction.total_amount | format_number }} € {% if transaction.quantity %}
{{ transaction.quantity }} €