Hintergründe zum EventInvitePage Layout Customizer hinzugefügt. Badge und CTA entfernt, Textfelder zu Textareas gemacht. Geschenkgutscheine verbessert, E-Mail-Versand ergänzt + Resend + Confirmationseite mit Code-Copy und Link zur Package-Seite, die den Code als URL-Parameter enthält.

This commit is contained in:
Codex Agent
2025-12-08 16:20:04 +01:00
parent 046e2fe3ec
commit 4784c23e70
35 changed files with 1503 additions and 136 deletions

View File

@@ -6,13 +6,17 @@ use App\Filament\Resources\GiftVoucherResource\Pages;
use App\Models\GiftVoucher;
use App\Services\GiftVouchers\GiftVoucherService;
use BackedEnum;
use Carbon\Carbon;
use Filament\Forms\Components\Textarea;
use Filament\Actions\Action;
use Filament\Forms\Components\DateTimePicker;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\BadgeColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Filament\Tables\Actions\ExportAction;
use UnitEnum;
class GiftVoucherResource extends Resource
@@ -92,6 +96,45 @@ class GiftVoucherResource extends Resource
$service->refund($record, 'customer_request');
})
->successNotificationTitle('Gutschein erstattet'),
Action::make('resend')
->label('E-Mails erneut senden')
->icon('heroicon-o-paper-airplane')
->action(fn (GiftVoucher $record, GiftVoucherService $service) => $service->resend($record))
->successNotificationTitle('E-Mails werden erneut versendet'),
Action::make('schedule_delivery')
->label('Versand terminieren')
->icon('heroicon-o-clock')
->form([
DateTimePicker::make('recipient_delivery_scheduled_at')
->label('Versenden am')
->required()
->minDate(now()->addMinutes(10)),
])
->action(function (GiftVoucher $record, array $data, GiftVoucherService $service): void {
$service->scheduleRecipientDelivery(
$record,
Carbon::parse($data['recipient_delivery_scheduled_at'])
);
})
->visible(fn (GiftVoucher $record): bool => ! empty($record->recipient_email)),
Action::make('mark_redeemed')
->label('Als eingelöst markieren')
->color('success')
->visible(fn (GiftVoucher $record): bool => $record->canBeRedeemed())
->form([
Textarea::make('note')->label('Notiz')->maxLength(250),
])
->action(function (GiftVoucher $record, array $data): void {
$record->forceFill([
'status' => GiftVoucher::STATUS_REDEEMED,
'redeemed_at' => now(),
'metadata' => array_merge($record->metadata ?? [], [
'manual_note' => $data['note'] ?? null,
'manual_marked' => true,
]),
])->save();
})
->successNotificationTitle('Als eingelöst markiert'),
]);
}
@@ -106,4 +149,12 @@ class GiftVoucherResource extends Resource
'index' => Pages\ListGiftVouchers::route('/'),
];
}
public static function tableActions(): array
{
return [
ExportAction::make()
->label('Exportieren'),
];
}
}

View File

@@ -3,7 +3,12 @@
namespace App\Filament\Resources\GiftVoucherResource\Pages;
use App\Filament\Resources\GiftVoucherResource;
use App\Services\GiftVouchers\GiftVoucherService;
use Filament\Actions\Action;
use Filament\Resources\Pages\ListRecords;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Placeholder;
use Illuminate\Support\Str;
class ListGiftVouchers extends ListRecords
{
@@ -11,6 +16,55 @@ class ListGiftVouchers extends ListRecords
protected function getHeaderActions(): array
{
return [];
return [
Action::make('issue')
->label('Gutschein ausstellen')
->icon('heroicon-o-plus')
->form([
TextInput::make('amount')
->label('Betrag')
->numeric()
->required(),
TextInput::make('currency')
->label('Währung')
->default('EUR')
->maxLength(3)
->required(),
TextInput::make('purchaser_email')->label('E-Mail Käufer')->required(),
TextInput::make('recipient_email')->label('E-Mail Empfänger'),
TextInput::make('recipient_name')->label('Name Empfänger'),
TextInput::make('message')
->label('Nachricht')
->maxLength(500),
TextInput::make('code')
->label('Code (optional)')
->placeholder('GIFT-'.Str::upper(Str::random(8))),
Placeholder::make('code_hint')
->label('')
->content('Wenn kein Code eingetragen wird, erzeugen wir automatisch einen eindeutigen Gutscheincode.'),
])
->action(function (array $data, GiftVoucherService $service): void {
$payload = [
'id' => null,
'metadata' => [
'type' => 'gift_voucher',
'purchaser_email' => $data['purchaser_email'],
'recipient_email' => $data['recipient_email'] ?? null,
'recipient_name' => $data['recipient_name'] ?? null,
'message' => $data['message'] ?? null,
'gift_code' => $data['code'] ?? null,
],
'currency_code' => $data['currency'] ?? 'EUR',
'totals' => [
'grand_total' => [
'amount' => (float) $data['amount'],
],
],
];
$service->issueFromPaddle($payload);
})
->modalHeading('Geschenkgutschein ausstellen'),
];
}
}