diff --git a/resources/views/livewire/association/profile.blade.php b/resources/views/livewire/association/profile.blade.php index fc4c5a7..c62b393 100644 --- a/resources/views/livewire/association/profile.blade.php +++ b/resources/views/livewire/association/profile.blade.php @@ -147,12 +147,32 @@ new class extends Component { ]) ->where('pubkey', $pubkey)->first(); - if ($this->currentPleb) { - $this->profileForm->setPleb($this->currentPleb); - $this->form->setPleb($this->currentPleb); - $this->no = $this->currentPleb->no_email; - $this->showEmail = !$this->no; + if (!$this->currentPleb) { + return; } + + $this->profileForm->setPleb($this->currentPleb); + $this->form->setPleb($this->currentPleb); + $this->no = $this->currentPleb->no_email; + $this->showEmail = !$this->no; + + if ($this->currentPleb->nip05_handle) { + $this->nip05VerifiedHandles = $this->getNip05HandlesForPubkey($this->currentPubkey); + + if (count($this->nip05VerifiedHandles) > 0) { + $this->nip05Verified = true; + $this->nip05VerifiedHandle = $this->nip05VerifiedHandles[0]; + + if (!in_array($this->profileForm->nip05Handle, $this->nip05VerifiedHandles, true)) { + $this->nip05HandleMismatch = true; + } + } + } + + $this->amountToPay = config('app.env') === 'production' ? 21000 : 1; + $this->resolveCurrentPaymentEvent(); + $this->loadEvents(); + $this->listenForPayment(); } public function handleNostrLoggedOut(): void @@ -1277,13 +1297,15 @@ new class extends Component { Mitgliedsbeitrag - - - Nostr Event für die Zahlung des Mitgliedsbeitrags: - {{ $currentPleb->paymentEvents->last()->event_id }} - - + @if($currentPleb->paymentEvents->last()) + + + Nostr Event für die Zahlung des Mitgliedsbeitrags: + {{ $currentPleb->paymentEvents->last()->event_id }} + + + @endif @if($invoiceStatusMessage) diff --git a/tests/Feature/Livewire/Association/ProfileTest.php b/tests/Feature/Livewire/Association/ProfileTest.php index f7b503e..9743cdf 100644 --- a/tests/Feature/Livewire/Association/ProfileTest.php +++ b/tests/Feature/Livewire/Association/ProfileTest.php @@ -15,6 +15,20 @@ it('handles nostr login correctly', function () { ->assertSet('currentPleb.pubkey', $pleb->pubkey); }); +it('handles nostr login for active member and initializes payment state', function () { + $pleb = EinundzwanzigPleb::factory()->active()->create(); + + expect($pleb->paymentEvents()->count())->toBe(0); + + Livewire::test('association.profile') + ->call('handleNostrLoggedIn', $pleb->pubkey) + ->assertSet('currentPubkey', $pleb->pubkey) + ->assertSet('currentPleb.pubkey', $pleb->pubkey) + ->assertSet('amountToPay', config('app.env') === 'production' ? 21000 : 1); + + expect($pleb->paymentEvents()->count())->toBeGreaterThan(0); +}); + it('handles nostr logout correctly', function () { $pleb = EinundzwanzigPleb::factory()->create();
- Nostr Event für die Zahlung des Mitgliedsbeitrags: - {{ $currentPleb->paymentEvents->last()->event_id }} -
+ Nostr Event für die Zahlung des Mitgliedsbeitrags: + {{ $currentPleb->paymentEvents->last()->event_id }} +