feat: voucher purchase flow

This commit is contained in:
fromme committed 2026-10-01 15:03:27 +02:00
1 parent a628e96d06
commit f3dd122678
70 files changed
+3672 -122

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
{# Sidebar of the voucher purchase steps, in place of the booking summary #}
<div class="bg-white h-full flex flex-col lg:border-l lg:border-primary-bg">
<div class="shrink-0 px-4 lg:px-8 py-4 lg:flex lg:flex-col lg:justify-center shadow-md relative z-10">
<div class="flex items-center justify-between pb-2">
<span class="block uppercase font-semibold">Gesamtpreis</span>
<span class="font-semibold">{{ (voucher.amount ?? 0)|format_currency('EUR') }}</span>
</div>
<div class="flex items-center justify-between">
<span class="block uppercase font-semibold">Dein Gutschein</span>
<button type="button"
class="lg:hidden button button--small bg-primary-light"
data-action="toggle#toggle">
<svg class="w-4 h-4 text-white transition-transform"
data-toggle-target="icon"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 256 256"><rect width="256" height="256" fill="none"/><polyline points="208 96 128 176 48 96" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="16"/></svg>
</button>
</div>
</div>
<div class="hidden lg:block flex-1 min-h-0 bg-white shadow-lg lg:shadow-none overflow-y-auto scroll-stable px-4 lg:px-8 py-8"
data-toggle-target="content">
{% if voucherThumbnail %}
<img src="{{ asset(voucherThumbnail) }}"
alt="Motiv {{ voucher.template.label }}"
class="block w-full max-w-sm h-auto mb-4 shadow">
{% endif %}
<div class="border border-primary-bg mb-4">
<div class="p-2 bg-primary-bg uppercase font-semibold">
Gutschein
</div>
<table class="w-full table-fixed">
<tr>
<td class="p-2 align-top w-24">Motiv</td>
<td class="p-2 align-top">{{ voucher.template.label ?? '–' }}</td>
</tr>
<tr>
<td class="p-2 align-top w-24">Von</td>
<td class="p-2 align-top break-words">{{ voucher.from ?: '–' }}</td>
</tr>
<tr>
<td class="p-2 align-top w-24">Für</td>
<td class="p-2 align-top break-words">{{ voucher.to ?: '–' }}</td>
</tr>
<tr>
<td class="p-2 align-top w-24">Wert</td>
<td class="p-2 align-top">{{ voucher.amount is not null ? voucher.amount|format_currency('EUR') : '–' }}</td>
</tr>
</table>
</div>
<div class="flex items-center justify-between pb-2">
<span class="block uppercase font-semibold">Gesamtpreis</span>
<span class="font-semibold">{{ (voucher.amount ?? 0)|format_currency('EUR') }}</span>
</div>
</div>
</div>
+30
View File
@@ -0,0 +1,30 @@
{% extends 'layout.html.twig' %}
{% block title %}Gutschein kaufen{% endblock %}
{% block content %}
<div class="px-4 lg:px-8 py-8 lg:py-16">
{% include '_partials/_flashes.html.twig' %}
<h1 class="text-white uppercase pb-4 mb-4 border-b border-primary-bg/40">
Gutschein<br>kaufen
</h1>
<div class="space-y-8 max-w-screen-sm">
<div>
<a href="{{ path('app_voucher_step_1') }}" class="button button--primary w-full md:w-auto">
Als Gast fortfahren
</a>
</div>
{% include '_partials/_purchase_login_form.html.twig' %}
</div>
</div>
{% endblock %}
{% block footer %}
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4">
{% include '_partials/_cancel_button.html.twig' with { cancel_url: path('app_voucher_cancel') } %}
</div>
{% endblock %}
+12
View File
@@ -0,0 +1,12 @@
{% extends 'layout_booking.html.twig' %}
{% block title %}Gutschein kaufen{% endblock %}
{% block content %}
<div class="flex-1 flex items-center justify-center"
hx-post="{{ path('app_voucher_init', { r: returnUrl }) }}"
hx-trigger="load"
hx-swap="none">
{% include '_partials/_spinner.html.twig' %}
</div>
{% endblock %}
+22
View File
@@ -0,0 +1,22 @@
{% extends 'htmx_modal.html.twig' %}
{% block title %}Sicher?{% endblock %}
{% block content %}
<div class="pb-8">
Möchtest du den Gutscheinkauf wirklich abbrechen?
</div>
<div class="flex flex-col space-y-4 md:flex-row md:space-y-0 justify-between">
<button type="button"
hx-post="{{ path('app_voucher_cancel') }}"
hx-target="body"
class="button button--primary">
Ja, Kauf abbrechen
</button>
<button type="button"
{{ stimulus_action('modal', 'close') }}
class="button button--secondary">
Nein, weiter einkaufen
</button>
</div>
{% endblock %}
+29
View File
@@ -0,0 +1,29 @@
{% extends 'htmx_modal.html.twig' %}
{% block title %}Vorschau{% endblock %}
{% block content %}
{% if not previewable %}
<div class="pb-4">
Für die Vorschau bitte zuerst Motiv, Von, Für und Gutscheinwert angeben.
</div>
{% else %}
{% set previewUrl = path('app_voucher_preview_pdf', { v: previewVersion }) %}
{# BusPro renders the PDF on demand, which takes a few seconds #}
<div class="relative" {{ stimulus_controller('frame-loading', { src: previewUrl }) }}>
<iframe title="Vorschau deines Gutscheins"
class="w-full h-[70vh] border border-primary-bg"
{{ stimulus_target('frame-loading', 'frame') }}></iframe>
<div class="absolute inset-0 flex flex-col items-center justify-center gap-4 bg-white"
{{ stimulus_target('frame-loading', 'indicator') }}>
{% include '_partials/_spinner.html.twig' with { class: 'w-24 h-24' } %}
<span>Die Vorschau wird erstellt …</span>
</div>
</div>
<div class="pt-4">
<a href="{{ previewUrl }}" target="_blank" rel="noopener" hx-boost="false" class="underline">
Vorschau in neuem Fenster öffnen
</a>
</div>
{% endif %}
{% endblock %}
+11
View File
@@ -0,0 +1,11 @@
{# Shown inside the preview frame, outside the site layout #}
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<title>Vorschau nicht verfügbar</title>
</head>
<body style="font-family: sans-serif; padding: 1rem;">
<p>{{ message }}</p>
</body>
</html>
+107
View File
@@ -0,0 +1,107 @@
{% extends 'layout_booking.html.twig' %}
{% set htmx_change_trigger = 'change delay:300ms' %}
{% block title %}Gutschein kaufen{% endblock %}
{% block content %}
{{ form_start(form, {
'attr': {
'class': 'flex-1 flex flex-col min-h-0',
'novalidate': 'novalidate'
}
}) }}
{# Pagination - mobile only (above summary) #}
<div class="lg:hidden">
{% include 'booking/_pagination.html.twig' with { current_step: 1, step_routes: stepRoutes } %}
</div>
<div class="flex-1 flex flex-col lg:grid lg:grid-cols-5 min-h-0 relative">
{% block voucher_summary %}
<div id="voucher-summary"
class="order-1 lg:order-2 lg:flex-1 lg:min-h-0 lg:col-span-2"
{{ stimulus_controller('toggle', { 'open': false }, { 'closed': 'hidden', 'open': 'absolute inset-0 z-20', 'iconOpen': 'rotate-180' }) }}
{% if htmx_oob_swap|default(false) %}hx-swap-oob="true"{% endif %}>
{% include 'voucher/_summary.html.twig' %}
</div>
{% endblock %}
<div id="form-wrapper"
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-primary-bg flex flex-col min-h-0">
{% include '_partials/_flashes.html.twig' %}
{# Pagination - desktop only (fixed above scrollable content) #}
<div class="hidden lg:block shrink-0">
{% include 'booking/_pagination.html.twig' with { current_step: 1, step_routes: stepRoutes } %}
</div>
{# The preview button waits until the voucher fields would pass step 1's validation #}
<div class="flex-1 overflow-y-auto scroll-stable px-4 lg:px-8 py-8"
{{ stimulus_controller('field-validity') }}
data-action="input->field-validity#update change->field-validity#update">
{% set validatedFieldAttr = { 'data-field-validity-target': 'field' } %}
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
{{ validation_alert(form, 'Bitte überprüfe deine Angaben', false) }}
{# Any change takes the input over unvalidated and refreshes the summary #}
<div hx-post="{{ path('app_voucher_step_1_refresh') }}"
hx-trigger="{{ htmx_change_trigger }}"
hx-include="closest form"
hx-swap="none">
<h2 class="pb-4">
Motiv
</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 pb-2">
{% for choice in form.template %}
<label for="{{ choice.vars.id }}"
class="block cursor-pointer bg-white rounded-md border-2 border-transparent p-2 has-[:checked]:border-primary-light">
{% set thumbnail = thumbnails[choice.vars.value] ?? null %}
{% if thumbnail %}
<img src="{{ asset(thumbnail) }}"
alt=""
loading="lazy"
class="block w-full h-auto mb-2">
{% endif %}
<span class="flex items-center gap-2 font-semibold">
{{ form_widget(choice, { attr: choice.vars.attr|merge(validatedFieldAttr) }) }}
{{ choice.vars.label }}
</span>
</label>
{% endfor %}
</div>
{% do form.template.setRendered %}
<div class="pb-6">{{ form_errors(form.template) }}</div>
<h2 class="pb-4">
Gutscheindaten
</h2>
{{ form_row(form.from, { attr: form.from.vars.attr|merge(validatedFieldAttr) }) }}
{{ form_row(form.to, { attr: form.to.vars.attr|merge(validatedFieldAttr) }) }}
{{ form_row(form.amount, {
attr: form.amount.vars.attr|merge(validatedFieldAttr),
help: 'Ganze Euro-Beträge von %s € bis %s €'|format(voucher.minAmount|number_format(0, ',', '.'), voucher.maxAmount|number_format(0, ',', '.'))
}) }}
</div>
<button type="button"
class="button button--secondary disabled:opacity-50 disabled:cursor-not-allowed"
title="Für die Vorschau bitte zuerst Motiv, Von, Für und Gutscheinwert angeben"
{{ stimulus_target('field-validity', 'button') }}
{% if not previewable %}disabled{% endif %}
hx-post="{{ path('app_voucher_preview') }}"
hx-include="closest form"
hx-target="body"
hx-swap="beforeend"
{{ qa_attribute('btn-preview') }}>
Vorschau anzeigen
</button>
</div>
</div>
</div>
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
<div class="flex justify-between" hx-disinherit="*">
{% include '_partials/_cancel_button.html.twig' with { cancel_url: path('app_voucher_cancel') } %}
<button type="submit" class="button button--primary" {{ qa_attribute('btn-submit') }}>
Weiter zu Schritt 2
</button>
</div>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% endblock %}
+79
View File
@@ -0,0 +1,79 @@
{% extends 'layout_booking.html.twig' %}
{% block title %}Gutschein kaufen{% endblock %}
{% block content %}
{{ form_start(form, {
'attr': {
'class': 'flex-1 flex flex-col min-h-0',
'novalidate': 'novalidate'
}
}) }}
{# Pagination - mobile only (above summary) #}
<div class="lg:hidden">
{% include 'booking/_pagination.html.twig' with { current_step: 2, step_routes: stepRoutes } %}
</div>
<div class="flex-1 flex flex-col lg:grid lg:grid-cols-5 min-h-0 relative">
<div id="voucher-summary"
class="order-1 lg:order-2 lg:flex-1 lg:min-h-0 lg:col-span-2"
{{ stimulus_controller('toggle', { 'open': false }, { 'closed': 'hidden', 'open': 'absolute inset-0 z-20', 'iconOpen': 'rotate-180' }) }}>
{% include 'voucher/_summary.html.twig' %}
</div>
<div id="form-wrapper"
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-primary-bg flex flex-col min-h-0">
{% include '_partials/_flashes.html.twig' %}
{# Pagination - desktop only (fixed above scrollable content) #}
<div class="hidden lg:block shrink-0">
{% include 'booking/_pagination.html.twig' with { current_step: 2, step_routes: stepRoutes } %}
</div>
<div class="flex-1 overflow-y-auto scroll-stable px-4 lg:px-8 py-8">
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
{{ validation_alert(form) }}
<h2 class="pb-4">
Käufer:in
</h2>
{{ form_row(form.salutation) }}
<div class="grid grid-cols-1 md:grid-cols-2 md:gap-x-4">
{{ form_row(form.title) }}
<div class="hidden md:block"></div>
{{ form_row(form.firstName) }}
{{ form_row(form.lastName) }}
<div class="md:col-span-2">{{ form_row(form.address.street) }}</div>
{{ form_row(form.address.postCode) }}
{{ form_row(form.address.city) }}
{{ form_row(form.address.country) }}
<div class="hidden md:block"></div>
{{ form_row(form.email) }}
<div class="hidden md:block"></div>
{{ form_row(form.phone) }}
{{ form_row(form.mobile) }}
</div>
<h2 class="pt-4 pb-4">
Zahlungsart
</h2>
<div class="border border-primary-bg bg-white p-4">
{{ voucher.paymentMethod.label ?? 'Überweisung' }}
</div>
</div>
</div>
</div>
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
<div class="flex justify-between" hx-disinherit="*">
{% include '_partials/_cancel_button.html.twig' with { cancel_url: path('app_voucher_cancel') } %}
<div class="flex items-center gap-2">
<a href="{{ path('app_voucher_step_1') }}"
class="button button--secondary"
{{ qa_attribute('btn-back') }}>
Zurück
</a>
<button type="submit" class="button button--primary" {{ qa_attribute('btn-submit') }}>
Weiter zu Schritt 3
</button>
</div>
</div>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% endblock %}
+124
View File
@@ -0,0 +1,124 @@
{% extends 'layout_booking.html.twig' %}
{% block title %}Gutschein kaufen{% endblock %}
{% block content %}
{{ form_start(form, {
'attr': {
'class': 'flex-1 flex flex-col min-h-0',
'novalidate': 'novalidate',
'hx-disabled-elt': 'find button[type=submit]'
}
}) }}
{# Pagination - mobile only #}
<div class="lg:hidden">
{% include 'booking/_pagination.html.twig' with { current_step: 3, step_routes: stepRoutes } %}
</div>
<div class="flex-1 flex flex-col lg:grid lg:grid-cols-5 min-h-0 relative">
<div id="voucher-summary"
class="order-1 lg:order-2 lg:flex-1 lg:min-h-0 lg:col-span-2"
{{ stimulus_controller('toggle', { 'open': false }, { 'closed': 'hidden', 'open': 'absolute inset-0 z-20', 'iconOpen': 'rotate-180' }) }}>
{% include 'voucher/_summary.html.twig' %}
</div>
<div id="form-wrapper"
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-white flex flex-col min-h-0">
{% include '_partials/_flashes.html.twig' %}
{# Pagination - desktop only #}
<div class="hidden lg:block shrink-0">
{% include 'booking/_pagination.html.twig' with { current_step: 3, step_routes: stepRoutes } %}
</div>
<div class="flex-1 overflow-y-auto scroll-stable px-4 lg:px-8 py-8">
<h2 class="pb-4">
Übersicht
</h2>
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
{{ validation_alert(form, 'Bitte bestätige beide Punkte', false) }}
<div class="border border-primary-bg mb-4">
<div class="p-2 bg-primary-bg uppercase font-semibold">
Gutschein
</div>
<table class="w-full table-fixed">
<tr>
<td class="p-2 align-top w-32">Motiv</td>
<td class="p-2 align-top">{{ voucher.template.label ?? '' }}</td>
</tr>
<tr>
<td class="p-2 align-top w-32">Von</td>
<td class="p-2 align-top break-words">{{ voucher.from }}</td>
</tr>
<tr>
<td class="p-2 align-top w-32">Für</td>
<td class="p-2 align-top break-words">{{ voucher.to }}</td>
</tr>
</table>
</div>
<div class="border border-primary-bg mb-4">
<div class="p-2 bg-primary-bg uppercase font-semibold">
Käufer:in
</div>
<div class="p-2">
{{ voucher.salutation }} {{ voucher.title }} {{ voucher.buyerFullName }}<br>
{{ voucher.address.street }}<br>
{{ voucher.address.country }} - {{ voucher.address.postCode }} {{ voucher.address.city }}<br>
{{ voucher.email }}
</div>
</div>
<div class="border border-primary-bg mb-4">
<div class="p-2 bg-primary-bg uppercase font-semibold">
Zahlungsart
</div>
<div class="p-2">
{{ voucher.paymentMethod.label ?? 'Überweisung' }}
</div>
</div>
<div class="flex items-center justify-between pb-4">
<span class="block uppercase font-semibold">Gesamtpreis</span>
<span class="font-semibold">{{ voucher.amount|format_currency('EUR') }}</span>
</div>
{% if purchasable %}
<div class="border border-primary-bg">
<div class="p-2 bg-primary-bg uppercase font-semibold">
Bestätigung
</div>
<div class="p-4">
{{ form_row(form.termsAccepted, {
'label_attr': {'class': 'text-base font-semibold'}
}) }}
{{ form_row(form.purchaseConfirmed, {
'label_attr': {'class': 'text-base font-semibold'}
}) }}
</div>
</div>
{% else %}
{% do form.termsAccepted.setRendered %}
{% do form.purchaseConfirmed.setRendered %}
{% endif %}
</div>
</div>
</div>
<div class="shrink-0 bg-primary-dark px-4 lg:px-8 py-2 lg:py-4 z-20">
<div class="flex justify-between" hx-disinherit="*">
{% include '_partials/_cancel_button.html.twig' with { cancel_url: path('app_voucher_cancel') } %}
<div class="flex items-center gap-2">
<a href="{{ path('app_voucher_step_2') }}"
class="button button--secondary"
{{ qa_attribute('btn-back') }}>
Zurück
</a>
{% if purchasable %}
<button type="submit" class="button button--primary" {{ qa_attribute('btn-submit') }}>
Zahlungspflichtig kaufen
</button>
{% endif %}
</div>
</div>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
{% endblock %}
+50
View File
@@ -0,0 +1,50 @@
{% extends 'layout.html.twig' %}
{% block title %}Gutschein gekauft{% endblock %}
{% block content %}
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 px-4 lg:px-8 py-8 lg:py-16">
<div>
<h1 class="text-white uppercase pb-4 mb-8 border-b border-primary-bg/40">
Vielen Dank
<br>
für deinen Gutscheinkauf
</h1>
{% if voucherNumber %}
<div class="text-xl text-white mb-8">
Deine Gutscheinnummer lautet
<br>
<strong class="font-mono">{{ voucherNumber }}</strong>
{% if invoiceNumber %}
<br>
<span class="text-base">Rechnungsnummer <span class="font-mono">{{ invoiceNumber }}</span></span>
{% endif %}
</div>
{% endif %}
<div class="pb-8">
{% include '_partials/_alert.html.twig' with {
level: 'info',
messages: [
'Bitte überweise den Betrag von %s.'|format(total|format_currency('EUR')),
email
? 'Sobald deine Zahlung eingegangen ist, erhältst du den Gutschein per E-Mail an %s.'|format(email)
: 'Sobald deine Zahlung eingegangen ist, erhältst du den Gutschein per E-Mail.'
]
} %}
</div>
{% if app.user %}
<a href="{{ path('app_account') }}" class="button button--primary">
Zu meinem Konto
</a>
{% else %}
{# hx-boost disabled for cross-origin #}
<a href="{{ returnUrl }}" hx-boost="false" class="button button--primary">
Zurück
</a>
{% endif %}
</div>
</div>
{% endblock %}