🗑️ Remove obsolete pulse migration file, clean up unused directives in Blade templates, and streamline delete confirmation logic with Flux modals for improved UX and maintainability.

This commit is contained in:
HolgerHatGarKeineNode
2026-01-19 23:17:39 +01:00
parent c5793872af
commit 39835c3a24
8 changed files with 189 additions and 210 deletions

View File

@@ -23,12 +23,14 @@ class extends Component {
'description' => '',
];
public mixed $file;
public $file;
public bool $isAllowed = false;
public bool $canEdit = false;
public ?int $confirmDeleteId = null;
public function mount(): void
{
if (NostrAuth::check()) {
@@ -43,7 +45,7 @@ class extends Component {
$this->isAllowed = true;
}
if ($currentPleb && $currentPleb->association_status->value > 2) {
if ($currentPleb && in_array($currentPleb->npub, config('einundzwanzig.config.current_board'))) {
$this->canEdit = true;
}
@@ -86,18 +88,27 @@ class extends Component {
->get();
}
public function delete(int $id): void
public function confirmDelete(int $id): void
{
$news = Notification::query()->find($id);
if ($news) {
$news->delete();
}
$this->confirmDeleteId = $id;
}
public function delete(): void
{
$news = Notification::query()->findOrFail($this->confirmDeleteId);
$news->delete();
$this->news = \App\Models\Notification::query()
->with(['einundzwanzigPleb.profile'])
->latest()
->get();
}
public function removeFile(): void
{
$this->file->delete();
$this->file = null;
}
};
?>
@@ -161,46 +172,45 @@ class extends Component {
<div class="space-y-2">
@forelse($news as $post)
<flux:card wire:key="post_{{ $post->id }}">
<!-- Avatar -->
<div class="shrink-0 mt-1.5">
<img class="w-8 h-8 rounded-full"
src="{{ $post->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
width="32" height="32"
alt="{{ $post->einundzwanzigPleb->profile?->name }}">
</div>
<!-- Content -->
<div class="grow">
<!-- Title -->
<h2 class="font-semibold text-gray-800 dark:text-gray-100 mb-2">
{{ $post->name }}
</h2>
<p class="mb-6">
{{ $post->description }}
</p>
<!-- Footer -->
<footer class="flex flex-wrap text-sm">
<!-- Avatar -->
<div class="shrink-0 mt-1.5">
<img class="w-8 h-8 rounded-full"
src="{{ $post->einundzwanzigPleb->profile?->picture ?? asset('einundzwanzig-alpha.jpg') }}"
width="32" height="32"
alt="{{ $post->einundzwanzigPleb->profile?->name }}">
</div>
<!-- Content -->
<div class="grow">
<!-- Title -->
<h2 class="font-semibold text-gray-800 dark:text-gray-100 mb-2">
{{ $post->name }}
</h2>
<p class="mb-6">
{{ $post->description }}
</p>
<!-- Footer -->
<footer class="flex flex-wrap text-sm">
<div
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
<div
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
<div
class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400">
<div class="flex items-center">
<svg class="mr-2 fill-current" width="16"
height="16"
xmlns="http://www.w3.org/2000/svg">
<path
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
</svg>
{{ $post->einundzwanzigPleb->profile->name }}
</div>
class="font-medium text-amber-500 hover:text-amber-600 dark:hover:text-amber-400">
<div class="flex items-center">
<svg class="mr-2 fill-current" width="16"
height="16"
xmlns="http://www.w3.org/2000/svg">
<path
d="M15.686 5.708 10.291.313c-.4-.4-.999-.4-1.399 0s-.4 1 0 1.399l.6.6-6.794 3.696-1-1C1.299 4.61.7 4.61.3 5.009c-.4.4-.4 1 0 1.4l1.498 1.498 2.398 2.398L.6 14.001 2 15.4l3.696-3.697L9.692 15.7c.5.5 1.199.2 1.398 0 .4-.4.4-1 0-1.4l-.999-.998 3.697-6.695.6.6c.599.6 1.199.2 1.398 0 .3-.4.3-1.1-.1-1.499Zm-7.193 6.095L4.196 7.507l6.695-3.697 1.298 1.299-3.696 6.694Z"></path>
</svg>
{{ $post->einundzwanzigPleb->profile->name }}
</div>
</div>
<div
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
</div>
<div
class="flex items-center after:block after:content-['·'] last:after:content-[''] after:text-sm after:text-gray-400 dark:after:text-gray-600 after:px-2">
<span
class="text-gray-500">{{ $post->created_at->format('d.m.Y') }}</span>
</div>
</footer>
</div>
</div>
</footer>
</div>
<div class="mt-2 flex justify-end w-full space-x-2">
<flux:button
@@ -211,14 +221,34 @@ class extends Component {
Öffnen
</flux:button>
@if($canEdit)
<flux:button
xs
negative
wire:click="delete({{ $post->id }})"
wire:loading.attr="disabled"
icon="trash">
Löschen
</flux:button>
<flux:modal.trigger name="delete-news-{{ $post->id }}">
<flux:button
xs
variant="danger"
icon="trash"
wire:click="confirmDelete({{ $post->id }})">
Löschen
</flux:button>
</flux:modal.trigger>
<flux:modal name="delete-news-{{ $post->id }}" class="min-w-88">
<div class="space-y-6">
<div>
<flux:heading size="lg">News löschen?</flux:heading>
<flux:text class="mt-2">
Du bist dabei, diese News zu löschen.<br>
Diese Aktion kann nicht rückgängig gemacht werden.
</flux:text>
</div>
<div class="flex gap-2">
<flux:spacer />
<flux:modal.close>
<flux:button variant="ghost">Abbrechen</flux:button>
</flux:modal.close>
<flux:button wire:click="delete" variant="danger">Löschen</flux:button>
</div>
</div>
</flux:modal>
@endif
</div>
</flux:card>
@@ -246,17 +276,29 @@ class extends Component {
@if($canEdit)
<flux:card>
<div
class="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase mb-4">
class="text-xs font-semibold text-gray-400 dark:text-gray-200 uppercase mb-4">
News anlegen
</div>
<div class="mt-4 flex flex-col space-y-2">
<div wire:dirty>
<input class="text-gray-200" type="file" wire:model="file">
@error('file')
<span class="text-red-500">{{ $message }}</span>
@enderror
<flux:file-upload wire:model="file" label="PDF hochladen">
<flux:file-upload.dropzone heading="Drop file here or click to browse" text="PDF bis 10MB" />
</flux:file-upload>
@error('file')
<span class="text-red-500">{{ $message }}</span>
@enderror
<div class="mt-3 flex flex-col gap-2">
@if ($file)
<flux:file-item
:heading="$file->getClientOriginalName()"
:size="$file->getSize()"
>
<x-slot name="actions">
<flux:file-item.remove wire:click="removeFile" aria-label="{{ 'Remove file: ' . $file->getClientOriginalName() }}" />
</x-slot>
</flux:file-item>
@endif
</div>
<div wire:dirty>
<div>
<flux:field>
<flux:label>Kategorie</flux:label>
<flux:select
@@ -273,14 +315,14 @@ class extends Component {
<flux:error name="form.category"/>
</flux:field>
</div>
<div wire:dirty>
<div>
<flux:field>
<flux:label>Titel</flux:label>
<flux:input wire:model="form.name" placeholder="News-Titel"/>
<flux:error name="form.name"/>
</flux:field>
</div>
<div wire:dirty>
<div>
<flux:field>
<flux:label>Beschreibung</flux:label>
<flux:description>optional</flux:description>

View File

@@ -135,14 +135,14 @@ new class extends Component {
Flux::toast('E-Mail Adresse gespeichert.');
}
public function pay($comment): \Illuminate\Http\RedirectResponse
public function pay($comment): mixed
{
$paymentEvent = $this->currentPleb
->paymentEvents()
->where('year', date('Y'))
->first();
if ($paymentEvent->btc_pay_invoice) {
return redirect('https://pay.einundzwanzig.space/i/'.$paymentEvent->btc_pay_invoice);
return redirect()->away('https://pay.einundzwanzig.space/i/'.$paymentEvent->btc_pay_invoice);
}
try {
$response = \Illuminate\Support\Facades\Http::withHeaders([
@@ -172,7 +172,7 @@ new class extends Component {
$paymentEvent->btc_pay_invoice = $response->json()['id'];
$paymentEvent->save();
return redirect($response->json()['checkoutLink']);
return redirect()->away($response->json()['checkoutLink']);
} catch (\Exception $e) {
Flux::toast(
'Fehler beim Erstellen der Rechnung. Bitte versuche es später erneut: '.$e->getMessage(),
@@ -343,9 +343,7 @@ new class extends Component {
</p>
</div>
<div class="shrink-0">
<div class="text-xs inline-flex font-medium bg-green-500/20 text-green-700 rounded-full px-2.5 py-1">
Android
</div>
<flux:badge color="success">Android</flux:badge>
</div>
</div>
</flux:card>
@@ -362,9 +360,7 @@ new class extends Component {
</p>
</div>
<div class="shrink-0">
<div class="text-xs inline-flex font-medium bg-yellow-500/20 text-yellow-700 rounded-full px-2.5 py-1">
Browser Chrome/Firefox
</div>
<flux:badge color="warning">Browser Chrome/Firefox</flux:badge>
</div>
</div>
</flux:card>
@@ -381,9 +377,7 @@ new class extends Component {
</p>
</div>
<div class="shrink-0">
<div class="text-xs inline-flex font-medium bg-red-500/20 text-red-700 rounded-full px-2.5 py-1">
Browser Chrome
</div>
<flux:badge color="danger">Browser Chrome</flux:badge>
</div>
</div>
</flux:card>
@@ -400,9 +394,7 @@ new class extends Component {
</p>
</div>
<div class="shrink-0">
<div class="text-xs inline-flex font-medium bg-amber-500/20 text-amber-700 rounded-full px-2.5 py-1">
Browser Firefox
</div>
<flux:badge color="amber">Browser Firefox</flux:badge>
</div>
</div>
</flux:card>
@@ -440,7 +432,7 @@ new class extends Component {
@if($currentPubkey && !$currentPleb->application_for && $currentPleb->association_status->value < 2)
<!-- Membership Registration Section -->
<div class="space-y-4 py-6 border-t border-gray-200 dark:border-gray-700">
<div class="space-y-4 py-6 border-t border-gray-200 dark:border-gray-600">
<div>
<h3 class="text-xl md:text-2xl text-[#1B1B1B] dark:text-gray-100 font-bold mb-2">
Einundzwanzig Mitglied werden
@@ -472,7 +464,7 @@ new class extends Component {
@if($currentPubkey)
<!-- Email Settings Section -->
<div class="py-6 border-t border-gray-200 dark:border-gray-700">
<div class="py-6 border-t border-gray-200 dark:border-gray-600">
<flux:callout variant="warning" class="mb-6">
<div class="space-y-4">
<p class="font-medium text-gray-800 dark:text-gray-100">
@@ -590,7 +582,7 @@ new class extends Component {
<!-- Payment History -->
@if($payments && count($payments) > 0)
<div class="pt-6 border-t border-gray-200 dark:border-gray-700">
<div class="pt-6 border-t border-gray-200 dark:border-gray-600">
<h4 class="text-lg md:text-xl text-gray-800 dark:text-gray-100 font-bold mb-4">
Bisherige Zahlungen
</h4>
@@ -598,7 +590,7 @@ new class extends Component {
<!-- Desktop Table -->
<div class="hidden md:block overflow-x-auto">
<table class="table-auto w-full">
<thead class="text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-700">
<thead class="text-xs font-semibold uppercase text-gray-500 dark:text-gray-400 border-b border-gray-200 dark:border-gray-600">
<tr>
<th class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap text-left">
<div class="font-semibold">Satoshis</div>
@@ -614,7 +606,7 @@ new class extends Component {
</th>
</tr>
</thead>
<tbody class="text-sm divide-y divide-gray-200 dark:divide-gray-700">
<tbody class="text-sm divide-y divide-gray-200 dark:divide-gray-600">
@foreach($payments as $payment)
<tr>
<td class="px-2 first:pl-5 last:pr-5 py-3 whitespace-nowrap">
@@ -646,7 +638,7 @@ new class extends Component {
<!-- Mobile Cards -->
<div class="md:hidden space-y-4">
@foreach($payments as $payment)
<div class="bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4">
<div class="bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-600 p-4">
<div class="space-y-3">
<div class="flex justify-between items-center">
<span class="text-sm font-medium text-gray-500 dark:text-gray-400">Satoshis</span>

View File

@@ -68,14 +68,14 @@ class extends Component {
Formular
</h2>
<div class="space-y-4">
<div wire:dirty>
<div>
<flux:field>
<flux:label>Name</flux:label>
<flux:input wire:model="form.name" placeholder="Projektname" />
<flux:error name="form.name" />
</flux:field>
</div>
<div wire:dirty>
<div>
<flux:field>
<flux:label>Beschreibung</flux:label>
<flux:textarea wire:model="form.description" rows="6" placeholder="Projektbeschreibung..." />

View File

@@ -81,14 +81,14 @@ class extends Component {
Formular
</h2>
<div class="space-y-4">
<div wire:dirty>
<div>
<flux:field>
<flux:label>Name</flux:label>
<flux:input wire:model="form.name" placeholder="Projektname" />
<flux:error name="form.name" />
</flux:field>
</div>
<div wire:dirty>
<div>
<flux:field>
<flux:label>Beschreibung</flux:label>
<flux:textarea wire:model="form.description" rows="6" placeholder="Projektbeschreibung..." />

View File

@@ -0,0 +1,53 @@
<?php
use App\Support\NostrAuth;
use Livewire\Attributes\On;
use Livewire\Component;
new class extends Component
{
public bool $isLoggedIn = false;
public string $location = 'sidebar'; // 'sidebar' or 'navbar'
public function mount(): void
{
$this->isLoggedIn = NostrAuth::check();
}
#[On('nostrLoggedIn')]
public function handleNostrLoggedIn(string $pubkey): void
{
NostrAuth::login($pubkey);
$this->js('window.location.reload(true);');
}
#[On('nostrLoggedOut')]
public function handleNostrLoggedOut(): void
{
$this->isLoggedIn = false;
}
}
?>
<div x-data="nostrLogin">
@if($isLoggedIn)
@if($location === 'sidebar')
<form method="post" action="{{ route('logout') }}">
@csrf
<flux:sidebar.item icon="arrow-right-start-on-rectangle" type="submit" wire:click="$dispatch('nostrLoggedOut')">Logout</flux:sidebar.item>
</form>
@else
<form method="post" action="{{ route('logout') }}">
@csrf
<flux:navbar.item type="submit" icon="arrow-right-start-on-rectangle" wire:click="$dispatch('nostrLoggedOut')">Logout</flux:navbar.item>
</form>
@endif
@else
@if($location === 'sidebar')
<flux:sidebar.item icon="user" @click="openNostrLogin">Mit Nostr verbinden</flux:sidebar.item>
@else
<flux:navbar.item icon="user" @click="openNostrLogin">Mit Nostr verbinden</flux:navbar.item>
@endif
@endif
</div>