From 06c43501a06660d4684a22d143bbfdbaec1c0ce9 Mon Sep 17 00:00:00 2001 From: fsociety Date: Thu, 24 Oct 2024 19:02:17 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat(project-support):=20update?= =?UTF-8?q?=20project=20support=20links=20and=20implement=20voting=20funct?= =?UTF-8?q?ionality=20with=20reasons=20for=20rejection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Livewire/Forms/VoteForm.php | 12 + config/einundzwanzig/config.php | 11 + .../[ProjectProposal:slug].blade.php | 293 ++++++++++++++++++ .../project-support/index.blade.php | 6 +- 4 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 app/Livewire/Forms/VoteForm.php create mode 100644 config/einundzwanzig/config.php create mode 100644 resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php diff --git a/app/Livewire/Forms/VoteForm.php b/app/Livewire/Forms/VoteForm.php new file mode 100644 index 0000000..9606b27 --- /dev/null +++ b/app/Livewire/Forms/VoteForm.php @@ -0,0 +1,12 @@ + [ + 'npub1pt0kw36ue3w2g4haxq3wgm6a2fhtptmzsjlc2j2vphtcgle72qesgpjyc6', + 'npub1gvqkjccl9urg93svaw60jqkk3ux8r3ycl5t3rlvc9uzjeu0agfuss8x8qy', + 'npub10t8npnmqhpwx9w8k232kess7gqtdlr6kqjemdzf8jnughwqd0gwsez0924', + 'npub1r8343wqpra05l3jnc4jud4xz7vlnyeslf7gfsty7ahpf92rhfmpsmqwym8', + 'npub17fqtu2mgf7zueq2kdusgzwr2lqwhgfl2scjsez77ddag2qx8vxaq3vnr8y', + ], +]; diff --git a/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php b/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php new file mode 100644 index 0000000..6028be4 --- /dev/null +++ b/resources/views/pages/association/project-support/[ProjectProposal:slug].blade.php @@ -0,0 +1,293 @@ + fn() => $projectProposal, + 'isAllowed' => false, + 'currentPubkey' => null, + 'currentPleb' => null, + 'reasons' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(), + 'ownVoteExists' => false, + 'boardVotes' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereHas('einundzwanzigPleb', fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board'))) + ->where('value', true) + ->get(), + 'otherVotes' => fn() + => Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->whereDoesntHave( + 'einundzwanzigPleb', + fn($q) => $q->whereIn('npub', config('einundzwanzig.config.current_board')), + ) + ->where('value', true) + ->get(), +]); + +on([ + 'nostrLoggedIn' => function ($pubkey) { + $this->currentPubkey = $pubkey; + $this->currentPleb = \App\Models\EinundzwanzigPleb::query()->where('pubkey', $pubkey)->first(); + if ($this->currentPleb->association_status->value < 2) { + return $this->js('alert("Du bist hierzu nicht berechtigt.")'); + } + $this->isAllowed = true; + $this->ownVoteExists = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('einundzwanzig_pleb_id', $this->currentPleb->id) + ->exists(); + }, + 'nostrLoggedOut' => function () { + $this->isAllowed = false; + $this->currentPubkey = null; + $this->currentPleb = null; + }, +]); + +$approve = function () { + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => true, + ]); + $this->form->reset(); + $this->ownVoteExists = true; + $this->boardVotes = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); + $this->otherVotes = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); +}; + +$notApprove = function () { + $this->form->validate(); + + Vote::query()->updateOrCreate([ + 'project_proposal_id' => $this->projectProposal->id, + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + ], [ + 'value' => false, + 'reason' => $this->form->reason, + ]); + $this->form->reset(); + $this->ownVoteExists = true; + $this->reasons = Vote::query() + ->where('project_proposal_id', $this->projectProposal->id) + ->where('value', false) + ->get(); +}; + +?> + + + @volt +
+ + +
+ + +
+ +
+ {{ $projectProposal->created_at->format('D d M, Y') }} +
+
+ +

+ {{ $projectProposal->name }} +

+ + {!! $projectProposal->description !!} + +
+ +
+ +
+ + User 04 + +
Eingereicht von +
{{ $projectProposal->einundzwanzigPleb->profile->name }}
+
+
+ +
+ +
+ Webseite +
+
+ {{ number_format($projectProposal->support_in_sats, 0, ',', '.') }} Sats +
+
+
+ +
+ Meetup +
+ +
+ + +
+

+ Ablehnungen ({{ count($reasons) }}) +

+
    + @foreach($reasons as $reason) +
  • + + {{ $reason->einundzwanzigPleb->profile->name }} + +
    +
    + {{ $reason->einundzwanzigPleb->profile->name }} +
    +
    {{ $reason->reason }}
    +
    +
  • + @endforeach +
+
+ +
+ + +
+ + +
+ @if(!$ownVoteExists) +
+ + + +
+ @else +
+

Du hast bereits abgestimmt.

+
+ @endif +
+ + +
+
+
+ Zustimmungen des Vorstands ({{ count($boardVotes) }}) +
+
+
    + @foreach($boardVotes as $vote) +
  • +
    +
    +
    + {{ $vote->einundzwanzigPleb->profile->name }} +
    +
    + + {{ $vote->einundzwanzigPleb->profile->name }} + +
    +
    +
    +
  • + @endforeach +
+
+ + +
+
+
+ Zustimmungen der übrigen Mitglieder ({{ count($otherVotes) }}) +
+
+
    + @foreach($otherVotes as $vote) +
  • +
    +
    +
    + {{ $vote->einundzwanzigPleb->profile->name }} +
    +
    + + {{ $vote->einundzwanzigPleb->profile->name }} + +
    +
    +
    +
  • + @endforeach +
+
+ +
+ +
+ +
+ @endvolt +
diff --git a/resources/views/pages/association/project-support/index.blade.php b/resources/views/pages/association/project-support/index.blade.php index 08489a1..fac7df4 100644 --- a/resources/views/pages/association/project-support/index.blade.php +++ b/resources/views/pages/association/project-support/index.blade.php @@ -135,7 +135,7 @@ $delete = function ($id) { class="flex bg-white dark:bg-gray-800 shadow-sm rounded-xl overflow-hidden"> + href="{{ route('association.projectSupport.item', ['projectProposal' => $project]) }}"> Meetup 01