From 1d0c81619249ddbaa7e1138c5dcb4797a4a4a4c6 Mon Sep 17 00:00:00 2001 From: fsociety Date: Mon, 30 Sep 2024 14:52:52 +0200 Subject: [PATCH] feat: filter payment tags in profile view This commit introduces a filter for payment tags in the association profile view. This filter ensures that only the payments with the current public key are shown. Minor adjustments are also made in the JSON_THROW_ON_ERROR and the comparison of year and amount in the currentYearIsPaid method. --- resources/views/pages/association/profile.blade.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/resources/views/pages/association/profile.blade.php b/resources/views/pages/association/profile.blade.php index cc8ac1c..3ee830a 100644 --- a/resources/views/pages/association/profile.blade.php +++ b/resources/views/pages/association/profile.blade.php @@ -98,7 +98,10 @@ $searchPaymentEvent = function () { 'pubkey' => $event->event->pubkey, 'tags' => $event->event->tags, 'created_at' => $event->event->created_at, - ])->toArray(); + ]) + ->filter(fn($payment) => collect($payment['tags'])->firstWhere('0', 'p')[1] === $this->currentPubkey) + ->values() + ->toArray(); $this->yearsPaid = collect($this->payments)->map(fn($payment) => [ @@ -108,13 +111,13 @@ $searchPaymentEvent = function () { collect($payment['tags'])->firstWhere('0', 'description')[1], true, 512, - JSON_THROW_ON_ERROR - )['tags'] + JSON_THROW_ON_ERROR, + )['tags'], )->firstWhere('0', 'amount')[1] / 1000, ]); $this->currentYearIsPaid = collect($this->yearsPaid)->contains( - fn($yearPaid) => $yearPaid['year'] == date('Y') && $yearPaid['amount'] == $this->amountToPay + fn($yearPaid) => $yearPaid['year'] == date('Y') && $yearPaid['amount'] == $this->amountToPay, ); $this->paid = true;